diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2019-01-28 17:19:13 +0200 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2019-01-31 14:10:49 +0200 |
commit | 3882e127e07cc575bede12895a0a6c663e325980 (patch) | |
tree | 601ca22cb6bd9c8d68095cccc722e94b3a334d7a /src/gatt-database.c | |
parent | 98f13d47c8bacaad249fad5cbfd2a36a3c180255 (diff) | |
download | bluez-3882e127e07cc575bede12895a0a6c663e325980.tar.gz |
gatt: Write back the handle to Handle property
If the application has set an attribute with Handle set to 0 inform the
allocated handle by writting the Handle property.
Diffstat (limited to 'src/gatt-database.c')
-rw-r--r-- | src/gatt-database.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/gatt-database.c b/src/gatt-database.c index 025f777eb..b159786ea 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -2617,6 +2617,18 @@ fail: gatt_db_attribute_write_result(attrib, id, BT_ATT_ERROR_UNLIKELY); } +static void write_handle(struct GDBusProxy *proxy, uint16_t handle) +{ + DBusMessageIter iter; + + /* Check if the attribute has the Handle property */ + if (!g_dbus_proxy_get_property(proxy, "Handle", &iter)) + return; + + g_dbus_proxy_set_property_basic(proxy, "Handle", DBUS_TYPE_UINT16, + &handle, NULL, NULL, NULL); +} + static bool database_add_desc(struct external_service *service, struct external_desc *desc) { @@ -2645,6 +2657,11 @@ static bool database_add_desc(struct external_service *service, desc->handled = true; + if (!handle) { + handle = gatt_db_attribute_get_handle(desc->attrib); + write_handle(desc->proxy, handle); + } + return true; } @@ -2810,6 +2827,11 @@ static bool database_add_chrc(struct external_service *service, if (!database_add_cep(service, chrc)) return false; + if (!handle) { + handle = gatt_db_attribute_get_handle(chrc->attrib); + write_handle(chrc->proxy, handle); + } + /* Handle the descriptors that belong to this characteristic. */ for (entry = queue_get_entries(service->descs); entry; entry = entry->next) { @@ -2868,6 +2890,11 @@ static bool database_add_service(struct external_service *service) if (!service->attrib) return false; + if (!handle) { + handle = gatt_db_attribute_get_handle(service->attrib); + write_handle(service->proxy, handle); + } + database_add_includes(service); entry = queue_get_entries(service->chrcs); |