Enable GATT server indication for Tizen Speaker 37/215637/1
authorAnupam Roy <anupam.r@samsung.com>
Thu, 19 Sep 2019 01:24:11 +0000 (10:24 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 14 Oct 2019 01:34:59 +0000 (10:34 +0900)
Change-Id: I7511f1ab1d2b010e0caf353ee51ef8eea67e244c
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver_vd.c

index cdbcc17..9aeabeb 100644 (file)
@@ -809,6 +809,9 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
         properties = BT_GATT_PROPERTY_WRITE | BT_GATT_PROPERTY_READ;
     }
 
+    /* Add Indicate property by default */
+    properties |= BT_GATT_PROPERTY_INDICATE;
+
     bt_gatt_h charPath = NULL;
 
     int ret = bt_gatt_characteristic_create(charUUID, permissions, properties, charValue,
@@ -824,8 +827,6 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
     OIC_LOG_V(DEBUG, TAG,
               "bt_gatt_characteristic_create charPath obtained: %s", (char *)charPath);
 
-    if (read)
-    {
 #ifdef BLE_TIZEN_30
         ret = bt_gatt_server_set_characteristic_notification_state_change_cb(charPath,
                                                                              CALENotificationCb,
@@ -844,7 +845,6 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
                       CALEGetErrorMsg(ret));
             return CA_STATUS_FAILED;
         }
-    }
 
     ret =  bt_gatt_service_add_characteristic(svcPath, charPath);
     if (0 != ret)
@@ -857,12 +857,17 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
 
     oc_mutex_lock(g_leCharacteristicMutex);
 
+    /**
+      * NOTE : Currently this sequence of adding characterstic works both on android and tizen.
+      * With previous logic it was faling on android in some devices giving wrong attribute
+      * handle error. This issue needs to be fixed in Android BT layer but we have applied
+      * workaround for now so that it should work with both Android and Tizen devices.
+      */
     if (read)
-    {
         g_gattReadCharPath = charPath;
-    }
     else
-    {
+        g_gattWriteCharPath = charPath;
+
         char desc_value[2] = {0, 0};  // Notification enabled.
         bt_gatt_h descriptor = NULL;
         permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE;
@@ -887,8 +892,6 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
                       CALEGetErrorMsg(ret));
             return CA_STATUS_FAILED;
         }
-        g_gattWriteCharPath = charPath;
-    }
 
     oc_mutex_unlock(g_leCharacteristicMutex);