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 TIZEN_4
bt_gatt_client_h client = NULL;
ret = bt_gatt_client_create(address, &client);
{
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
return CA_DEFAULT_BLE_MTU_SIZE;
}
#endif // TIZEN_4
+ 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;
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 TIZEN_4
bt_gatt_client_h client = NULL;
ret = bt_gatt_client_create(address, &client);
{
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 // TIZEN_4
+ 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;