From 3e024ea2f7b409f5f4d421550d757570eadc2d99 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: Ie77a21a7828251dbfd42a9b8749188c4696a819b 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 634314b..c2130a0 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 6982d2d..9e441ee 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -1926,6 +1926,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); @@ -4031,6 +4043,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 78de38f..75a3ff2 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -259,7 +259,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.7.4