From 6e3cc8579b539a9db9fc801df9ba488653018c01 Mon Sep 17 00:00:00 2001 From: agrkush Date: Sun, 16 Dec 2018 20:48:06 +0530 Subject: [PATCH] Changing logic of fetching MTU size in server size. https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/368 (cherry picked from commit b4f4c74d8b114706acb1cbcc3a71fcceeb23399a) Change-Id: I39f7a066c4608cff93730771eef756bcd8695d21 Signed-off-by: agrkush Signed-off-by: DoHyun Pyun --- .../src/bt_le_adapter/tizen/caleserver.c | 35 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver.c b/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver.c index 9c74caf..019984d 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver.c @@ -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; } -- 2.7.4