X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fconnectivity%2Fsrc%2Fbt_edr_adapter%2Fcaedradapter.c;h=4481499c871209aa4e865ffff2bd2a0ca484fcdf;hb=8229635f6d207516ccbbdf23b13be164e0fc1787;hp=c5a86d8768db26432f4eb0d9f1e650e9ffd02b1e;hpb=7971eea6746afbea2c37e924e7f3c96780a85fb1;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c b/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c index c5a86d8..4481499 100644 --- a/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c +++ b/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c @@ -32,7 +32,7 @@ #include "caqueueingthread.h" #include "oic_malloc.h" #include "caremotehandler.h" -#include "pdu.h" +#include /** * Logging tag for module name. @@ -93,8 +93,8 @@ void CAAdapterTerminateQueues(); void CAAdapterDataSendHandler(void *context); void CAAdapterDataReceiverHandler(void *context); CAResult_t CAAdapterStopQueue(); -void CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, uint32_t dataLength, - uint32_t *sentLength); +CAResult_t CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, + uint32_t dataLength, uint32_t *sentLength); void CAEDRNotifyNetworkStatus(CANetworkStatus_t status); void CAEDROnNetworkStatusChanged(void *context); CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, @@ -352,15 +352,15 @@ CAResult_t CAStopEDR() // Stop RFComm server if it is running CAEDRServerStop(); - // Stop network monitor - CAEDRStopNetworkMonitor(); - // Stop the adapter CAEDRClientUnsetCallbacks(); // Disconnect all the client connections CAEDRClientDisconnectAll(); + // Stop network monitor + CAEDRStopNetworkMonitor(); + // Stop Send and receive Queue CAAdapterStopQueue(); @@ -634,19 +634,19 @@ CAResult_t CAAdapterStopQueue() return CA_STATUS_OK; } -void CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, uint32_t dataLength, - uint32_t *sentLength) +CAResult_t CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, + uint32_t dataLength, uint32_t *sentLength) { if (false == g_adapterState) { OIC_LOG_V(ERROR, TAG, "Bluetooth adapter is disabled!"); *sentLength = 0; - return; + return CA_ADAPTER_NOT_ENABLED; } // Input validation - VERIFY_NON_NULL_VOID(data, TAG, "Data is null"); - VERIFY_NON_NULL_VOID(sentLength, TAG, "Sent data length holder is null"); + VERIFY_NON_NULL(data, TAG, "Data is null"); + VERIFY_NON_NULL(sentLength, TAG, "Sent data length holder is null"); // Create remote endpoint CAEndpoint_t *remoteEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS, @@ -655,7 +655,7 @@ void CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, uint32_t if (NULL == remoteEndpoint) { OIC_LOG(ERROR, TAG, "Failed to create remote endpoint !"); - return; + return CA_STATUS_FAILED; } // Add message to data queue @@ -665,6 +665,8 @@ void CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, uint32_t // Free remote endpoint CAFreeEndpoint(remoteEndpoint); + + return CA_STATUS_OK; } void CAEDRErrorHandler(const char *remoteAddress, const uint8_t *data, @@ -766,6 +768,18 @@ void CAEDRNotifyNetworkStatus(CANetworkStatus_t status) else { g_adapterState = false; + + CAResult_t res = CAQueueingThreadClearData(g_sendQueueHandle); + if (res != CA_STATUS_OK) + { + OIC_LOG_V(ERROR, TAG, "CAQueueingThreadClearData failed[%d]", res); + } + + res = CAQueueingThreadClearData(g_recvQueueHandle); + if (res != CA_STATUS_OK) + { + OIC_LOG_V(ERROR, TAG, "CAQueueingThreadClearData failed[%d]", res); + } } // Notify to upper layer @@ -776,7 +790,7 @@ void CAEDRNotifyNetworkStatus(CANetworkStatus_t status) if (NULL != event) { if (CA_STATUS_OK != ca_thread_pool_add_task(g_edrThreadPool, - CAEDROnNetworkStatusChanged,event)) + CAEDROnNetworkStatusChanged, event, NULL)) { OIC_LOG(ERROR, TAG, "Failed to create threadpool!"); return;