gatt-database: Add OCF service handling logic 17/295417/1 accepted/tizen/7.0/unified/20230710.155130
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:14:47 +0000 (10:14 +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: I48d6b649a7adbc3142a2525e02c904271e9b9f9c
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
lib/uuid.h
src/gatt-database.c
src/shared/gatt-db.c

index e613c52e08441a2fc77b319637248210d74c1a38..cfe787913c035dab8f36b1d87f78bad6423fe55c 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 af8c7f34bc2f13d54c286bb8938262c4914ae500..1f9f4ecb46327b75cd82614081fbffa3a001f3d8 100644 (file)
@@ -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);
index 1d31f8b809eed9d1727981fbbf63d0f371ef76b9..b1211190cae6a92eb1f0b1c0e1fc3e2d05a9d0e4 100644 (file)
@@ -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);
 }