* limitations under the License.
*
******************************************************************/
+
/**
- * @file caretransmission.h
- * @brief
+ * @file
+ * This file contains common function for retransmission messages.
*/
-#ifndef __CA_RETRANSMISSION_H_
-#define __CA_RETRANSMISSION_H_
+
+#ifndef CA_RETRANSMISSION_H_
+#define CA_RETRANSMISSION_H_
#include <stdint.h>
-#include "uthreadpool.h"
-#include "umutex.h"
+#include "cathreadpool.h"
+#include "camutex.h"
#include "uarraylist.h"
#include "cacommon.h"
-/** CA_ETHERNET, CA_WIFI **/
-#define DEFAULT_RETRANSMISSION_TYPE ((1<<0)|(1<<1))
+/** IP, EDR, LE. **/
+#define DEFAULT_RETRANSMISSION_TYPE (CA_ADAPTER_IP | \
+ CA_ADAPTER_RFCOMM_BTEDR | \
+ CA_ADAPTER_GATT_BTLE)
-/** default retransmission trying count is 4. **/
-#define DEFAULT_RETRANSMISSION_COUNT 4
+/** default ACK time is 2 sec(CoAP). **/
+#define DEFAULT_ACK_TIMEOUT_SEC 2
+
+/** default max retransmission trying count is 4(CoAP). **/
+#define DEFAULT_RETRANSMISSION_COUNT 4
/** check period is 1 sec. **/
-#define RETRANSMISSION_CHECK_PERIOD 1000000
+#define RETRANSMISSION_CHECK_PERIOD_SEC 1
+
+/** retransmission data send method type. **/
+typedef CAResult_t (*CADataSendMethod_t)(const CAEndpoint_t *endpoint,
+ const void *pdu,
+ uint32_t size);
-/** retransmission data send method type**/
-typedef CAResult_t (*CADataSendMethod_t)(const CARemoteEndpoint_t *endpoint, void *data,
- uint32_t length);
+/** retransmission timeout callback type. **/
+typedef void (*CATimeoutCallback_t)(const CAEndpoint_t *endpoint,
+ const void *pdu,
+ uint32_t size);
typedef struct
{
- /** retransmission support connectivity type **/
- CAConnectivityType_t supportType;
- /** retransmission trying count **/
+ /** retransmission support transport type. **/
+ CATransportAdapter_t supportType;
+
+ /** retransmission trying count. **/
uint8_t tryingCount;
} CARetransmissionConfig_t;
typedef struct
{
- /** Thread pool of the thread started **/
- u_thread_pool_t threadPool;
- /** mutex for synchrnoization **/
- u_mutex threadMutex;
- /** conditional mutex for synchrnoization **/
- u_cond threadCond;
- /** send method for retransmission data **/
+ /** Thread pool of the thread started. **/
+ ca_thread_pool_t threadPool;
+
+ /** mutex for synchronization. **/
+ ca_mutex threadMutex;
+
+ /** conditional mutex for synchronization. **/
+ ca_cond threadCond;
+
+ /** send method for retransmission data. **/
CADataSendMethod_t dataSendMethod;
- /** retransmission configure data **/
+
+ /** callback function for retransmit timeout. **/
+ CATimeoutCallback_t timeoutCallback;
+
+ /** retransmission configure data. **/
CARetransmissionConfig_t config;
- /** Variable to inform the thread to stop **/
- CABool_t isStop;
+
+ /** Variable to inform the thread to stop. **/
+ bool isStop;
+
/** array list on which the thread is operating. **/
- u_arraylist_t* dataList;
+ u_arraylist_t *dataList;
+
} CARetransmission_t;
#ifdef __cplusplus
{
#endif
-CAResult_t CARetransmissionInitialize(CARetransmission_t* context, u_thread_pool_t handle,
- CADataSendMethod_t retransmissionSendMethod, CARetransmissionConfig_t* config);
+/**
+ * Initializes the retransmission context.
+ * @param[in] context context for retransmission.
+ * @param[in] handle thread pool handle.
+ * @param[in] retransmissionSendMethod function to be called for retransmission.
+ * @param[in] timeoutCallback callback for retransmit timeout.
+ * @param[in] config configuration for retransmission.
+ * if NULL is coming, it will set default values.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CARetransmissionInitialize(CARetransmission_t *context,
+ ca_thread_pool_t handle,
+ CADataSendMethod_t retransmissionSendMethod,
+ CATimeoutCallback_t timeoutCallback,
+ CARetransmissionConfig_t* config);
+
+/**
+ * Starting the retransmission context.
+ * @param[in] context context for retransmission.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CARetransmissionStart(CARetransmission_t *context);
-CAResult_t CARetransmissionStart(CARetransmission_t* context);
+/**
+ * Pass the sent pdu data. if retransmission process need, internal thread will wake up and
+ * process the retransmission data.
+ * @param[in] context context for retransmission.
+ * @param[in] endpoint endpoint information.
+ * @param[in] pdu sent pdu binary data.
+ * @param[in] size sent pdu binary data size.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CARetransmissionSentData(CARetransmission_t* context,
+ const CAEndpoint_t* endpoint,
+ const void* pdu, uint32_t size);
-CAResult_t CARetransmissionSentData(CARetransmission_t* context, const CARemoteEndpoint_t* endpoint,
- const void* pdu, uint32_t size);
+/**
+ * Pass the received pdu data. if received pdu is ACK data for the retransmission CON data,
+ * the specified CON data will remove on retransmission list.
+ * @param[in] context context for retransmission.
+ * @param[in] endpoint endpoint information.
+ * @param[in] pdu received pdu binary data.
+ * @param[in] size received pdu binary data size.
+ * @param[out] retransmissionPdu pdu data of the request for reset and ack.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CARetransmissionReceivedData(CARetransmission_t *context,
+ const CAEndpoint_t *endpoint, const void *pdu,
+ uint32_t size, void **retransmissionPdu);
-CAResult_t CARetransmissionReceivedData(CARetransmission_t* context,
- const CARemoteEndpoint_t* endpoint, const void* pdu, uint32_t size);
+/**
+ * Stopping the retransmission context.
+ * @param[in] context context for retransmission.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CARetransmissionStop(CARetransmission_t *context);
-CAResult_t CARetransmissionStop(CARetransmission_t* context);
+/**
+ * Terminating the retransmission context.
+ * @param[in] context context for retransmission.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CARetransmissionDestroy(CARetransmission_t *context);
-CAResult_t CARetransmissionDestroy(CARetransmission_t* context);
+/**
+ * Invoke Retransmission according to TimedAction Response.
+ * @param[in] threadValue context for retransmission.
+ */
+void CARetransmissionBaseRoutine(void *threadValue);
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif // __CA_RETRANSMISSION_H_
+#endif /* CA_RETRANSMISSION_H_ */