[PATCH BlueZ 8/8] shared/gatt-client: Watch CCC while registering Service Changed handler.

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

 



If gatt-client discovers the "Service Changed" characteristic but
doesn't discover a Client Characteristic Configuration descriptor for it
then it should just invoke the ready callback instead of attempting to
register a handler and failing. This patch addresses that.
---
 src/shared/gatt-client.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 6016b06..30b271e 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -116,6 +116,7 @@ struct bt_gatt_client {
 	 */
 	uint16_t gatt_svc_handle;
 	uint16_t svc_chngd_val_handle;
+	uint16_t svc_chngd_ccc_handle;
 	unsigned int svc_chngd_ind_id;
 	struct queue *svc_chngd_queue;  /* Queued service changed events */
 	bool in_svc_chngd;
@@ -577,9 +578,14 @@ static void discover_descs_cb(bool success, uint8_t att_ecode,
 						"handle: 0x%04x, uuid: %s",
 						descs[i].handle, uuid_str);
 
-		if (uuid_cmp(descs[i].uuid, GATT_CLIENT_CHARAC_CFG_UUID) == 0)
+		if (uuid_cmp(descs[i].uuid, GATT_CLIENT_CHARAC_CFG_UUID) == 0) {
 			op->cur_chrc->ccc_handle = descs[i].handle;
 
+			if (uuid_cmp(op->cur_chrc->chrc_external.uuid,
+							SVC_CHNGD_UUID) == 0)
+				client->svc_chngd_ccc_handle = descs[i].handle;
+		}
+
 		i++;
 	}
 
@@ -1153,7 +1159,7 @@ static void init_complete(struct discovery_op *op, bool success,
 	op->result_head = NULL;
 	op->result_tail = NULL;
 
-	if (!client->svc_chngd_val_handle) {
+	if (!client->svc_chngd_val_handle || !client->svc_chngd_ccc_handle) {
 		client->ready = true;
 		goto done;
 	}
-- 
2.1.0.rc2.206.gedb03e5

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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