[PATCH 1/3] dis: Fix attribute handle when initializing from db

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

 



The handle field in struct bt_dis is initialized to the handle of the DIS gatt
service. It should be the value handle of the PNP ID characteristic.

This patch fixes the issue.
---
 profiles/deviceinfo/dis.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/profiles/deviceinfo/dis.c b/profiles/deviceinfo/dis.c
index 91ce26b..6126a77 100644
--- a/profiles/deviceinfo/dis.c
+++ b/profiles/deviceinfo/dis.c
@@ -90,6 +90,25 @@ static void dis_free(struct bt_dis *dis)
 	g_free(dis);
 }
 
+static void foreach_dis_char(struct gatt_db_attribute *attr, void *user_data)
+{
+	struct bt_dis *dis = user_data;
+	bt_uuid_t pnpid_uuid, uuid;
+	uint16_t value_handle;
+
+	/* Ignore if there are multiple instances */
+	if (dis->handle)
+		return;
+
+	if (!gatt_db_attribute_get_char_data(attr, NULL, &value_handle, NULL, NULL, &uuid))
+		return;
+
+	/* Find PNPID characteristic's value handle */
+	bt_string_to_uuid(&pnpid_uuid, PNPID_UUID);
+	if (bt_uuid_cmp(&pnpid_uuid, &uuid) == 0)
+		dis->handle = value_handle;
+}
+
 static void foreach_dis_service(struct gatt_db_attribute *attr, void *user_data)
 {
 	struct bt_dis *dis = user_data;
@@ -98,7 +117,7 @@ static void foreach_dis_service(struct gatt_db_attribute *attr, void *user_data)
 	if (dis->handle)
 		return;
 
-	dis->handle = gatt_db_attribute_get_handle(attr);
+	gatt_db_service_foreach_char(attr, foreach_dis_char, dis);
 }
 
 struct bt_dis *bt_dis_new(struct gatt_db *db)
-- 
2.7.4

--
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