GATT ReadValue in c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I am trying to develop my GATT client using DBUS
I have the next code in order to read some data using ReadValue, but
i'm not sure that I convert properly the results into string.

If I'm using the next gdbus command:
gdbus call --system --dest org.bluez  --object-path
/org/bluez/hci1/dev_C7_5E_38_E7_67_25/service000b/char000c --method
org.bluez.GattCharacteristic1.ReadValue "{}"
([byte 0x48, 0x45, 0x4c, 0x4c, 0x4f, 0x21],) // it means HELLO!

If I use my code, is giving me nothing:

        GVariantBuilder *builder = g_variant_builder_new(
G_VARIANT_TYPE("a{sv}") );
        GVariant *options = g_variant_new ("a{sv}", builder);
        g_variant_builder_unref (builder);

        GVariant *args = g_variant_new("(@a{sv})", options);

        GVariant *result =
bluez_adapter_call_method_sync(tx_path.c_str(), "ReadValue",
"org.bluez.GattCharacteristic1", args);
        if (result) {
                GVariant *received_data = g_variant_get_child_value(result, 0);
                cout << g_variant_get_bytestring(received_data) << endl;
        }

tx_path is initialized with
/org/bluez/hci1/dev_C7_5E_38_E7_67_25/service000b/char000c

Do you have any idea what I'm doing wrong?
Thank you in advance

Cristian-Stefan



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux