Update snapshot(2018-02-07)
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / camessagehandler.h
index 7dd323d..10203b9 100644 (file)
@@ -19,7 +19,7 @@
  ******************************************************************/
 
 /**
- * @file camessagehandler.h
+ * @file
  * This file contains message functionality.
  */
 
@@ -27,7 +27,7 @@
 #define CA_MESSAGE_HANDLER_H_
 
 #include "cacommon.h"
-#include "coap.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;} }
@@ -38,13 +38,6 @@ typedef enum
     SEND_TYPE_UNICAST
 } CASendDataType_t;
 
-typedef enum
-{
-    CA_REQUEST_DATA = 1,
-    CA_RESPONSE_DATA = 2,
-    CA_ERROR_DATA = 3,
-} CADataType_t;
-
 typedef struct
 {
     CASendDataType_t type;
@@ -52,9 +45,8 @@ typedef struct
     CARequestInfo_t *requestInfo;
     CAResponseInfo_t *responseInfo;
     CAErrorInfo_t *errorInfo;
-    CAHeaderOption_t *options;
+    CAConnectEvent_t eventInfo;
     CADataType_t dataType;
-    uint8_t numOptions;
 } CAData_t;
 
 #ifdef __cplusplus
@@ -63,87 +55,76 @@ extern "C"
 #endif
 
 /**
- * Detaches control from the caller for sending unicast request
- * @param[IN] endpoint    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 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)
+ * 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 CADetachRequestToAllMessage(const CAEndpoint_t *object,
-                                       const CARequestInfo_t *request);
+CAResult_t CADetachSendMessage(const CAEndpoint_t *endpoint,
+                               const void *sendMsg,
+                               CADataType_t dataType);
 
 /**
- * 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)
+ * 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 CADetachResponseMessage(const CAEndpoint_t *endpoint,
-                                   const CAResponseInfo_t *response);
+CAResult_t CADetachSendNetworkReqMessage(const CAEndpoint_t *endpoint,
+                                         CAConnectEvent_t event,
+                                         CADataType_t dataType);
 
 /**
- * Detaches control from the caller for sending request
- * @param[IN] resourceUri    resource uri that needs to  be sent in the request
- * @param[IN] token          token information of the request
- * @param[IN] tokenLength    length of the token
- * @param[IN] options        header options that need to be append in the request
- * @param[IN] numOptions     number of options be appended
- * @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,
-                                      uint8_t tokenLength, const CAHeaderOption_t *options,
-                                      uint8_t numOptions);
-
-/**
- * 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
+ * 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.
  */
 void CASetInterfaceCallbacks(CARequestCallback ReqHandler, CAResponseCallback RespHandler,
                              CAErrorCallback ErrorHandler);
 
 /**
  * Initialize the message handler by starting thread pool and initializing the
- * send and receive queue
- * @return  CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
+ * 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 CAInitializeMessageHandler(CATransportAdapter_t transportType);
+
+/**
+ * Clears the message handler queue data.
+ * @param[in]   transportType  transport type to initialize.
  */
-CAResult_t CAInitializeMessageHandler();
+void CAClearMessageHandler(CATransportAdapter_t transportType);
 
 /**
- * Terminate the message handler by stopping  the thread pool and destroying the queues
+ * Terminate the message handler by stopping  the thread pool and destroying the queues.
  */
 void CATerminateMessageHandler();
 
 /**
- * Handler for receiving request and response callback in single thread model
+ * Handler for receiving request and response callback in single thread model.
  */
 void CAHandleRequestResponseCallbacks();
 
 /**
- * To log the PDU data
- * @param[IN] pdu    pdu data
+ * Setting the Callback funtion for network state change callback.
+ * @param[in] nwMonitorHandler    callback for network state change.
  */
-void CALogPDUInfo(coap_pdu_t *pdu);
+void CASetNetworkMonitorCallback(CANetworkMonitorCallback nwMonitorHandler);
 
 #ifdef WITH_BWT
 /**
- * Add the data to the send queue thread
- * @param[IN] data    send data
+ * 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
+ * Add the data to the receive queue thread to notify received data.
+ * @param[in] data    received data.
  */
 void CAAddDataToReceiveThread(CAData_t *data);
 #endif