help on a{sv} passing by dbus-glib

Yi Hui Fan yihuifan at
Wed Mar 23 01:53:58 PDT 2011


I made a sample program to call methods published by bluez. Here is the 
api description.

object  CreateApplication(dict config)

                Returns the path of the new registered application.

                Dict is defined as bellow:
                        "DataType": uint16, (mandatory)
                        "Role" : ("Source" or "Sink"), (mandatory)
                        "Description" : string, (optional)
                        "ChannelType" : ("Reliable" or "Streaming")
                                                (just for Sources, 

                Application will be closed by the call or implicitly when 
                programs leaves the bus.

                Possible errors: org.bluez.Error.InvalidArguments

Now, I create a sample by using dbus-glib as following, I get an error 
Caught remote method exception org.bluez.Error.InvalidArguments: Invalid 
arguments in method call

Maybe it's a problem about send a{sv} data as parameters of method call. 
Is there any one help me to resolve the problem?

here is the code:

dbus_g_proxy_call(proxy, "CreateApplication", &err,
                get_hdp_properties_type(), create_hdp_properties, 
                G_TYPE_STRING, &app_path, G_TYPE_INVALID)

GHashTable *create_hdp_properties()
        GHashTable *hash;
        GValue *val;
        //GVariant *val_data_type, *val_role;
        hash = g_hash_table_new_full(g_str_hash, NULL, NULL, release_val);

        val = g_new0(GValue, 1);
        g_value_init (val, G_TYPE_UINT);
        g_value_set_uint(val, 4100);
        g_hash_table_insert(hash, "DataType", val);
        val_data_type = g_variant_new_uint32(4100);
        g_hash_table_insert(hash, "DataType", val_data_type);
        val = g_new0(GValue, 1);
        g_value_init(val, G_TYPE_STRING);
        g_value_set_string(val, "Sink");
        g_hash_table_insert(hash, "Role", val);
        val_role = g_variant_new_string("Sink");
        g_hash_table_insert(hash, "Role", val_role);

        return hash;

GType get_hdp_properties_type()
        return dbus_g_type_get_map("GHashTable", G_TYPE_STRING, 

Thanks &
Best regards,

Yihui,Fan (范益辉)
Associate IT Architect
Healthcare Standards
Emerging Technology Institute(ETI)
IBM China Software Development Lab
Tel: (8610) 82454982  | Fax: (8610) 82453600 
Mobile: 86-13911564003| Email: yihuifan at
Address: Tower B, Diamond Building, Zhongguancun Software Park, Haidian 
District, Beijing 100193, P.R.China

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the dbus mailing list