Commit 78f724e8 authored by koushik.girijala's avatar koushik.girijala Committed by Habib Virji

Fix for Tizen EDR issues

Blocked Server from doing device discovery
Handled Data send result handlig for socket disconnect case

Change-Id: I5ce49c218f9a4947875b385196ade80909cf371c
Signed-off-by: default avatarkoushik.girijala <g.koushik@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5203Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarHabib Virji <habib.virji@samsung.com>
parent 8fef6cff
......@@ -293,6 +293,13 @@ CAResult_t CAEDRClientSendMulticastData(const uint8_t *data,
*/
CAResult_t CAEDRGetBondedDeviceList();
#ifdef __TIZEN__
/**
* This function starts device discovery.
*/
CAResult_t CAEDRStartDeviceDiscovery(void);
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
......
......@@ -263,6 +263,15 @@ CAResult_t CAStopEDRListeningServer()
CAResult_t CAStartEDRDiscoveryServer()
{
#ifdef __TIZEN__
// Start device discovery
CAResult_t result = CAEDRStartDeviceDiscovery();
if(CA_STATUS_OK != result)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Failed to Start Device discovery");
}
#endif
return CAStartServer();
}
......
......@@ -77,6 +77,11 @@ static u_arraylist_t *g_multicastDataList = NULL;
*/
static ca_mutex g_multicastDataListMutex = NULL;
/**
* To Store Adapter Mode information
*/
static bool g_isDiscoveryServer = false;
/**
* This function creates mutex.
*/
......@@ -92,11 +97,6 @@ static void CAEDRManagerTerminateMutex(void);
*/
static void CAEDRDataRecvCallback(bt_socket_received_data_s *data, void *userData);
/**
* This function starts device discovery.
*/
static CAResult_t CAEDRStartDeviceDiscovery(void);
/**
* This function stops any ongoing service sevice search.
*/
......@@ -417,7 +417,6 @@ CAResult_t CAEDRStartDeviceDiscovery(void)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
bool isDiscoveryStarted = false;
// Check the device discovery state
......@@ -441,6 +440,8 @@ CAResult_t CAEDRStartDeviceDiscovery(void)
}
}
g_isDiscoveryServer = true;
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
return CA_STATUS_OK;
}
......@@ -526,14 +527,6 @@ CAResult_t CAEDRClientSetCallbacks(void)
bt_socket_set_connection_state_changed_cb(CAEDRSocketConnectionStateCallback, NULL);
bt_socket_set_data_received_cb(CAEDRDataRecvCallback, NULL);
// Start device discovery
CAResult_t result = CAEDRStartDeviceDiscovery();
if(CA_STATUS_OK != result)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Failed to Start Device discovery");
return CA_STATUS_FAILED;
}
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
return CA_STATUS_OK;
}
......@@ -838,35 +831,38 @@ CAResult_t CAEDRClientSendMulticastData(const uint8_t *data,
ca_mutex_unlock(g_edrDeviceListMutex);
// Start the device Discovery.
result = CAEDRStartDeviceDiscovery();
if (CA_STATUS_OK == result)
if(g_isDiscoveryServer)
{
OIC_LOG(INFO, EDR_ADAPTER_TAG, "Add the data to the multicast data list");
EDRData *multicastData = (EDRData *)OICCalloc(1, sizeof(EDRData));
if (NULL == multicastData)
// Start the device Discovery.
result = CAEDRStartDeviceDiscovery();
if (CA_STATUS_OK == result)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Malloc failed");
goto exit;
}
multicastData->data = OICCalloc(1, dataLength);
if (NULL == multicastData->data)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Malloc failed");
goto exit;
}
memcpy(multicastData->data, data, dataLength);
multicastData->dataLength = dataLength;
OIC_LOG(INFO, EDR_ADAPTER_TAG, "Add the data to the multicast data list");
// Add the data to pending multicast data list.
ca_mutex_lock(g_multicastDataListMutex);
if (NULL == g_multicastDataList)
{
g_multicastDataList = u_arraylist_create();
EDRData *multicastData = (EDRData *)OICCalloc(1, sizeof(EDRData));
if (NULL == multicastData)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Malloc failed");
goto exit;
}
multicastData->data = OICCalloc(1, dataLength);
if (NULL == multicastData->data)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Malloc failed");
goto exit;
}
memcpy(multicastData->data, data, dataLength);
multicastData->dataLength = dataLength;
// Add the data to pending multicast data list.
ca_mutex_lock(g_multicastDataListMutex);
if (NULL == g_multicastDataList)
{
g_multicastDataList = u_arraylist_create();
}
u_arraylist_add(g_multicastDataList, (void *)multicastData);
ca_mutex_unlock(g_multicastDataListMutex);
}
u_arraylist_add(g_multicastDataList, (void *)multicastData);
ca_mutex_unlock(g_multicastDataListMutex);
}
exit:
......
......@@ -47,6 +47,11 @@ CAResult_t CAEDRSendData(int serverFD, const void *data, uint32_t dataLength)
OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "sending data failed!, soketid [%d]", serverFD);
return CA_SOCKET_OPERATION_FAILED;
}
else if (dataLen == 0)
{
OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "soketid [%d] may be disconnected?", serverFD);
return CA_SOCKET_OPERATION_FAILED;
}
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
return CA_STATUS_OK;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment