[RFC 02/16] gatt: Add services list to gatt_db struct

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

 



Gatt database will store all services in queue services. Each service
contains attributes, number of handles included and flag if it is
active service.
---
 src/shared/gatt-db.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index e56b381..47915c7 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -21,11 +21,24 @@
  *
  */
 
+#include <stdbool.h>
+
 #include "src/shared/util.h"
+#include "src/shared/queue.h"
 #include "src/shared/gatt-db.h"
 
 struct gatt_db {
 	uint16_t next_handle;
+	struct queue *services;
+};
+
+struct gatt_db_attribute {
+};
+
+struct gatt_db_service {
+	bool active;
+	uint16_t num_handles;
+	struct gatt_db_attribute **attributes;
 };
 
 struct gatt_db *gatt_db_new(void)
@@ -36,12 +49,31 @@ struct gatt_db *gatt_db_new(void)
 	if (!db)
 		return NULL;
 
+	db->services = queue_new();
+	if (!db->services) {
+		free(db);
+		return NULL;
+	}
+
 	db->next_handle = 0x0001;
 
 	return db;
 }
 
+static void gatt_db_service_destroy(void *data)
+{
+	struct gatt_db_service *service = data;
+	int i;
+
+	for (i = 0; i < service->num_handles; i++)
+		free(service->attributes[i]);
+
+	free(service->attributes);
+	free(service);
+}
+
 void gatt_db_destroy(struct gatt_db *db)
 {
+	queue_destroy(db->services, gatt_db_service_destroy);
 	free(db);
 }
-- 
1.8.5.3

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