CAResult_t CAUpdateCharacteristicsToAllGattServers(const uint8_t *data, uint32_t dataLen) { OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "IN"); VERIFY_NON_NULL(data, TZ_BLE_CLIENT_TAG, "data is NULL"); if (0 >= dataLen) { OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG, "dataLen is less than or equal zero. Invalid input !"); return CA_STATUS_INVALID_PARAM; } int numOfServersConnected = CAGetRegisteredServiceCount(); for (int32_t pos = 0; pos < numOfServersConnected; pos++) { /*remoteAddress will be NULL. Since we have to send to all destinations. pos will be used for getting remote address. */ CAResult_t ret = CAUpdateCharacteristicsToGattServer(NULL, data, dataLen, LE_MULTICAST, pos); if (CA_STATUS_OK != ret) { OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG, "CAUpdateCharacteristicsToGattServer Failed with return val [%d] ", ret); g_clientErrorCallback(NULL, data, dataLen, ret); continue; } } OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT "); return CA_STATUS_OK; }
uint32_t CASendLEUnicastData(const CARemoteEndpoint_t *endpoint, void *data, uint32_t dataLen) { OCLog(DEBUG, CALEADAPTER_TAG, "IN"); //Input validation VERIFY_NON_NULL(endpoint, NULL, "Remote endpoint is null"); VERIFY_NON_NULL(data, NULL, "Data is null"); CAResult_t result = CA_STATUS_FAILED; #ifdef __TIZEN__ pthread_mutex_lock(&gBleIsServerMutex); if (gIsServer) { result = CAUpdateCharacteristicsInGattServer(data, dataLen); if (CA_STATUS_OK != result) { OCLogv(ERROR, CALEADAPTER_TAG, "[SendLEUnicastData] sending unicast data to [%s] failed\n", endpoint->addressInfo.BT.btMacAddress); pthread_mutex_unlock(&gBleIsServerMutex); return 0; } } else { result = CAUpdateCharacteristicsToGattServer(endpoint->addressInfo.BT.btMacAddress, data, dataLen, UNICAST, 0); if (CA_STATUS_OK != result) { OCLogv(ERROR, CALEADAPTER_TAG, "[SendLEUnicastData] sending unicast data to [%s] failed\n", endpoint->addressInfo.BT.btMacAddress); pthread_mutex_unlock(&gBleIsServerMutex); return 0; } } pthread_mutex_unlock(&gBleIsServerMutex); #else char *tempPath = "temp_path"; updateCharacteristicsInGattServer(tempPath, (char *) data, dataLen); #endif //#ifdef __TIZEN__ OCLog(DEBUG, CALEADAPTER_TAG, "OUT"); return dataLen; }