-/******************************************************************
+/* *****************************************************************
*
* Copyright 2014 Samsung Electronics All Rights Reserved.
*
* limitations under the License.
*
******************************************************************/
+
/**
- * @file camessagehandler.h
- * @brief This file contains message functionality.
+ * @file
+ * This file contains message functionality.
*/
-#ifndef __CA_MESSAGE_HANDLER_H_
-#define __CA_MESSAGE_HANDLER_H_
+#ifndef CA_MESSAGE_HANDLER_H_
+#define CA_MESSAGE_HANDLER_H_
-#include <stdint.h>
#include "cacommon.h"
+#include <coap/coap.h>
+
+#define CA_MEMORY_ALLOC_CHECK(arg) { if (NULL == arg) {OIC_LOG(ERROR, TAG, "Out of memory"); \
+goto memory_error_exit;} }
+
+typedef enum
+{
+ SEND_TYPE_MULTICAST = 0,
+ SEND_TYPE_UNICAST
+} CASendDataType_t;
+
+typedef struct
+{
+ CASendDataType_t type;
+ CAEndpoint_t *remoteEndpoint;
+ CARequestInfo_t *requestInfo;
+ CAResponseInfo_t *responseInfo;
+ CAErrorInfo_t *errorInfo;
+ CAConnectEvent_t eventInfo;
+ CADataType_t dataType;
+} CAData_t;
#ifdef __cplusplus
extern "C"
#endif
/**
- * @brief Detaches control from the caller for sending unicast request
- * @param endpoint [IN] endpoint information where the data has to be sent
- * @param request [IN] request that needs to be sent
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Detaches control from the caller for sending message.
+ * @param[in] endpoint endpoint information where the data has 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 CARemoteEndpoint_t *endpoint,
- const CARequestInfo_t *request);
+CAResult_t CADetachSendMessage(const CAEndpoint_t *endpoint,
+ const void *sendMsg,
+ CADataType_t dataType);
/**
- * @brief Detaches control from the caller for sending multicast request
- * @param endpoint [IN] endpoint information where the data has to be sent
- * @param request [IN] request that needs to be sent
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Detaches control from the caller for sending message to adapter.
+ * @param[in] endpoint endpoint information where the data has to be sent.
+ * @param[in] event command to request disconect or connect.
+ * @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 CADetachRequestToAllMessage(const CAGroupEndpoint_t *object,
- const CARequestInfo_t *request);
+CAResult_t CADetachSendNetworkReqMessage(const CAEndpoint_t *endpoint,
+ CAConnectEvent_t event,
+ CADataType_t dataType);
/**
- * @brief Detaches control from the caller for sending response
- * @param endpoint [IN] endpoint information where the data has to be sent
- * @param response [IN] request that needs to be sent
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Setting the request and response callbacks for network packets.
+ * @param[in] ReqHandler callback for receiving the requests.
+ * @param[in] RespHandler callback for receiving the response.
+ * @param[in] ErrorHandler callback for receiving error response.
*/
-CAResult_t CADetachResponseMessage(const CARemoteEndpoint_t *endpoint,
- const CAResponseInfo_t *response);
+void CASetInterfaceCallbacks(CARequestCallback ReqHandler, CAResponseCallback RespHandler,
+ CAErrorCallback ErrorHandler);
/**
- * @brief Detaches control from the caller for sending request
- * @param resourceUri [IN] resource uri that needs to be sent in the request
- * @param token [IN] token information of the request
- * @param options [IN] header options that need to be append in the request
- * @param numOptions [IN] number of options be appended
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Initialize the message handler by starting thread pool and initializing the
+ * send and receive queue.
+ * @param[in] transportType transport type to initialize.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CADetachMessageResourceUri(const CAURI_t resourceUri, const CAToken_t token,
- const CAHeaderOption_t *options, const uint8_t numOptions);
+CAResult_t CAInitializeMessageHandler(CATransportAdapter_t transportType);
/**
- * @brief Setting the request and response callbacks for network packets
- * @param ReqHandler [IN] callback for receiving the requests
- * @param RespHandler [IN] callback for receiving the response
- * @return void
+ * Clears the message handler queue data.
+ * @param[in] transportType transport type to initialize.
*/
-void CASetRequestResponseCallbacks(CARequestCallback ReqHandler,
- CAResponseCallback RespHandler);
+void CAClearMessageHandler(CATransportAdapter_t transportType);
/**
- * @brief Initialize the message handler by starting thread pool and initializing the send and reive queue
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Terminate the message handler by stopping the thread pool and destroying the queues.
*/
-CAResult_t CAInitializeMessageHandler();
+void CATerminateMessageHandler();
/**
- * @brief Terminate the message handler by stopping the thread pool and destroying the queues
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Handler for receiving request and response callback in single thread model.
*/
-void CATerminateMessageHandler();
+void CAHandleRequestResponseCallbacks();
/**
- * @brief Handler for receiving request and response callback in singled thread model
+ * Setting the Callback funtion for network state change callback.
+ * @param[in] nwMonitorHandler callback for network state change.
*/
-void CAHandleRequestResponseCallbacks();
+void CASetNetworkMonitorCallback(CANetworkMonitorCallback nwMonitorHandler);
+
+#ifdef WITH_BWT
+/**
+ * Add the data to the send queue thread.
+ * @param[in] data send data.
+ */
+void CAAddDataToSendThread(CAData_t *data);
+
+/**
+ * Add the data to the receive queue thread to notify received data.
+ * @param[in] data received data.
+ */
+void CAAddDataToReceiveThread(CAData_t *data);
+#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif //#ifndef __CA_MESSAGE_HANDLER_H_
-
+#endif /* CA_MESSAGE_HANDLER_H_ */