Commit 581024e2 authored by vimala.v's avatar vimala.v Committed by Erich Keane

Fixed following Tizen BLE issues

1) Fixed JIRA-472 Issue.
2) Fixed issues related to Tizen BLE interoperability with Arduino BLE.

Change-Id: Id29bb04f5ba241daa084f9ecaac8cd30d888068d
Signed-off-by: default avatarvimala.v <vimala.v@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/970Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarJohn Light <john.j.light@intel.com>
Reviewed-by: default avatarErich Keane <erich.keane@intel.com>
parent 0734f2d4
......@@ -56,6 +56,12 @@
*/
#define CA_HEADER_LENGTH 2
/**
* @var CA_SUPPORTED_BLE_MTU_SIZE
* @brief The MTU supported for BLE adapter
*/
#define CA_SUPPORTED_BLE_MTU_SIZE 20
#ifdef __TIZEN__
/**
* @var PLATFORM_IDENTIFIER_BIT
......@@ -69,12 +75,6 @@
*/
#define CA_SUPPORTED_EDR_MTU_SIZE 512
/**
* @var CA_SUPPORTED_BLE_MTU_SIZE
* @brief The MTU supported from Tizen platform for LE adapter.
*/
#define CA_SUPPORTED_BLE_MTU_SIZE 200
#elif __ANDROID__
/**
* @var PLATFORM_IDENTIFIER_BIT
......@@ -88,12 +88,6 @@
*/
#define CA_SUPPORTED_EDR_MTU_SIZE 200
/**
* @var CA_SUPPORTED_BLE_MTU_SIZE
* @brief The MTU supported from Android platform for LE adapter.
*/
#define CA_SUPPORTED_BLE_MTU_SIZE 20
#elif __ARDUINO__
/**
* @var PLATFORM_IDENTIFIER_BIT
......@@ -107,12 +101,6 @@
*/
#define CA_SUPPORTED_EDR_MTU_SIZE 200
/**
* @var CA_SUPPORTED_BLE_MTU_SIZE
* @brief The MTU supported from Arduino platform for LE adapter.
*/
#define CA_SUPPORTED_BLE_MTU_SIZE 200
#else //Other Platforms
/**
* @var PLATFORM_IDENTIFIER_BIT
......@@ -126,12 +114,6 @@
*/
#define CA_SUPPORTED_EDR_MTU_SIZE 200
/**
* @var CA_SUPPORTED_BLE_MTU_SIZE
* @brief The MTU supported for BLE adapter
*/
#define CA_SUPPORTED_BLE_MTU_SIZE 200
#endif
/**
......
......@@ -265,40 +265,24 @@ bool CABleGattCharacteristicsDiscoveredCb(int result,
ca_mutex_unlock(g_bleServiceListMutex);
char *uuid = NULL;
bt_gatt_get_service_uuid(characteristic, &uuid);
if (BLE_GATT_READ_CHAR_INDEX == inputIndex) // Server will read on this characteristics.
{
OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG, "new read Characteristics is obtained [%s]",
(char *)characteristic);
VERIFY_NON_NULL_RET(uuid, TZ_BLE_CLIENT_TAG, "uuid is NULL", false);
CAResult_t retVal = CAAppendBLECharInfo(characteristic, BLE_GATT_READ_CHAR, bleServiceInfo);
if (CA_STATUS_OK != retVal)
{
OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG , "CAAppendBLECharInfo failed ");
return false;
}
char *uuid = NULL;
OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG, "New Characteristics[%s] of uuid[%s] is obtained",
(char *)characteristic, uuid);
bt_gatt_get_service_uuid(characteristic, &uuid);
OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG, "new read Characteristics uuid is obtained [%s]",
uuid);
}
else if (BLE_GATT_WRITE_CHAR_INDEX == inputIndex) // Server will write on this characterisctics
if(0 == strcasecmp(uuid, CA_BLE_READ_CHAR_UUID)) // Server will read on this characterisctics
{
OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG, "new write Characteristics is obtained [%s]",
(char *)characteristic);
CAResult_t retVal = CAAppendBLECharInfo(characteristic, BLE_GATT_WRITE_CHAR, bleServiceInfo);
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG , "Read characteristics is obtained");
OICFree(uuid);
CAResult_t retVal = CAAppendBLECharInfo(characteristic, BLE_GATT_READ_CHAR, bleServiceInfo);
if (CA_STATUS_OK != retVal)
{
OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG , "CAAppendBLECharInfo failed! ");
return false;
}
char *uuid = NULL;
bt_gatt_get_service_uuid(characteristic, &uuid);
OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG, "new write Characteristics uuid is obtained [%s]",
uuid);
stGattServiceInfo_t *stTemp = (stGattServiceInfo_t *)OICCalloc(1,
sizeof(stGattServiceInfo_t));
......@@ -343,98 +327,20 @@ bool CABleGattCharacteristicsDiscoveredCb(int result,
}
ca_mutex_unlock(g_bleClientThreadPoolMutex);
}
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT");
return true;
}
void CABtGattBondCreatedCb(int result, bt_device_info_s *device_info, void *user_data)
{
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "IN");
if (BT_ERROR_NONE != result)
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
" create_bond Failed as [%s ]", CABTGetErrorMsg(result));
}
else
else if (0 == strcasecmp(uuid, CA_BLE_WRITE_CHAR_UUID)) // Server will write on this characteristics.
{
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "bond with remote device is created.");
OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG, "Callback: The number of service : %d.",
device_info->service_count);
VERIFY_NON_NULL_VOID(device_info, TZ_BLE_CLIENT_TAG,
"device_info is NULL");
VERIFY_NON_NULL_VOID(device_info->remote_address, TZ_BLE_CLIENT_TAG,
"device_info->remote_address is NULL");
BLEServiceInfo *bleServiceInfo = NULL;
ca_mutex_lock(g_bleServiceListMutex);
CAResult_t retVal = CAGetBLEServiceInfo(g_bLEServiceList, device_info->remote_address,
&bleServiceInfo);
OICFree(uuid);
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG , "Write characteristics is obtained");
CAResult_t retVal = CAAppendBLECharInfo(characteristic, BLE_GATT_WRITE_CHAR, bleServiceInfo);
if (CA_STATUS_OK != retVal)
{
OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG , "CAGetBLEServiceInfo failed! ");
return;
}
VERIFY_NON_NULL_VOID(bleServiceInfo, TZ_BLE_CLIENT_TAG,
"bleServiceInfo is NULL");
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "Its OIC service");
OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG,
"serviceInfo remote address [%s]", bleServiceInfo->bdAddress);
stGattServiceInfo_t *stTemp = (stGattServiceInfo_t *)OICCalloc(1,
sizeof(stGattServiceInfo_t));
VERIFY_NON_NULL_VOID(stTemp, TZ_BLE_CLIENT_TAG, "malloc failed");
bt_gatt_clone_attribute_handle(&(stTemp->serviceInfo), bleServiceInfo->service_clone);
size_t len = strlen(bleServiceInfo->bdAddress);
stTemp->address = (char *)OICMalloc(sizeof(char) * (len + 1));
if (NULL == stTemp->address)
{
OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG , "Malloc failed!");
bt_gatt_destroy_attribute_handle(stTemp->serviceInfo);
OICFree(stTemp);
return;
}
strncpy(stTemp->address, bleServiceInfo->bdAddress, len + 1);
ca_mutex_lock(g_bleClientThreadPoolMutex);
if (NULL == g_bleClientThreadPool)
{
OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG, "g_bleClientThreadPool is NULL");
bt_gatt_destroy_attribute_handle(stTemp->serviceInfo);
OICFree(stTemp->address);
OICFree(stTemp);
ca_mutex_unlock(g_bleClientThreadPoolMutex);
return;
}
CAResult_t ret = ca_thread_pool_add_task(g_bleClientThreadPool,
CADiscoverCharThread, stTemp);
if (CA_STATUS_OK != ret)
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
"ca_thread_pool_add_task failed with ret [%d]", ret);
bt_gatt_destroy_attribute_handle(stTemp->serviceInfo);
OICFree(stTemp->address);
OICFree(stTemp);
ca_mutex_unlock(g_bleClientThreadPoolMutex);
return;
OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG , "CAAppendBLECharInfo failed ");
return false;
}
ca_mutex_unlock(g_bleClientThreadPoolMutex);
OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG,
"Callback: is_bonded - %d.", device_info->is_bonded);
OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG,
"Callback: is_connected - %d.", device_info->is_connected);
}
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT");
return true;
}
bool CABleGattPrimaryServiceCb(bt_gatt_attribute_h service, int index, int count,
......@@ -531,9 +437,10 @@ bool CABleGattPrimaryServiceCb(bt_gatt_attribute_h service, int index, int count
ca_mutex_unlock(g_bleClientThreadPoolMutex);
return false;
}
bt_gatt_clone_attribute_handle(&(stTemp->serviceInfo), service);
result = ca_thread_pool_add_task(g_bleClientThreadPool,
CAGATTCreateBondThread,
CADiscoverCharThread,
stTemp);
if (CA_STATUS_OK != result)
{
......@@ -863,6 +770,14 @@ void CAStopBLEGattClient()
return;
}
CABleGattUnSetCallbacks();
CABleGattUnWatchCharacteristicChanges();
CABleGattStopDeviceDiscovery();
g_isBleGattClientStarted = false;
GMainContext *context_event_loop = NULL;
// Required for waking up the thread which is running in gmain loop
if (NULL != g_eventLoop)
......@@ -892,17 +807,12 @@ void CATerminateBLEGattClient()
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "IN");
ca_mutex_lock(g_bleClientStateMutex);
ca_mutex_lock(g_bleServerBDAddressMutex);
OICFree(g_remoteAddress);
ca_mutex_unlock(g_bleServerBDAddressMutex);
CABleGattUnWatchCharacteristicChanges();
CABleGattUnSetCallbacks();
CABleGattStopDeviceDiscovery();
ca_mutex_lock(g_bleServiceListMutex);
CAFreeBLEServiceList(g_bLEServiceList);
g_bLEServiceList = NULL;
......@@ -910,7 +820,6 @@ void CATerminateBLEGattClient()
CAResetRegisteredServiceCount();
g_isBleGattClientStarted = false;
ca_mutex_unlock(g_bleClientStateMutex);
CATerminateGattClientMutexVariables();
......@@ -1075,16 +984,6 @@ CAResult_t CABleGattSetCallbacks()
return CA_STATUS_FAILED;
}
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "Setting bt_device_set_bond_created_cb");
ret = bt_device_set_bond_created_cb(CABtGattBondCreatedCb, NULL);
if (BT_ERROR_NONE != ret)
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG, " bt_device_set_bond_created_cb Failed as [%s ]",
CABTGetErrorMsg(ret));
return CA_STATUS_FAILED;
}
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT");
return CA_STATUS_OK;
}
......@@ -1095,8 +994,6 @@ void CABleGattUnSetCallbacks()
bt_gatt_unset_characteristic_changed_cb();
bt_device_unset_bond_created_cb();
bt_gatt_unset_connection_state_changed_cb();
bt_adapter_le_unset_device_discovery_state_changed_cb();
......@@ -1151,14 +1048,25 @@ void CABleGattUnWatchCharacteristicChanges()
CAResult_t CABleGattStartDeviceDiscovery()
{
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "IN");
bool isDiscovering = false;
int ret = bt_adapter_le_start_device_discovery();
int ret = bt_adapter_le_is_discovering(&isDiscovering);
if (BT_ERROR_NONE != ret)
{
OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG, "bt_adapter_le_start_device_discovery Failed");
OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG, "bt_adapter_le_is_discovering Failed");
return CA_STATUS_FAILED;
}
if(!isDiscovering)
{
ret = bt_adapter_le_start_device_discovery();
if (BT_ERROR_NONE != ret)
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG, "bt_adapter_le_start_device_discovery Failed Ret: %d, %x", ret, ret);
return CA_STATUS_FAILED;
}
}
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT");
return CA_STATUS_OK;
}
......@@ -1167,7 +1075,24 @@ void CABleGattStopDeviceDiscovery()
{
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "IN");
bt_adapter_le_stop_device_discovery();
bool isDiscovering = false;
int ret = bt_adapter_le_is_discovering(&isDiscovering);
if (BT_ERROR_NONE != ret)
{
OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG, "bt_adapter_le_is_discovering Failed");
return;
}
if(isDiscovering)
{
ret = bt_adapter_le_stop_device_discovery();
if (BT_ERROR_NONE != ret)
{
OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG, "bt_adapter_le_stop_device_discovery Failed");
return;
}
}
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT");
}
......@@ -1284,7 +1209,7 @@ CAResult_t CABleGattDiscoverServices(const char *remoteAddress)
}
else
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG,
"bt_gatt_foreach_primary_services success for address [%s]", remoteAddress);
}
......@@ -1465,59 +1390,6 @@ CAResult_t CASetCharacteristicDescriptorValue(stGattCharDescriptor_t *stGattChar
return CA_STATUS_OK;
}
void CAGATTCreateBondThread(void *stServiceInfo)
{
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "IN");
VERIFY_NON_NULL_VOID(stServiceInfo, TZ_BLE_CLIENT_TAG, "stServiceInfo is NULL");
stGattServiceInfo_t *stTemp = (stGattServiceInfo_t *)stServiceInfo;
VERIFY_NON_NULL_VOID(stTemp, TZ_BLE_CLIENT_TAG, "stTemp is NULL");
OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG, "remote address [%s]",
stTemp->address);
CAResult_t result = CABleGATTCreateBond(stTemp->address);
if (CA_STATUS_OK != result)
{
OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG ,
"CABleGattDiscoverCharacteristics failed!");
OICFree(stTemp->address);
OICFree(stTemp);
return;
}
OICFree(stTemp->address);
OICFree(stTemp);
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT");
}
CAResult_t CABleGATTCreateBond(const char *remoteAddress)
{
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "IN");
VERIFY_NON_NULL_RET(remoteAddress, TZ_BLE_CLIENT_TAG,
"remote address is NULL", CA_STATUS_FAILED);
int ret = bt_device_create_bond(remoteAddress);
if (BT_ERROR_NONE != ret)
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
"bt_device_create_bond Failed with ret value [%d] ", ret);
return CA_STATUS_FAILED;
}
else
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
" bt_device_create_bond query success for address [%s]", remoteAddress);
}
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT");
return CA_STATUS_OK;
}
CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress,
const char *data, const uint32_t dataLen,
CALETransferType_t type, const int32_t position)
......@@ -1567,13 +1439,12 @@ CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress,
"Updating the data of length [%d] to [%s]", dataLen,
bleServiceInfo->bdAddress);
int result = bt_gatt_set_characteristic_value_request(bleServiceInfo->read_char, (unsigned char *)data,
dataLen,
CABleGattCharacteristicWriteCb);
int result = bt_gatt_set_characteristic_value(bleServiceInfo->write_char, (unsigned char *)data,
dataLen);
if (BT_ERROR_NONE != result)
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
"bt_gatt_set_characteristic_value_request Failed with return val [%d]",
"bt_gatt_set_characteristic_value Failed with return val [%d]",
result);
return CA_STATUS_FAILED;
}
......
......@@ -96,16 +96,6 @@ void CABleGattDescriptorDiscoveredCb(int result, unsigned char format, int total
bool CABleGattCharacteristicsDiscoveredCb(int result, int inputIndex, int total,
bt_gatt_attribute_h characteristic, void *userData);
/**
* @brief This is the callback which will be called when bond created with remote device.
*
* @param result [IN] The result of bond creation.
* @param device_info [IN] remote device information
* @param userData [IN] The user data passed from the request function
* @return NONE
*/
void CABtGattBondCreatedCb(int result, bt_device_info_s *device_info, void *user_data);
/**
* @brief This is the callback which will be called when we get the primary services repeatedly.
*
......@@ -158,8 +148,7 @@ void CAPrintDiscoveryInformation(const bt_adapter_le_device_discovery_info_s *di
/**
* @brief This thread will be used to initialize the Gatt Client and start device discovery.
* 1. Set scan parameters
* 2. Setting neccessary callbacks for connection, characteristics changed and discovery
* and bond creation.
* 2. Setting neccessary callbacks for connection, characteristics changed and discovery.
* 3. Start device discovery
*
* @param data [IN] Currently it will be NULL(no parameter)
......@@ -202,7 +191,7 @@ void CAClearNonOICDeviceList();
CAResult_t CABleGattSetScanParameter();
/**
* @brief Used to register required callbacks to BLE platform(connection, discovery, bond and etc).
* @brief Used to register required callbacks to BLE platform(connection, discovery, etc).
*
* @return #CA_STATUS_OK or Appropriate error code
* @retval #CA_STATUS_OK Successful
......@@ -369,27 +358,6 @@ void CASetCharacteristicDescriptorValueThread(void *stServiceInfo);
CAResult_t CASetCharacteristicDescriptorValue
(stGattCharDescriptor_t *stGattCharDescriptorInfo);
/**
* @brief This is the thread which will be used for creating bond with remote device.
*
* @param stServiceInfo [IN] Service Information which contains the remote address and service
* handle, characteristic handle.
* @return NONE
*/
void CAGATTCreateBondThread(void *stServiceInfo);
/**
* @brief Used to make LE bond with remote device(pairng the device) using bt_device_create_bond
* api.
* @param remoteAddress [IN] MAC address of remote device with which we want to bond
*
* @return #CA_STATUS_OK or Appropriate error code
* @retval #CA_STATUS_OK Successful
* @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
* @retval #CA_STATUS_FAILED Operation failed
*/
CAResult_t CABleGATTCreateBond(const char *remoteAddress);
/**
* @brief Used to enqueue the message into sender queue using CAAdapterEnqueueMessage and make
* signal to the thread to process.
......
......@@ -154,7 +154,7 @@ CAResult_t CAGetLEAddress(char **local_address)
{
OIC_LOG(DEBUG, TZ_LE_NWK_MONITOR_TAG, "IN");
VERIFY_NON_NULL_VOID(local_address, TZ_LE_NWK_MONITOR_TAG, "local_address is null")
VERIFY_NON_NULL(local_address, TZ_LE_NWK_MONITOR_TAG, "local_address is null")
char *address = NULL;
......
......@@ -47,18 +47,6 @@
*/
#define CA_BLE_SERVICE_UUID "713D0000-503E-4C75-BA94-3148F18D941E"
/**
* @def CA_BLE_READ_CHAR_UUID
* @brief UUID of read characteristic. This UUID is common across all platform for LE transport.
*/
#define CA_BLE_READ_CHAR_UUID "713D0002-503E-4C75-BA94-3148F18D941E"
/**
* @def CA_BLE_WRITE_CHAR_UUID
* @brief UUID of write characteristic. This UUID is common across all platform for LE transport.
*/
#define CA_BLE_WRITE_CHAR_UUID "713D0003-503E-4C75-BA94-3148F18D941E"
/**
* @def CA_BLE_INITIAL_BUF_SIZE
* @brief Initial buffer size for Gatt Server.
......@@ -329,37 +317,6 @@ CAResult_t CAStopBleGattServer()
return CA_STATUS_OK;
}
GMainContext *context_event_loop = NULL;
// Required for waking up the thread which is running in gmain loop
if ( NULL != g_eventLoop)
{
context_event_loop = g_main_loop_get_context(g_eventLoop);
}
if (context_event_loop)
{
OIC_LOG_V(DEBUG, TZ_BLE_SERVER_TAG, "g_eventLoop context %x", context_event_loop);
g_main_context_wakeup(context_event_loop);
// Kill g main loops and kill threads
g_main_loop_quit(g_eventLoop);
}
else
{
OIC_LOG(ERROR, TZ_BLE_SERVER_TAG, "g_eventLoop context is NULL");
}
ca_mutex_unlock(g_bleServerStateMutex);
OIC_LOG(DEBUG, TZ_BLE_SERVER_TAG, "OUT");
return CA_STATUS_OK;
}
void CATerminateBleGattServer()
{
OIC_LOG(DEBUG, TZ_BLE_SERVER_TAG, "IN");
ca_mutex_lock(g_bleServerStateMutex);
g_isBleGattServerStarted = false;
if (NULL != g_hAdvertiser )
{
......@@ -392,6 +349,38 @@ void CATerminateBleGattServer()
OIC_LOG_V(ERROR, TZ_BLE_SERVER_TAG, "_bt_gatt_deinit_service failed with ret [%d]", res);
}
GMainContext *context_event_loop = NULL;
// Required for waking up the thread which is running in gmain loop
if (NULL != g_eventLoop)
{
context_event_loop = g_main_loop_get_context(g_eventLoop);
if (context_event_loop)
{
OIC_LOG_V(DEBUG, TZ_BLE_SERVER_TAG, "g_eventLoop context %x", context_event_loop);
g_main_context_wakeup(context_event_loop);
// Kill g main loops and kill threads
g_main_loop_quit(g_eventLoop);
}
}
else
{
OIC_LOG(ERROR, TZ_BLE_SERVER_TAG, "g_eventLoop context is NULL");
}
ca_mutex_unlock(g_bleServerStateMutex);
OIC_LOG(DEBUG, TZ_BLE_SERVER_TAG, "OUT");
return CA_STATUS_OK;
}
void CATerminateBleGattServer()
{
OIC_LOG(DEBUG, TZ_BLE_SERVER_TAG, "IN");
ca_mutex_lock(g_bleServerStateMutex);
// free service Path(unique identifier for ble service)
ca_mutex_lock(g_bleServiceMutex);
OICFree(g_gattSvcPath);
......@@ -729,9 +718,9 @@ CAResult_t CAUpdateCharacteristicsToGattClient(const char* address, const char *
ca_mutex_lock(g_bleCharacteristicMutex);
if (NULL == g_gattWriteCharPath)
if (NULL == g_gattReadCharPath)
{
OIC_LOG(ERROR, TZ_BLE_SERVER_TAG, "gGattWriteCharPath is NULL");
OIC_LOG(ERROR, TZ_BLE_SERVER_TAG, "g_gattReadCharPath is NULL");
ca_mutex_unlock(g_bleCharacteristicMutex);
return CA_STATUS_FAILED;
}
......@@ -748,9 +737,9 @@ CAResult_t CAUpdateCharacteristicsToGattClient(const char* address, const char *
strncpy(data, charValue, charValueLen);
OIC_LOG_V(DEBUG, TZ_BLE_SERVER_TAG, "updating characteristics char [%s] data [%s] dataLen [%d]",
(const char *)g_gattWriteCharPath, data, charValueLen);
(const char *)g_gattReadCharPath, data, charValueLen);
int ret = bt_gatt_update_characteristic(g_gattWriteCharPath, data, charValueLen, address);
int ret = bt_gatt_update_characteristic(g_gattReadCharPath, data, charValueLen, address);
if (0 != ret)