#endif
/**
- * Detaches control from the caller for sending unicast request.
+ * Detaches control from the caller for sending message.
* @param[in] endpoint endpoint information where the data has to be sent.
- * @param[in] request request that needs to be sent.
+ * @param[in] sendMsg message that needs to be sent.
+ * @param[in] dataType type of the message(request/response).
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CADetachRequestMessage(const CAEndpoint_t *endpoint,
- const CARequestInfo_t *request);
-
-/**
- * Detaches control from the caller for sending multicast request.
- * @param[in] object Group endpoint information where the data has to be sent.
- * @param[in] request request that needs to be sent.
- * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
- */
-CAResult_t CADetachRequestToAllMessage(const CAEndpoint_t *object,
- const CARequestInfo_t *request);
-
-/**
- * Detaches control from the caller for sending response.
- * @param[in] endpoint endpoint information where the data has to be sent.
- * @param[in] response response that needs to be sent.
- * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
- */
-CAResult_t CADetachResponseMessage(const CAEndpoint_t *endpoint,
- const CAResponseInfo_t *response);
+CAResult_t CADetachSendMessage(const CAEndpoint_t *endpoint,
+ const void *sendMsg,
+ CADataType_t dataType);
/**
* Detaches control from the caller for sending request.
return CAGetNetworkInformationInternal(info, size);
}
-CAResult_t CASendRequest(const CAEndpoint_t *object,const CARequestInfo_t *requestInfo)
+CAResult_t CASendRequest(const CAEndpoint_t *object, const CARequestInfo_t *requestInfo)
{
- OIC_LOG(DEBUG, TAG, "CASendGetRequest");
+ OIC_LOG(DEBUG, TAG, "CASendRequest");
if(!g_isInitialized)
{
return CA_STATUS_NOT_INITIALIZED;
}
- return CADetachRequestMessage(object, requestInfo);
+ return CADetachSendMessage(object, requestInfo, CA_REQUEST_DATA);
}
CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo)
return CA_STATUS_NOT_INITIALIZED;
}
- return CADetachResponseMessage(object, responseInfo);
+ return CADetachSendMessage(object, responseInfo, CA_RESPONSE_DATA);
}
CAResult_t CASelectNetwork(CATransportAdapter_t interestedNetwork)
return cadata;
}
-CAResult_t CADetachRequestMessage(const CAEndpoint_t *object, const CARequestInfo_t *request)
+CAResult_t CADetachSendMessage(const CAEndpoint_t *endpoint, const void *sendMsg,
+ CADataType_t dataType)
{
- VERIFY_NON_NULL(object, TAG, "object");
- VERIFY_NON_NULL(request, TAG, "request");
+ VERIFY_NON_NULL(endpoint, TAG, "endpoint");
+ VERIFY_NON_NULL(sendMsg, TAG, "sendMsg");
if (false == CAIsSelectedNetworkAvailable())
{
}
#endif /* ARDUINO */
- CAData_t *data = CAPrepareSendData(object, request, CA_REQUEST_DATA);
+ CAData_t *data = CAPrepareSendData(endpoint, sendMsg, dataType);
if(!data)
{
OIC_LOG(ERROR, TAG, "CAPrepareSendData failed");
if(CA_STATUS_OK != result)
{
OIC_LOG(ERROR, TAG, "CAProcessSendData failed");
+ CADestroyData(data, sizeof(CAData_t));
return result;
}
CADestroyData(data, sizeof(CAData_t));
#else
#ifdef WITH_BWT
- if (CA_ADAPTER_GATT_BTLE != object->adapter
+ if (CA_ADAPTER_GATT_BTLE != endpoint->adapter
#ifdef TCP_ADAPTER
- && CA_ADAPTER_TCP != object->adapter
+ && CA_ADAPTER_TCP != endpoint->adapter
#endif
)
{
{
CAQueueingThreadAddData(&g_sendThread, data, sizeof(CAData_t));
}
-#endif
-
- return CA_STATUS_OK;
-}
-
-CAResult_t CADetachResponseMessage(const CAEndpoint_t *object,
- const CAResponseInfo_t *response)
-{
- VERIFY_NON_NULL(object, TAG, "object");
- VERIFY_NON_NULL(response, TAG, "response");
-
- if (false == CAIsSelectedNetworkAvailable())
- {
- return CA_STATUS_FAILED;
- }
-
- CAData_t *data = CAPrepareSendData(object, response, CA_RESPONSE_DATA);
- if(!data)
- {
- OIC_LOG(ERROR, TAG, "CAPrepareSendData failed");
- return CA_MEMORY_ALLOC_FAILED;
- }
-
-#ifdef SINGLE_THREAD
- CAResult_t result = CAProcessSendData(data);
- if(result != CA_STATUS_OK)
- {
- OIC_LOG(ERROR, TAG, "CAProcessSendData failed");
- return result;
- }
-
- CADestroyData(data, sizeof(CAData_t));
-#else
-#ifdef WITH_BWT
- if (CA_ADAPTER_GATT_BTLE != object->adapter
-#ifdef TCP_ADAPTER
- && CA_ADAPTER_TCP != object->adapter
-#endif
- )
- {
- // send block data
- CAResult_t res = CASendBlockWiseData(data);
- if(CA_NOT_SUPPORTED == res)
- {
- OIC_LOG(DEBUG, TAG, "normal msg will be sent");
- CAQueueingThreadAddData(&g_sendThread, data, sizeof(CAData_t));
- return CA_STATUS_OK;
- }
- else
- {
- CADestroyData(data, sizeof(CAData_t));
- }
- return res;
- }
- else
-#endif
- {
- CAQueueingThreadAddData(&g_sendThread, data, sizeof(CAData_t));
- }
-#endif
+#endif /* SINGLE_THREAD */
return CA_STATUS_OK;
}