From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> If there are no characteristics to discover, or for some reason bt_gatt_discover_descriptors is skiped, or the last attribute is actually a included service the service should be marked as active as there will be no more attributes to be discovered. Fixes: https://github.com/bluez/bluez/issues/438 --- src/shared/gatt-client.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index cf0d2e2b749d..8eb5e0fea621 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -576,12 +576,26 @@ static void discover_incl_cb(bool success, uint8_t att_ecode, gatt_db_attribute_get_handle(attr), handle); goto failed; } + + if (!gatt_db_attribute_get_service_data(attr, NULL, &end, + NULL, NULL)) { + DBG(client, "Unable to get service data at 0x%04x", + handle); + goto failed; + } + + /* Skip if there are no attributes */ + if (handle == end) + gatt_db_service_set_active(attr, true); } next: range = queue_pop_head(op->discov_ranges); - if (!range) + if (!range) { + /* Skip if there are no attributes */ + gatt_db_service_set_active(op->cur_svc, true); goto failed; + } client->discovery_req = bt_gatt_discover_characteristics(client->att, range->start, @@ -696,6 +710,9 @@ static bool discover_descs(struct discovery_op *op, bool *discovering) &ccc_uuid, 0, NULL, NULL, NULL); if (attr) { + if (dest_start == end) + /* Done with the current service */ + gatt_db_service_set_active(attr, true); free(chrc_data); continue; } -- 2.37.3