#include "caqueueingthread.h"
#include "oic_malloc.h"
#include "caremotehandler.h"
-#include "pdu.h"
+#include <coap/pdu.h>
/**
* Logging tag for module name.
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,
// 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();
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,
if (NULL == remoteEndpoint)
{
OIC_LOG(ERROR, TAG, "Failed to create remote endpoint !");
- return;
+ return CA_STATUS_FAILED;
}
// Add message to data queue
// Free remote endpoint
CAFreeEndpoint(remoteEndpoint);
+
+ return CA_STATUS_OK;
}
void CAEDRErrorHandler(const char *remoteAddress, const uint8_t *data,
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
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;