From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> This enable bluetoothd to write back the actual value of attribute handles. --- client/gatt.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/client/gatt.c b/client/gatt.c index b6b517bdf..0137aa9e5 100644 --- a/client/gatt.c +++ b/client/gatt.c @@ -62,6 +62,7 @@ struct desc { struct chrc *chrc; char *path; + uint16_t handle; char *uuid; char **flags; int value_len; @@ -72,6 +73,7 @@ struct desc { struct chrc { struct service *service; char *path; + uint16_t handle; char *uuid; char **flags; bool notifying; @@ -88,6 +90,7 @@ struct chrc { struct service { DBusConnection *conn; char *path; + uint16_t handle; char *uuid; bool primary; GList *chrcs; @@ -1259,6 +1262,34 @@ static void service_free(void *data) g_free(service); } +static gboolean service_get_handle(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct service *service = data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &service->handle); + + return TRUE; +} + +static void service_set_handle(const GDBusPropertyTable *property, + DBusMessageIter *value, GDBusPendingPropertySet id, + void *data) +{ + struct service *service = data; + + if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_UINT16) { + g_dbus_pending_property_error(id, "org.bluez.InvalidArguments", + "Invalid arguments in method call"); + return; + } + + dbus_message_iter_get_basic(value, &service->handle); + + g_dbus_pending_property_success(id); +} + static gboolean service_get_uuid(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -1326,6 +1357,7 @@ static gboolean service_exist_includes(const GDBusPropertyTable *property, static const GDBusPropertyTable service_properties[] = { + { "Handle", "q", service_get_handle, service_set_handle }, { "UUID", "s", service_get_uuid }, { "Primary", "b", service_get_primary }, { "Includes", "ao", service_get_includes, @@ -1493,6 +1525,33 @@ void gatt_unregister_include(DBusConnection *conn, GDBusProxy *proxy, return bt_shell_noninteractive_quit(EXIT_SUCCESS); } +static gboolean chrc_get_handle(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct chrc *chrc = data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &chrc->handle); + + return TRUE; +} + +static void chrc_set_handle(const GDBusPropertyTable *property, + DBusMessageIter *value, GDBusPendingPropertySet id, + void *data) +{ + struct chrc *chrc = data; + + if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_UINT16) { + g_dbus_pending_property_error(id, "org.bluez.InvalidArguments", + "Invalid arguments in method call"); + return; + } + + dbus_message_iter_get_basic(value, &chrc->handle); + + g_dbus_pending_property_success(id); +} + static gboolean chrc_get_uuid(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -1616,6 +1675,7 @@ static gboolean chrc_notify_acquired_exists(const GDBusPropertyTable *property, } static const GDBusPropertyTable chrc_properties[] = { + { "Handle", "s", chrc_get_handle, chrc_set_handle, NULL }, { "UUID", "s", chrc_get_uuid, NULL, NULL }, { "Service", "o", chrc_get_service, NULL, NULL }, { "Value", "ay", chrc_get_value, NULL, NULL }, @@ -2342,6 +2402,33 @@ static const GDBusMethodTable desc_methods[] = { { } }; +static gboolean desc_get_handle(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct desc *desc = data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &desc->handle); + + return TRUE; +} + +static void desc_set_handle(const GDBusPropertyTable *property, + DBusMessageIter *value, GDBusPendingPropertySet id, + void *data) +{ + struct desc *desc = data; + + if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_UINT16) { + g_dbus_pending_property_error(id, "org.bluez.InvalidArguments", + "Invalid arguments in method call"); + return; + } + + dbus_message_iter_get_basic(value, &desc->handle); + + g_dbus_pending_property_success(id); +} + static gboolean desc_get_uuid(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -2400,6 +2487,7 @@ static gboolean desc_get_flags(const GDBusPropertyTable *property, } static const GDBusPropertyTable desc_properties[] = { + { "Handle", "q", desc_get_handle, desc_set_handle, NULL }, { "UUID", "s", desc_get_uuid, NULL, NULL }, { "Characteristic", "o", desc_get_chrc, NULL, NULL }, { "Value", "ay", desc_get_value, NULL, NULL }, -- 2.17.2