[PATCHv2 1/5] android/gatt: Add queue for characteristic descriptors caching

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

 



This is where descriptors will be cached.
---
 android/gatt.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/android/gatt.c b/android/gatt.c
index 8bd7028..0e63df5 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -67,9 +67,16 @@ struct element_id {
 	uint8_t instance;
 };
 
+struct descriptor {
+	struct element_id id;
+	uint16_t handle;
+};
+
 struct characteristic {
 	struct element_id id;
 	struct gatt_char ch;
+
+	struct queue *descriptors;
 };
 
 struct service {
@@ -171,6 +178,17 @@ static void element_id_to_hal_gatt_id(const struct element_id *from,
 	uuid2android(&from->uuid, to->uuid);
 }
 
+static void destroy_characteristic(void *data)
+{
+	struct characteristic *chars = data;
+
+	if (!chars)
+		return;
+
+	queue_destroy(chars->descriptors, free);
+	free(chars);
+}
+
 static void destroy_service(void *data)
 {
 	struct service *srvc = data;
@@ -178,7 +196,7 @@ static void destroy_service(void *data)
 	if (!srvc)
 		return;
 
-	queue_destroy(srvc->chars, free);
+	queue_destroy(srvc->chars, destroy_characteristic);
 	free(srvc);
 }
 
@@ -1268,6 +1286,12 @@ static void cache_all_srvc_chars(GSList *characteristics, struct queue *q)
 			continue;
 		}
 
+		ch->descriptors = queue_new();
+		if (!ch->descriptors) {
+			free(ch);
+			continue;
+		}
+
 		memcpy(&ch->ch, characteristics->data, sizeof(ch->ch));
 
 		bt_string_to_uuid(&uuid, ch->ch.uuid);
-- 
1.9.0

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