diff options
author | Petre Eftime <[email protected]> | 2016-08-19 17:37:00 +0300 |
---|---|---|
committer | Petre Eftime <[email protected]> | 2016-08-19 17:37:00 +0300 |
commit | 447ec6b865a760b57d16eeaf8da46d8eb2d94d8b (patch) | |
tree | 6a06d61c892b6cc47a504ae3a018fe83f49708b9 | |
parent | 6426b0c91136710c559bb86a29e3a4c1cb40e7ad (diff) |
Support for BlueZ 5.40+, previous versions will stop working
Signed-off-by: Petre Eftime <[email protected]>
-rw-r--r-- | src/BluetoothGattCharacteristic.cpp | 25 | ||||
-rw-r--r-- | src/BluetoothGattDescriptor.cpp | 23 | ||||
-rw-r--r-- | src/generated-code.c | 132 | ||||
-rw-r--r-- | src/org.bluez.xml | 4 |
4 files changed, 157 insertions, 27 deletions
diff --git a/src/BluetoothGattCharacteristic.cpp b/src/BluetoothGattCharacteristic.cpp index d947ad7..6a88a41 100644 --- a/src/BluetoothGattCharacteristic.cpp +++ b/src/BluetoothGattCharacteristic.cpp @@ -120,16 +120,27 @@ std::unique_ptr<BluetoothGattCharacteristic> BluetoothGattCharacteristic::make( } /* D-Bus method calls: */ -std::vector<unsigned char> BluetoothGattCharacteristic::read_value () +std::vector<unsigned char> BluetoothGattCharacteristic::read_value (uint16_t offset) { GError *error = NULL; GBytes *result_gbytes; + + GVariantDict dict; + g_variant_dict_init(&dict, NULL); + + if (offset != 0) + g_variant_dict_insert_value(&dict, "offset", g_variant_new_uint16(offset)); + + GVariant *variant = g_variant_dict_end(&dict); + gatt_characteristic1_call_read_value_sync( object, &result_gbytes, + variant, NULL, &error ); + handle_error(error); std::vector<unsigned char> result = from_gbytes_to_vector(result_gbytes); @@ -141,19 +152,29 @@ std::vector<unsigned char> BluetoothGattCharacteristic::read_value () } bool BluetoothGattCharacteristic::write_value ( - const std::vector<unsigned char> &arg_value) + const std::vector<unsigned char> &arg_value, uint16_t offset) { GError *error = NULL; bool result = true; GBytes *arg_value_gbytes = from_vector_to_gbytes(arg_value); + GVariantDict dict; + g_variant_dict_init(&dict, NULL); + + if (offset != 0) + g_variant_dict_insert_value(&dict, "offset", g_variant_new_uint16(offset)); + + GVariant *variant = g_variant_dict_end(&dict); + result = gatt_characteristic1_call_write_value_sync( object, arg_value_gbytes, + variant, NULL, &error ); + handle_error(error); /* freeing the GBytes allocated inside from_vector_to_gbytes function */ diff --git a/src/BluetoothGattDescriptor.cpp b/src/BluetoothGattDescriptor.cpp index bd21034..9095c87 100644 --- a/src/BluetoothGattDescriptor.cpp +++ b/src/BluetoothGattDescriptor.cpp @@ -124,13 +124,23 @@ BluetoothGattDescriptor *BluetoothGattDescriptor::clone() const } /* D-Bus method calls: */ -std::vector<unsigned char> BluetoothGattDescriptor::read_value () +std::vector<unsigned char> BluetoothGattDescriptor::read_value (uint16_t offset) { GError *error = NULL; GBytes *result_gbytes; + + GVariantDict dict; + g_variant_dict_init(&dict, NULL); + + if (offset != 0) + g_variant_dict_insert_value(&dict, "offset", g_variant_new_uint16(offset)); + + GVariant *variant = g_variant_dict_end(&dict); + gatt_descriptor1_call_read_value_sync( object, &result_gbytes, + variant, NULL, &error ); @@ -145,16 +155,25 @@ std::vector<unsigned char> BluetoothGattDescriptor::read_value () } bool BluetoothGattDescriptor::write_value ( - const std::vector<unsigned char> &arg_value) + const std::vector<unsigned char> &arg_value, uint16_t offset) { GError *error = NULL; bool result; GBytes *arg_value_gbytes = from_vector_to_gbytes(arg_value); + GVariantDict dict; + g_variant_dict_init(&dict, NULL); + + if (offset != 0) + g_variant_dict_insert_value(&dict, "offset", g_variant_new_uint16(offset)); + + GVariant *variant = g_variant_dict_end(&dict); + result = gatt_descriptor1_call_write_value_sync( object, arg_value_gbytes, + variant, NULL, &error ); diff --git a/src/generated-code.c b/src/generated-code.c index 45f1e89..5201071 100644 --- a/src/generated-code.c +++ b/src/generated-code.c @@ -1,5 +1,5 @@ /* - * Generated by gdbus-codegen 2.45.4. DO NOT EDIT. + * Generated by gdbus-codegen 2.48.1. DO NOT EDIT. * * The license of this code is the same as for the source it was derived from. */ @@ -7318,6 +7318,23 @@ gatt_service1_skeleton_new (void) /* ---- Introspection data for org.bluez.GattCharacteristic1 ---- */ +static const _ExtendedGDBusArgInfo _gatt_characteristic1_method_info_read_value_IN_ARG_options = +{ + { + -1, + (gchar *) "options", + (gchar *) "a{sv}", + NULL + }, + FALSE +}; + +static const _ExtendedGDBusArgInfo * const _gatt_characteristic1_method_info_read_value_IN_ARG_pointers[] = +{ + &_gatt_characteristic1_method_info_read_value_IN_ARG_options, + NULL +}; + static const _ExtendedGDBusArgInfo _gatt_characteristic1_method_info_read_value_OUT_ARG_value = { { @@ -7340,7 +7357,7 @@ static const _ExtendedGDBusMethodInfo _gatt_characteristic1_method_info_read_val { -1, (gchar *) "ReadValue", - NULL, + (GDBusArgInfo **) &_gatt_characteristic1_method_info_read_value_IN_ARG_pointers, (GDBusArgInfo **) &_gatt_characteristic1_method_info_read_value_OUT_ARG_pointers, NULL }, @@ -7359,9 +7376,21 @@ static const _ExtendedGDBusArgInfo _gatt_characteristic1_method_info_write_value FALSE }; +static const _ExtendedGDBusArgInfo _gatt_characteristic1_method_info_write_value_IN_ARG_options = +{ + { + -1, + (gchar *) "options", + (gchar *) "a{sv}", + NULL + }, + FALSE +}; + static const _ExtendedGDBusArgInfo * const _gatt_characteristic1_method_info_write_value_IN_ARG_pointers[] = { &_gatt_characteristic1_method_info_write_value_IN_ARG_value, + &_gatt_characteristic1_method_info_write_value_IN_ARG_options, NULL }; @@ -7587,6 +7616,7 @@ gatt_characteristic1_default_init (GattCharacteristic1Iface *iface) * GattCharacteristic1::handle-read-value: * @object: A #GattCharacteristic1. * @invocation: A #GDBusMethodInvocation. + * @arg_options: Argument passed by remote caller. * * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-bluez-GattCharacteristic1.ReadValue">ReadValue()</link> D-Bus method. * @@ -7602,14 +7632,15 @@ gatt_characteristic1_default_init (GattCharacteristic1Iface *iface) NULL, g_cclosure_marshal_generic, G_TYPE_BOOLEAN, - 1, - G_TYPE_DBUS_METHOD_INVOCATION); + 2, + G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_VARIANT); /** * GattCharacteristic1::handle-write-value: * @object: A #GattCharacteristic1. * @invocation: A #GDBusMethodInvocation. * @arg_value: Argument passed by remote caller. + * @arg_options: Argument passed by remote caller. * * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-bluez-GattCharacteristic1.WriteValue">WriteValue()</link> D-Bus method. * @@ -7625,8 +7656,8 @@ gatt_characteristic1_default_init (GattCharacteristic1Iface *iface) NULL, g_cclosure_marshal_generic, G_TYPE_BOOLEAN, - 2, - G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING); + 3, + G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_VARIANT); /** * GattCharacteristic1::handle-start-notify: @@ -8018,6 +8049,7 @@ gatt_characteristic1_set_descriptors (GattCharacteristic1 *object, const gchar * /** * gatt_characteristic1_call_read_value: * @proxy: A #GattCharacteristic1Proxy. + * @arg_options: Argument to pass with the method invocation. * @cancellable: (allow-none): A #GCancellable or %NULL. * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. * @user_data: User data to pass to @callback. @@ -8031,13 +8063,15 @@ gatt_characteristic1_set_descriptors (GattCharacteristic1 *object, const gchar * void gatt_characteristic1_call_read_value ( GattCharacteristic1 *proxy, + GVariant *arg_options, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_dbus_proxy_call (G_DBUS_PROXY (proxy), "ReadValue", - g_variant_new ("()"), + g_variant_new ("(@a{sv})", + arg_options), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, @@ -8094,6 +8128,7 @@ _out: /** * gatt_characteristic1_call_read_value_sync: * @proxy: A #GattCharacteristic1Proxy. + * @arg_options: Argument to pass with the method invocation. * @out_value: (out): Return location for return parameter or %NULL to ignore. * @cancellable: (allow-none): A #GCancellable or %NULL. * @error: Return location for error or %NULL. @@ -8108,6 +8143,7 @@ gboolean gatt_characteristic1_call_read_value_sync ( GattCharacteristic1 *proxy, GBytes **out_value, + GVariant *arg_options, GCancellable *cancellable, GError **error) { @@ -8119,7 +8155,8 @@ gatt_characteristic1_call_read_value_sync ( _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), "ReadValue", - g_variant_new ("()"), + g_variant_new ("(@a{sv})", + arg_options), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, @@ -8148,6 +8185,7 @@ _out: * gatt_characteristic1_call_write_value: * @proxy: A #GattCharacteristic1Proxy. * @arg_value: Argument to pass with the method invocation. + * @arg_options: Argument to pass with the method invocation. * @cancellable: (allow-none): A #GCancellable or %NULL. * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. * @user_data: User data to pass to @callback. @@ -8162,6 +8200,7 @@ void gatt_characteristic1_call_write_value ( GattCharacteristic1 *proxy, GBytes *arg_value, + GVariant *arg_options, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -8178,8 +8217,9 @@ gatt_characteristic1_call_write_value ( g_dbus_proxy_call (G_DBUS_PROXY (proxy), "WriteValue", - g_variant_new ("(ay)", - builder), + g_variant_new ("(ay@a{sv})", + builder, + arg_options), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, @@ -8220,6 +8260,7 @@ _out: * gatt_characteristic1_call_write_value_sync: * @proxy: A #GattCharacteristic1Proxy. * @arg_value: Argument to pass with the method invocation. + * @arg_options: Argument to pass with the method invocation. * @cancellable: (allow-none): A #GCancellable or %NULL. * @error: Return location for error or %NULL. * @@ -8233,6 +8274,7 @@ gboolean gatt_characteristic1_call_write_value_sync ( GattCharacteristic1 *proxy, GBytes *arg_value, + GVariant *arg_options, GCancellable *cancellable, GError **error) { @@ -8249,8 +8291,9 @@ gatt_characteristic1_call_write_value_sync ( _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), "WriteValue", - g_variant_new ("(ay)", - builder), + g_variant_new ("(ay@a{sv})", + builder, + arg_options), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, @@ -9576,6 +9619,23 @@ gatt_characteristic1_skeleton_new (void) /* ---- Introspection data for org.bluez.GattDescriptor1 ---- */ +static const _ExtendedGDBusArgInfo _gatt_descriptor1_method_info_read_value_IN_ARG_options = +{ + { + -1, + (gchar *) "options", + (gchar *) "a{sv}", + NULL + }, + FALSE +}; + +static const _ExtendedGDBusArgInfo * const _gatt_descriptor1_method_info_read_value_IN_ARG_pointers[] = +{ + &_gatt_descriptor1_method_info_read_value_IN_ARG_options, + NULL +}; + static const _ExtendedGDBusArgInfo _gatt_descriptor1_method_info_read_value_OUT_ARG_value = { { @@ -9598,7 +9658,7 @@ static const _ExtendedGDBusMethodInfo _gatt_descriptor1_method_info_read_value = { -1, (gchar *) "ReadValue", - NULL, + (GDBusArgInfo **) &_gatt_descriptor1_method_info_read_value_IN_ARG_pointers, (GDBusArgInfo **) &_gatt_descriptor1_method_info_read_value_OUT_ARG_pointers, NULL }, @@ -9617,9 +9677,21 @@ static const _ExtendedGDBusArgInfo _gatt_descriptor1_method_info_write_value_IN_ FALSE }; +static const _ExtendedGDBusArgInfo _gatt_descriptor1_method_info_write_value_IN_ARG_options = +{ + { + -1, + (gchar *) "options", + (gchar *) "a{sv}", + NULL + }, + FALSE +}; + static const _ExtendedGDBusArgInfo * const _gatt_descriptor1_method_info_write_value_IN_ARG_pointers[] = { &_gatt_descriptor1_method_info_write_value_IN_ARG_value, + &_gatt_descriptor1_method_info_write_value_IN_ARG_options, NULL }; @@ -9767,6 +9839,7 @@ gatt_descriptor1_default_init (GattDescriptor1Iface *iface) * GattDescriptor1::handle-read-value: * @object: A #GattDescriptor1. * @invocation: A #GDBusMethodInvocation. + * @arg_options: Argument passed by remote caller. * * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-bluez-GattDescriptor1.ReadValue">ReadValue()</link> D-Bus method. * @@ -9782,14 +9855,15 @@ gatt_descriptor1_default_init (GattDescriptor1Iface *iface) NULL, g_cclosure_marshal_generic, G_TYPE_BOOLEAN, - 1, - G_TYPE_DBUS_METHOD_INVOCATION); + 2, + G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_VARIANT); /** * GattDescriptor1::handle-write-value: * @object: A #GattDescriptor1. * @invocation: A #GDBusMethodInvocation. * @arg_value: Argument passed by remote caller. + * @arg_options: Argument passed by remote caller. * * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-bluez-GattDescriptor1.WriteValue">WriteValue()</link> D-Bus method. * @@ -9805,8 +9879,8 @@ gatt_descriptor1_default_init (GattDescriptor1Iface *iface) NULL, g_cclosure_marshal_generic, G_TYPE_BOOLEAN, - 2, - G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING); + 3, + G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_VARIANT); /* GObject properties for D-Bus properties: */ /** @@ -9994,6 +10068,7 @@ gatt_descriptor1_set_value (GattDescriptor1 *object, const GBytes *value) /** * gatt_descriptor1_call_read_value: * @proxy: A #GattDescriptor1Proxy. + * @arg_options: Argument to pass with the method invocation. * @cancellable: (allow-none): A #GCancellable or %NULL. * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. * @user_data: User data to pass to @callback. @@ -10007,13 +10082,15 @@ gatt_descriptor1_set_value (GattDescriptor1 *object, const GBytes *value) void gatt_descriptor1_call_read_value ( GattDescriptor1 *proxy, + GVariant *arg_options, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_dbus_proxy_call (G_DBUS_PROXY (proxy), "ReadValue", - g_variant_new ("()"), + g_variant_new ("(@a{sv})", + arg_options), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, @@ -10065,6 +10142,7 @@ _out: /** * gatt_descriptor1_call_read_value_sync: * @proxy: A #GattDescriptor1Proxy. + * @arg_options: Argument to pass with the method invocation. * @out_value: (out): Return location for return parameter or %NULL to ignore. * @cancellable: (allow-none): A #GCancellable or %NULL. * @error: Return location for error or %NULL. @@ -10079,6 +10157,7 @@ gboolean gatt_descriptor1_call_read_value_sync ( GattDescriptor1 *proxy, GBytes **out_value, + GVariant *arg_options, GCancellable *cancellable, GError **error) { @@ -10090,7 +10169,8 @@ gatt_descriptor1_call_read_value_sync ( _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), "ReadValue", - g_variant_new ("()"), + g_variant_new ("(@a{sv})", + arg_options), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, @@ -10115,6 +10195,7 @@ _out: * gatt_descriptor1_call_write_value: * @proxy: A #GattDescriptor1Proxy. * @arg_value: Argument to pass with the method invocation. + * @arg_options: Argument to pass with the method invocation. * @cancellable: (allow-none): A #GCancellable or %NULL. * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. * @user_data: User data to pass to @callback. @@ -10129,6 +10210,7 @@ void gatt_descriptor1_call_write_value ( GattDescriptor1 *proxy, GBytes *arg_value, + GVariant *arg_options, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -10145,8 +10227,9 @@ gatt_descriptor1_call_write_value ( g_dbus_proxy_call (G_DBUS_PROXY (proxy), "WriteValue", - g_variant_new ("(ay)", - builder), + g_variant_new ("(ay@a{sv})", + builder, + arg_options), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, @@ -10187,6 +10270,7 @@ _out: * gatt_descriptor1_call_write_value_sync: * @proxy: A #GattDescriptor1Proxy. * @arg_value: Argument to pass with the method invocation. + * @arg_options: Argument to pass with the method invocation. * @cancellable: (allow-none): A #GCancellable or %NULL. * @error: Return location for error or %NULL. * @@ -10200,6 +10284,7 @@ gboolean gatt_descriptor1_call_write_value_sync ( GattDescriptor1 *proxy, GBytes *arg_value, + GVariant *arg_options, GCancellable *cancellable, GError **error) { @@ -10216,8 +10301,9 @@ gatt_descriptor1_call_write_value_sync ( _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), "WriteValue", - g_variant_new ("(ay)", - builder), + g_variant_new ("(ay@a{sv})", + builder, + arg_options), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, diff --git a/src/org.bluez.xml b/src/org.bluez.xml index 99c18c0..6d5f883 100644 --- a/src/org.bluez.xml +++ b/src/org.bluez.xml @@ -77,9 +77,11 @@ THE SOFTWARE. <interface name="org.bluez.GattCharacteristic1"> <method name="ReadValue"> <arg name="value" type="ay" direction="out"/> + <arg name="options" type="a{sv}" direction="in"/> </method> <method name="WriteValue"> <arg name="value" type="ay" direction="in"/> + <arg name="options" type="a{sv}" direction="in"/> </method> <method name="StartNotify"/> <method name="StopNotify"/> @@ -93,9 +95,11 @@ THE SOFTWARE. <interface name="org.bluez.GattDescriptor1"> <method name="ReadValue"> <arg name="value" type="ay" direction="out"/> + <arg name="options" type="a{sv}" direction="in"/> </method> <method name="WriteValue"> <arg name="value" type="ay" direction="in"/> + <arg name="options" type="a{sv}" direction="in"/> </method> <property name="UUID" type="s" access="read"/> <property name="Characteristic" type="o" access="read"/> |