Changing logic of fetching MTU size in server size. 44/195844/1 accepted/tizen/5.0/unified/20181219.063412 submit/tizen_5.0/20181219.005848
authoragrkush <kush.agrawal@samsung.com>
Sun, 16 Dec 2018 15:18:06 +0000 (20:48 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 19 Dec 2018 00:55:16 +0000 (09:55 +0900)
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/368
(cherry picked from commit b4f4c74d8b114706acb1cbcc3a71fcceeb23399a)

Change-Id: I39f7a066c4608cff93730771eef756bcd8695d21
Signed-off-by: agrkush <kush.agrawal@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver.c

index 9c74caf..019984d 100644 (file)
@@ -949,8 +949,35 @@ uint16_t CALEServerGetMtuSize(const char* address)
     OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL_RET(address, TAG, "address is null",
                         CA_SUPPORTED_BLE_MTU_SIZE - CA_BLE_MTU_HEADER_SIZE);
-    //@Todo
-    OIC_LOG(INFO, TAG,
-            "bt_device_get_att_mtu is not supported");
-    return CA_SUPPORTED_BLE_MTU_SIZE - CA_BLE_MTU_HEADER_SIZE;
+
+    unsigned int mtu = CA_DEFAULT_BLE_MTU_SIZE;
+    int ret = 0;
+
+    bt_gatt_client_h client = NULL;
+    ret = bt_gatt_client_create(address, &client);
+    if (0 != ret)
+    {
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_client_create failed with return [%s]", CALEGetErrorMsg(ret));
+        return CA_DEFAULT_BLE_MTU_SIZE;
+    }
+
+    ret = bt_gatt_client_get_att_mtu(client, &mtu);
+    if (0 != ret)
+    {
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_client_get_att_mtu failed with return [%s]", CALEGetErrorMsg(ret));
+        return CA_DEFAULT_BLE_MTU_SIZE;
+    }
+
+    ret = bt_gatt_client_destroy(client);
+    if (0 != ret)
+    {
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_client_destroy failed with return [%s]", CALEGetErrorMsg(ret));
+        return CA_DEFAULT_BLE_MTU_SIZE;
+    }
+
+    OIC_LOG_V(INFO, TAG, "mtu size(including header) from bt_device_get_att_mtu is %d", mtu);
+    return mtu - CA_BLE_MTU_HEADER_SIZE;
 }