1 /* *****************************************************************
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
23 * This file contains common function for connection manager
26 #ifndef CA_CONNECTIONMANAGER_H_
27 #define CA_CONNECTIONMANAGER_H_
31 #include <coap/coap.h>
32 #include "cathreadpool.h"
35 #include "uarraylist.h"
37 #include "caprotocolmessage.h"
38 #include "camessagehandler.h"
39 #include "cautilinterface.h"
47 * Callback to send replaced data.
48 * @param[in] data send data.
50 typedef void (*CASendThreadFunc)(CAData_t *data);
53 * Callback to notify received data from the remote endpoint.
54 * @param[in] data received data.
56 typedef void (*CAReceiveThreadFunc)(CAData_t *data);
59 * Context of connection manager
63 /** send method for block data. **/
64 CASendThreadFunc sendThreadFunc;
66 /** callback function for received message. **/
67 CAReceiveThreadFunc receivedThreadFunc;
69 /** array list on which the thread is operating. **/
70 u_arraylist_t *dataList;
72 /** data list mutex for synchronization. **/
73 oc_mutex dataListMutex;
75 /** sender mutex for synchronization. **/
76 oc_mutex dataSenderMutex;
77 } CAConnectionManagerContext_t;
80 * Initializes the connection manager context.
81 * @param[in] CASendThreadFunc function point to add data in send queue thread.
82 * @param[in] CAReceiveThreadFunc function point to add data in receive queue thread.
83 * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
85 CAResult_t CAInitializeConnectionManager(CASendThreadFunc blockSendMethod,
86 CAReceiveThreadFunc receivedDataCallback);
89 * Terminate the connection manager context.
91 void CATerminateConnectionManager();
95 * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
97 CAResult_t CAInitConnectionManagerMutexVariables();
102 void CATerminateConnectionManagerMutexVariables();
105 * Get request/response message to send.
107 CAData_t* CAGetConnectionManagerMessageData(CAData_t *data);
110 * Start connection manager.
112 void CAStartConnectionManagerService(CMConfigureInfo_t info);
118 #endif // CA_CONNECTIONMANAGER_H_