X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fconnectivity%2Fsrc%2Fbt_le_adapter%2Ftizen%2Fcaleserver_vd.c;h=f06d8c6ca448ebfae54b6e545024820f0281caa1;hb=1af7e1dd37cb06e4066a2307f4794c264c74bade;hp=bcd5d0d9e7405051909ae6b2a493104bf7e7aa4d;hpb=cec5405f3da265e8232cb5c8c46b1ec78222139a;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver_vd.c b/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver_vd.c index bcd5d0d..f06d8c6 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver_vd.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver_vd.c @@ -1046,6 +1046,16 @@ uint16_t CALEServerGetMtuSize(const char* address) unsigned int mtu = CA_DEFAULT_BLE_MTU_SIZE; int ret = 0; + unsigned int cached_mtu; + + oc_mutex_lock(g_LEClientListMutex); + cached_mtu = CAClientInfoGetMTUSize(g_LEClientList, address); + if (cached_mtu > 0 && cached_mtu > CA_BLE_MTU_HEADER_SIZE) + { + OIC_LOG_V(INFO, TAG, "Cached MTU Size is %d",cached_mtu); + oc_mutex_unlock(g_LEClientListMutex); + return cached_mtu -CA_BLE_MTU_HEADER_SIZE; + } #ifdef BLE_TIZEN_55 ret = bt_gatt_server_get_device_mtu(address, &mtu); @@ -1063,6 +1073,7 @@ uint16_t CALEServerGetMtuSize(const char* address) { OIC_LOG_V(ERROR, TAG, "bt_gatt_client_create failed with return [%s]", CALEGetErrorMsg(ret)); + oc_mutex_unlock(g_LEClientListMutex); return CA_DEFAULT_BLE_MTU_SIZE; } @@ -1071,6 +1082,7 @@ uint16_t CALEServerGetMtuSize(const char* address) { OIC_LOG_V(ERROR, TAG, "bt_gatt_client_get_att_mtu failed with return [%s]", CALEGetErrorMsg(ret)); + oc_mutex_unlock(g_LEClientListMutex); return CA_DEFAULT_BLE_MTU_SIZE; } @@ -1079,6 +1091,7 @@ uint16_t CALEServerGetMtuSize(const char* address) { OIC_LOG_V(ERROR, TAG, "bt_gatt_client_destroy failed with return [%s]", CALEGetErrorMsg(ret)); + oc_mutex_unlock(g_LEClientListMutex); return CA_DEFAULT_BLE_MTU_SIZE; } #else @@ -1092,6 +1105,15 @@ uint16_t CALEServerGetMtuSize(const char* address) #endif // BLE_TIZEN_40 #endif // BLE_TIZEN_55 + ret = CAClientInfoUpdateMTUSize(g_LEClientList, address,mtu); + if (CA_STATUS_OK != ret) + { + OIC_LOG(ERROR, TAG, "CAClientInfoUpdateMTUSize Update failed"); + oc_mutex_unlock(g_LEClientListMutex); + return CA_DEFAULT_BLE_MTU_SIZE; + } + + oc_mutex_unlock(g_LEClientListMutex); OIC_LOG_V(INFO, TAG, "mtu size(including header) from bt_device_get_att_mtu is %d", mtu); OIC_LOG(DEBUG, TAG, "OUT"); return mtu - CA_BLE_MTU_HEADER_SIZE;