cachingpropertiesglibgnome

Is there a g_dbus function to update the non cached property value?


I am working on a head unit project using a Raspberry Pi. The goal is to have a graphical user interface on the head unit that can control the phone when playing music.

I cant seem to get the phone to enable "Shuffle" or "Repeat".

I am using Bluez 5.45, and GLIB. I have basic control over play, stop, next.

Is there a similar function to g_dbus_proxy_set_cached_property()?

I have tried the function g_dbus_proxy_set_cached_property() but it only updates the cached value, the phone never receives the value set.


Solution

  • I found out how to set/get properties. I used the g_dbus_proxy_call_sync method.

    g_dbus_proxy_call_sync (GDBusProxy *proxy,
                        const gchar *method_name,
                        GVariant *parameters,
                        GDBusCallFlags flags,
                        gint timeout_msec,
                        GCancellable *cancellable,
                        GError **error);
    

    I needed to access the "org.freedesktop.DBUS.Properties" interface. I needed to use the "Set" method. It takes three paramaters.

    Set(String interface_name, String property_name, A value)

    1. interface_name - The interface the property is associated with
    2. propertyName - The name of the property
    3. value - The new value of the property (May be any valid DBUS type).

      g_dbus_proxy_call_sync( myProxy, "org.freedesktop.DBus.Properties.Set", g_variant_new ("(ssv)", "org.bluez.MediaPlayer1", "Repeat", g_variant_new_string ("alltracks")), G_DBUS_CALL_FLAGS_NONE, // Flags -1, // timeout NULL, // cancellable &error // error );