gatt-database: Add OCF service handling logic 18/295418/1
authorWootak Jung <wootak.jung@samsung.com>
Thu, 6 Jul 2023 05:59:20 +0000 (14:59 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 7 Jul 2023 01:17:39 +0000 (10:17 +0900)
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 <wootak.jung@samsung.com>
lib/uuid.h
src/gatt-database.c
src/shared/gatt-db.c

index 634314b..c2130a0 100755 (executable)
@@ -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 */
index 6982d2d..9e441ee 100644 (file)
@@ -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);
index 78de38f..75a3ff2 100644 (file)
@@ -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);
 }