From 5fff92b40bb8501dba76e436f8a0826fedb3a411 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Thu, 6 Jul 2023 14:59:20 +0900 Subject: [PATCH] gatt-database: Add OCF service handling logic 1. invalid handle issue For bluez, the handle increases whenever service is added. Invalid handle error occurs because mobile caches the handle for paired remote device. Modify to use reserved handle for ocf uuid. 2. service persistence issue Mobile is caching without service if gatt connection is lost while service is removed. Modify service changed notification not to be delivered for ocf service. Change-Id: I48d6b649a7adbc3142a2525e02c904271e9b9f9c Signed-off-by: Wootak Jung --- lib/uuid.h | 1 + src/gatt-database.c | 20 ++++++++++++++++++++ src/shared/gatt-db.c | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/lib/uuid.h b/lib/uuid.h index e613c52e..cfe78791 100755 --- a/lib/uuid.h +++ b/lib/uuid.h @@ -106,6 +106,7 @@ extern "C" { /* Samsung Accessary Protocol UUIDs */ #define WEARABLE_OLD_SAP_UUID "a49eb41e-cb06-495c-9f4f-aa80a90cdf4a" #define WEARABLE_NEW_SAP_UUID "a49eb41e-cb06-495c-9f4f-bb80a90cdf00" +#define OCF_UUID "ADE3D529-C784-4F63-A987-EB69F70EE816" #endif /* GATT UUIDs section */ diff --git a/src/gatt-database.c b/src/gatt-database.c index af8c7f34..1f9f4ecb 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -1885,6 +1885,18 @@ static void send_service_changed(struct btd_gatt_database *database, return; } +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + bt_uuid_t svc_uuid; + if (gatt_db_attribute_get_service_uuid(attrib, &svc_uuid)) { + bt_uuid_t ocf_uuid; + bt_string_to_uuid(&ocf_uuid, OCF_UUID); + if (!bt_uuid_cmp(&svc_uuid, &ocf_uuid)) { + DBG("Do not send notification for ocf service"); + return; + } + } +#endif + put_le16(start, value); put_le16(end, value + 2); @@ -3948,6 +3960,14 @@ static bool database_add_service(struct external_service *service) return false; } +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + bt_uuid_to_string(&uuid, str, sizeof(str)); + if (!strcasecmp(str, OCF_UUID)) { + DBG("Use 1st handle for ocf service"); + handle = 1; + } +#endif + service->attrib = gatt_db_insert_service(service->app->database->db, handle, &uuid, primary, service->attr_cnt); diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index 1d31f8b8..b1211190 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -247,7 +247,11 @@ struct gatt_db *gatt_db_new(void) db->crypto = bt_crypto_new(); db->services = queue_new(); db->notify_list = queue_new(); +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + db->next_handle = 0x0010; +#else db->next_handle = 0x0001; +#endif return gatt_db_ref(db); } -- 2.34.1