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);
{
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;
}
{
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;
}
{
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
#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;