1 /******************************************************************
3 * Copyright 2014 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 ******************************************************************/
22 * @file caretransmission_singlethread.h
23 * @brief This file contains common function for retransmission messages.
26 #ifndef CA_RETRANSMISSION_SINGLETHREAD_H_
27 #define CA_RETRANSMISSION_SINGLETHREAD_H_
31 #include "uarraylist.h"
34 /** CA_IPV4, CA_LE **/
35 #define DEFAULT_RETRANSMISSION_TYPE (CA_ADAPTER_IP | CA_ADAPTER_GATT_BTLE)
37 /** default retransmission trying count is 4. **/
38 #define DEFAULT_RETRANSMISSION_COUNT 4
40 /** check period is 1 sec. **/
41 #define RETRANSMISSION_CHECK_PERIOD_SEC 1
43 /** retransmission data send method type**/
44 typedef CAResult_t (*CADataSendMethod_t)(const CAEndpoint_t *endpoint, const void *pdu,
47 /** retransmission timeout callback type**/
48 typedef void (*CATimeoutCallback_t)(const CAEndpoint_t *endpoint, const void *pdu,
53 /** retransmission support transport type **/
54 CATransportAdapter_t supportType;
56 /** retransmission trying count **/
59 } CARetransmissionConfig_t;
63 /** send method for retransmission data **/
64 CADataSendMethod_t dataSendMethod;
66 /** callback function for retransmit timeout **/
67 CATimeoutCallback_t timeoutCallback;
69 /** retransmission configure data **/
70 CARetransmissionConfig_t config;
72 /** Variable to inform the thread to stop **/
75 /** array list on which the thread is operating. **/
76 u_arraylist_t *dataList;
86 * @brief Initializes the retransmission context
87 * @param context [IN] context for retransmission
88 * @param retransmissionSendMethod [IN] function to be called for retransmission
89 * @param timeoutCallback [IN] callback for retransmit timeout
90 * @param config [IN] configuration for retransmission.
91 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
93 CAResult_t CARetransmissionInitialize(CARetransmission_t *context,
94 CADataSendMethod_t retransmissionSendMethod,
95 CATimeoutCallback_t timeoutCallback,
96 CARetransmissionConfig_t *config);
99 * @brief Pass the sent pdu data. if retransmission process need, internal thread will wake up
100 * and process the retransmission data.
101 * @param context [IN] context for retransmission
102 * @param endpoint [IN] endpoint information
103 * @param pdu [IN] sent pdu binary data
104 * @param size [IN] sent pdu binary data size
105 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
107 CAResult_t CARetransmissionSentData(CARetransmission_t *context,
108 const CAEndpoint_t *endpoint,
109 const void *pdu, uint32_t size);
112 * @brief Paas the received pdu data. if received pdu is ACK data for the retransmission CON data,
113 * the specified CON data will remove on retransmission list.
114 * @param context [IN] context for retransmission
115 * @param endpoint [IN] endpoint information
116 * @param pdu [IN] received pdu binary data
117 * @param size [IN] received pdu binary data size
118 * @param retransmissionPdu [OUT] pdu data of the request for reset and ack
119 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
121 CAResult_t CARetransmissionReceivedData(CARetransmission_t *context,
122 const CAEndpoint_t *endpoint, const void *pdu,
123 uint32_t size, void **retransmissionPdu);
126 * @brief Stopping the retransmission context
127 * @param context [IN] context for retransmission
128 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
130 CAResult_t CARetransmissionStop(CARetransmission_t *context);
133 * @brief Terminating the retransmission context
134 * @param context [IN] context for retransmission
135 * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
137 CAResult_t CARetransmissionDestroy(CARetransmission_t *context);
140 * @brief Retransmitting the request/response for CONFIRMABLE type
142 void CACheckRetransmissionList();
145 * @brief Invoke Retransmission according to TimedAction Response
146 * @param threadValue [IN] context for retransmission
148 void CARetransmissionBaseRoutine(void *threadValue);
154 #endif /* CA_RETRANSMISSION_SINGLETHREAD_H_ */