Setting descriptor in write characterstic in LE server 73/197173/1
authoragrkush <kush.agrawal@samsung.com>
Fri, 4 Jan 2019 13:58:10 +0000 (19:28 +0530)
committerAmit KS <amit.s12@samsung.com>
Thu, 10 Jan 2019 05:47:43 +0000 (11:17 +0530)
This sequence of adding characterstics and descriptor works with
Android and Tizen both.
If we use the previous sequence of adding characterstics and descriptor
then Android writes on wrong attribute handle and fails.

Reverting changes done in LE Server in this patch:
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/d7a3c45d3ab7d4a0ee01a3a4fb639f5ba7f366f8

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/387
(cherry picked from commit 15e13a59345f37b53a6500fe7520d9e83d1da281)

Change-Id: I1e0a3a136a14807fc97d95c05116775421b73f51
Signed-off-by: agrkush <kush.agrawal@samsung.com>
Signed-off-by: Amit KS <amit.s12@samsung.com>
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver_vd.c

index f1a5f6e..901d3d8 100644 (file)
@@ -857,8 +857,16 @@ 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 {
         char desc_value[2] = {0, 0};  // Notification enabled.
         bt_gatt_h descriptor = NULL;
         permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE;
@@ -883,9 +891,6 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
                       CALEGetErrorMsg(ret));
             return CA_STATUS_FAILED;
         }
-        g_gattReadCharPath = charPath;
-    }
-    else{
         g_gattWriteCharPath = charPath;
     }