+CAResult_t CAUpdateCharacteristicsToGattServerImpl(LEServerInfo *serverInfo,
+ const uint8_t *data, const uint32_t dataLen)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+
+ VERIFY_NON_NULL(serverInfo, TAG, "Server Info is NULL");
+
+ CALEGattStopDeviceScanning();
+
+ OIC_LOG_V(DEBUG, TAG, "Updating the data of length [%d] to [%s] ", dataLen,
+ serverInfo->remoteAddress);
+
+ int result = bt_gatt_set_value(serverInfo->writeChar, (char *)data, dataLen);
+
+ if (BT_ERROR_NONE != result)
+ {
+ OIC_LOG_V(ERROR, TAG,
+ "bt_gatt_set_value Failed with return val [%s]",
+ CALEGetErrorMsg(result));
+ goto exit;
+ }
+
+ result = bt_gatt_client_write_value(serverInfo->writeChar, CALEGattCharacteristicWriteCb,
+ NULL);
+ if (BT_ERROR_NONE != result)
+ {
+ OIC_LOG_V(ERROR, TAG,
+ "bt_gatt_client_write_value Failed with return val [%s]",
+ CALEGetErrorMsg(result));
+ goto exit;
+ }
+
+ // wait for callback for write Characteristic with success to sent data
+ OIC_LOG_V(DEBUG, TAG, "callback flag is %d", g_isSignalSetFlag);
+ oc_mutex_lock(g_threadWriteCharacteristicMutex);
+ if (!g_isSignalSetFlag)
+ {
+ OIC_LOG(DEBUG, TAG, "wait for callback to notify writeCharacteristic is success");
+ if (OC_WAIT_SUCCESS != oc_cond_wait_for(g_threadWriteCharacteristicCond,
+ g_threadWriteCharacteristicMutex,
+ WAIT_TIME_WRITE_CHARACTERISTIC))
+ {
+ g_isSignalSetFlag = false;
+ oc_mutex_unlock(g_threadWriteCharacteristicMutex);
+ OIC_LOG(ERROR, TAG, "there is no response. write has failed");
+ goto exit;
+ }
+ }
+ // reset flag set by writeCharacteristic Callback
+ g_isSignalSetFlag = false;
+ oc_mutex_unlock(g_threadWriteCharacteristicMutex);
+
+ oc_mutex_lock(g_scanMutex);
+ if (g_isMulticastInProgress || g_isUnicastScanInProgress)
+ {
+ if (CA_STATUS_OK != CALEGattStartDeviceScanning())
+ {
+ OIC_LOG(ERROR, TAG, "Could not start device scanning");
+ }
+ }
+ oc_mutex_unlock(g_scanMutex);
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return CA_STATUS_OK;
+
+exit:
+ oc_mutex_lock(g_scanMutex);
+ if (g_isMulticastInProgress || g_isUnicastScanInProgress)
+ {
+ if (CA_STATUS_OK != CALEGattStartDeviceScanning())
+ {
+ OIC_LOG(ERROR, TAG, "Could not start device scanning");
+ }
+ }
+ oc_mutex_unlock(g_scanMutex);
+
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return CA_STATUS_FAILED;
+}
+
+void CADiscoverLEServicesThread(void *remoteAddress)