linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/3] gatt: Make database_add_record detect the UUID
@ 2017-12-04 12:10 Luiz Augusto von Dentz
  2017-12-04 12:10 ` [PATCH BlueZ 2/3] gatt: Use monitor code to decode service name Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2017-12-04 12:10 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

gatt_db_attribute does carry the UUID so this make database_add_record
add it directly instead of taking as parameter.
---
 src/gatt-database.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/gatt-database.c b/src/gatt-database.c
index 3e10c901c..fa94a83f8 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -707,15 +707,30 @@ static sdp_record_t *record_new(uuid_t *uuid, uint16_t start, uint16_t end)
 }
 
 static uint32_t database_add_record(struct btd_gatt_database *database,
-					uint16_t uuid,
 					struct gatt_db_attribute *attr,
 					const char *name)
 {
 	sdp_record_t *record;
 	uint16_t start, end;
 	uuid_t svc, gap_uuid;
+	bt_uuid_t uuid;
+
+	gatt_db_attribute_get_service_uuid(attr, &uuid);
+
+	switch (uuid.type) {
+	case BT_UUID16:
+		sdp_uuid16_create(&svc, uuid.value.u16);
+		break;
+	case BT_UUID32:
+		sdp_uuid32_create(&svc, uuid.value.u32);
+		break;
+	case BT_UUID128:
+		sdp_uuid128_create(&svc, (void *) &uuid.value.u128);
+		break;
+	case BT_UUID_UNSPEC:
+		return 0;
+	}
 
-	sdp_uuid16_create(&svc, uuid);
 	gatt_db_attribute_get_service_handles(attr, &start, &end);
 
 	record = record_new(&svc, start, end);
@@ -747,7 +762,7 @@ static void populate_gap_service(struct btd_gatt_database *database)
 	/* Add the GAP service */
 	bt_uuid16_create(&uuid, UUID_GAP);
 	service = gatt_db_add_service(database->db, &uuid, true, 5);
-	database->gap_handle = database_add_record(database, UUID_GAP, service,
+	database->gap_handle = database_add_record(database, service,
 						"Generic Access Profile");
 
 	/*
@@ -902,8 +917,7 @@ static void populate_gatt_service(struct btd_gatt_database *database)
 	/* Add the GATT service */
 	bt_uuid16_create(&uuid, UUID_GATT);
 	service = gatt_db_add_service(database->db, &uuid, true, 4);
-	database->gatt_handle = database_add_record(database, UUID_GATT,
-						service,
+	database->gatt_handle = database_add_record(database, service,
 						"Generic Attribute Profile");
 
 	bt_uuid16_create(&uuid, GATT_CHARAC_SERVICE_CHANGED);
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-04 17:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-04 12:10 [PATCH BlueZ 1/3] gatt: Make database_add_record detect the UUID Luiz Augusto von Dentz
2017-12-04 12:10 ` [PATCH BlueZ 2/3] gatt: Use monitor code to decode service name Luiz Augusto von Dentz
2017-12-04 12:10 ` [PATCH BlueZ 3/3] gatt: Add all services as records Luiz Augusto von Dentz
2017-12-04 17:48 ` [PATCH BlueZ 1/3] gatt: Make database_add_record detect the UUID Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).