CAResult_t CAUpdateCharacteristicsToAllGattClients(const uint8_t *charValue, uint32_t charValueLen) { OIC_LOG(DEBUG, TAG, "IN"); VERIFY_NON_NULL(charValue, TAG, "charValue"); oc_mutex_lock(g_leCharacteristicMutex); if (!g_LEConnectedState) { OIC_LOG(ERROR, TAG, "g_LEConnectedState is false"); oc_mutex_unlock(g_leCharacteristicMutex); return CA_STATUS_FAILED; } if (NULL == g_gattReadCharPath) { OIC_LOG(ERROR, TAG, "g_gattReadCharPath is NULL"); oc_mutex_unlock(g_leCharacteristicMutex); return CA_STATUS_FAILED; } int ret = bt_gatt_set_value(g_gattReadCharPath, (char *)charValue, charValueLen); if (0 != ret) { OIC_LOG_V(ERROR, TAG, "bt_gatt_set_value failed with return[%s]", CALEGetErrorMsg(ret)); oc_mutex_unlock(g_leCharacteristicMutex); return CA_STATUS_FAILED; } #ifdef BLE_TIZEN_30 ret = bt_gatt_server_notify_characteristic_changed_value(g_gattReadCharPath, CALEServerNotificationSentCB, NULL, NULL); #else ret = bt_gatt_server_notify(g_gattReadCharPath, false, CALEServerNotificationSentCB, NULL); #endif if (0 != ret) { OIC_LOG_V(ERROR, TAG, #ifdef BLE_TIZEN_30 "bt_gatt_server_notify_characteristic_changed_value failed with return[%s]", #else "bt_gatt_server_notify failed with return[%s]", #endif CALEGetErrorMsg(ret)); oc_mutex_unlock(g_leCharacteristicMutex); return CA_STATUS_FAILED; } oc_mutex_unlock(g_leCharacteristicMutex); OIC_LOG(DEBUG, TAG, "OUT"); return CA_STATUS_OK; }
CAResult_t CAUpdateCharacteristicsToGattClient(const char *address, const uint8_t *charValue, uint32_t charValueLen) { OIC_LOG(DEBUG, TAG, "IN"); VERIFY_NON_NULL(charValue, TAG, "charValue"); VERIFY_NON_NULL(address, TAG, "address"); OIC_LOG_V(DEBUG, TAG, "Client's Unicast address for sending data [%s]", address); ca_mutex_lock(g_leCharacteristicMutex); if (NULL == g_gattReadCharPath) { OIC_LOG(ERROR, TAG, "g_gattReadCharPath is NULL"); ca_mutex_unlock(g_leCharacteristicMutex); return CA_STATUS_FAILED; } int ret = bt_gatt_set_value(g_gattReadCharPath, (char *)charValue, charValueLen); if (0 != ret) { OIC_LOG_V(ERROR, TAG, "bt_gatt_set_value failed with return [%s]", CALEGetErrorMsg(ret)); ca_mutex_unlock(g_leCharacteristicMutex); return CA_STATUS_FAILED; } ret = bt_gatt_server_notify(g_gattReadCharPath, false, CALEServerNotificationSentCB, address, NULL); if (0 != ret) { OIC_LOG_V(ERROR, TAG, "bt_gatt_server_notify failed with return [%s]", CALEGetErrorMsg(ret)); ca_mutex_unlock(g_leCharacteristicMutex); return CA_STATUS_FAILED; } ca_mutex_unlock(g_leCharacteristicMutex); OIC_LOG(DEBUG, TAG, "OUT"); return CA_STATUS_OK; }