125 lines
3.6 KiB
C
125 lines
3.6 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
#ifndef IOT_CLI_UL_BUF_H
|
|
#define IOT_CLI_UL_BUF_H
|
|
|
|
#include "os_timer_api.h"
|
|
#include "os_lock_api.h"
|
|
|
|
#include "iot_pkt_api.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define CLI_UL_BUF_IVALID_SN (0)
|
|
#define CLI_UL_BUF_TIMER (1000)
|
|
#define CLI_UL_BUF_SIZE (40)
|
|
#define CLI_UL_BUF_MAX_SEND_CNT (3)
|
|
#define CLI_UL_BUF_ACK_TIMEOUT (6)
|
|
#define CLI_UL_BUF_MAX_AGE (CLI_UL_BUF_MAX_SEND_CNT * \
|
|
CLI_UL_BUF_ACK_TIMEOUT)
|
|
|
|
#pragma pack(push) /* save the pack status */
|
|
#pragma pack(1) /* 1 byte align */
|
|
|
|
/** cli ul buf entry */
|
|
typedef struct _iot_cli_buf_entry {
|
|
/** if received ack from plc mgr */
|
|
uint8_t acked;
|
|
/** timeout */
|
|
uint8_t timeout;
|
|
/** seq num */
|
|
uint16_t sn;
|
|
/** ++ in buf timer handler */
|
|
uint8_t age;
|
|
/** ++ when retry happens */
|
|
uint8_t send_cnt;
|
|
/** msg id */
|
|
uint32_t msgid;
|
|
/** cli report data */
|
|
iot_pkt_t *data;
|
|
} iot_cli_buf_entry;
|
|
|
|
/** cli ul buf */
|
|
typedef struct _iot_cli_ul_buf {
|
|
/** ul buf */
|
|
iot_cli_buf_entry ul_buf[CLI_UL_BUF_SIZE];
|
|
/** seq num */
|
|
uint16_t sn;
|
|
/** seq num */
|
|
timer_id_t timer;
|
|
/** ul buf timer */
|
|
os_mutex_h ul_buf_mutex;
|
|
/** active flag */
|
|
uint8_t active;
|
|
} iot_cli_ul_buf;
|
|
|
|
/** cli ul ack */
|
|
typedef struct _cli_ul_ack {
|
|
/** seq num */
|
|
uint16_t sn;
|
|
} cli_ul_ack;
|
|
|
|
/**
|
|
* @brief iot_cli_handle_ul_buf_timer_msg() - ul buf timer msg handler
|
|
*/
|
|
void iot_cli_handle_ul_buf_timer_msg();
|
|
|
|
/**
|
|
* @brief cli_ul_ack_handler() - ul ack handler
|
|
* @param buffer: buffer ptr
|
|
* @param bufferlen: buffer len
|
|
* @param src_mac: source mac
|
|
*/
|
|
void cli_ul_ack_handler(uint8_t *buffer, uint32_t bufferlen, uint8_t *src_mac);
|
|
|
|
/**
|
|
* @brief cli_set_ul_buf_active() - set ul buf active flag
|
|
* @param buffer: buffer ptr
|
|
*/
|
|
void cli_set_ul_buf_active(uint8_t active);
|
|
|
|
/**
|
|
* @brief iot_cli_ul_buf_init() - ul buf init interfaccez
|
|
*/
|
|
void iot_cli_ul_buf_init();
|
|
|
|
/**
|
|
* @brief cli_ul_buf_add_entry() - add ul buf entry
|
|
* @param msgid: message id
|
|
* @param data: message data
|
|
* @param len: message data len
|
|
* @return 0 - failure case
|
|
* @return otherwise - for normal case
|
|
*/
|
|
uint16_t cli_ul_buf_add_entry(uint32_t msgid, uint8_t *data, uint32_t len);
|
|
|
|
/**
|
|
* @brief cli_ul_buf_add_pkt_entry() - add ul buf pkt entry
|
|
* @param msgid: message id
|
|
* @param data: message data pkt
|
|
* @return 0 - failure case
|
|
* @return otherwise - for normal case
|
|
*/
|
|
uint16_t cli_ul_buf_add_pkt_entry(uint32_t msgid, iot_pkt_t *data);
|
|
|
|
#pragma pack(pop) /* restore the pack status */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif |