1250 lines
36 KiB
C
Executable File
1250 lines
36 KiB
C
Executable File
/****************************************************************************
|
|
|
|
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_PLCTXRX_H
|
|
#define IOT_PLCTXRX_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define IOT_PLCTXRX_BROADCAST_MAC_6BYTES {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
|
|
|
|
/* define priorities for message to be handle */
|
|
#define IOT_PLCTXRX_TASK_QUEUE_HP 0
|
|
#define IOT_PLCTXRX_TASK_QUEUE_LP 1
|
|
#define IOT_PLCTXRX_TASK_QUEUE_MAX_PRIO 2
|
|
|
|
#define IOT_PLCTXRX_TASK_LIKE_ID 2
|
|
|
|
#if (IOT_PSRAM_ENABLE)
|
|
#define IOT_PLCTXRX_TASK_POOL_SIZE 254
|
|
#else
|
|
#define IOT_PLCTXRX_TASK_POOL_SIZE 64
|
|
#endif
|
|
|
|
#define IOT_PLCTXRX_TASK_PRIO 7
|
|
/* message type */
|
|
#define IOT_PLCTXRX_MAC_MSG 0
|
|
#define IOT_PLCTXRX_TIMER_MSG 1
|
|
#define IOT_PLCTXRX_XMIT_MSG 2
|
|
#define IOT_PLCTXRX_CMD_MSG 3
|
|
|
|
/* Xmit message ID */
|
|
#define IOT_PLCTXRX_ID_RECV_MSG 0
|
|
#define IOT_PLCTXRX_ID_SEND_MSG 1
|
|
#define IOT_PLCTXRX_ID_ACK_MSG 2
|
|
|
|
/* timer message ID */
|
|
|
|
/* data method timer,eg retry */
|
|
#define IOT_PLCTXRX_TIMER_DATA_PATH 1
|
|
/* for plctxrx period action */
|
|
#define IOT_PLCTXRX_TIMER_TXRX_PATH 2
|
|
/* for plctxrx aggr_timeout action */
|
|
#define IOT_PLCTXRX_TIMER_AGGR_PATH 3
|
|
|
|
/* flag in pkt header, show msdu sources moudle */
|
|
#define IOT_PLCTXRX_MSDU_SRCMODULE_PROTO 0
|
|
#define IOT_PLCTXRX_MSDU_SRCMODULE_AT 1
|
|
#define IOT_PLCTXRX_MSDU_SRCMODULE_DEV_TEST 2
|
|
|
|
/* default unicast send retry interval. unit is ms */
|
|
#define IOT_PLCXRX_RETRY_INTVAL_DEFAULT 500
|
|
|
|
/* request id, see IOT_PLC_CCO_REQ_ID_XXX */
|
|
#define IOT_PLCTXRX_CCO_REQ_ID_GET_TOPO (15)
|
|
|
|
/* aggr timer interval. unit is ms */
|
|
#define IOT_PLCTXRX_AGGR_TIMER_INTVAL (200)
|
|
|
|
/* txrx timer interval, print statistic info. one loop, unit is ms */
|
|
#define IOT_PLCTXRX_TXRX_TIMER_INTVAL (500)
|
|
|
|
/* indicate how long will the conn_less pkt would be cached */
|
|
#define IOT_PLCTXRX_CONN_LESS_PKT_SPAN_CNT (6)
|
|
|
|
/* indicatie how many conn_less pkt infor would be stored */
|
|
#define IOT_PLCTXRX_CONN_LESS_PKT_BUF_CNT (50)
|
|
|
|
/* indicatie the interval count for print stastics infor */
|
|
#define IOT_PLCTXRX_STASTIC_PRINT_INTVL_CNT (80)
|
|
|
|
/* every two seconds show signal led state */
|
|
#define IOT_PLC_SINGAL_LED_SHOW_INTVAL_CNT (4)
|
|
|
|
#if (IOT_PSRAM_ENABLE)
|
|
/* Macro to define msdu pkt pool number*/
|
|
#define TXRX_SEND_BUFF_POOL_NUM 36
|
|
#else
|
|
/* Macro to define msdu pkt pool number*/
|
|
#define TXRX_SEND_BUFF_POOL_NUM 6
|
|
#endif
|
|
|
|
/* Macro to define package size, used by aggregating for proto layer frame*/
|
|
#define TXRX_AGGR_PKT_LEN 500
|
|
|
|
/* vendor info in bc entry */
|
|
#define GREE_TIME_DATA_LENGTH 7
|
|
/* magic id for gree outside */
|
|
#define GREE_PASSWD_LENGTH 6
|
|
/* mac addr len */
|
|
#define MAC_ADDR_3BYTE_LEN 3
|
|
|
|
/* rate adapt mode */
|
|
/* rate adapt based on packet size */
|
|
#define GE_PLC_RATE_ADAPT_FIX_MODE 1
|
|
/* rate adapt based on netwoak communication quality */
|
|
#define GE_PLC_RATE_ADAPT_AUTO_MODE 2
|
|
|
|
/** const, STA DEVs max supported in network */
|
|
#if (PLC_SUPPORT_CCO_ROLE)
|
|
#define STA_DEV_MAX 800
|
|
#else
|
|
#define STA_DEV_MAX 40
|
|
#endif
|
|
|
|
#define QUERY_NODE_INFO_MAX_CNT_ONCE 8
|
|
|
|
/** ge default enable cmd data send to beacon */
|
|
#define ENABLE_GE_DATA_SEND_TO_BEACON 1
|
|
|
|
|
|
#define IOT_GE_FB_SCAN_BITMAP_SIZE 16
|
|
|
|
/* length of mac addr enum */
|
|
enum mac_addr_len_e {
|
|
MAC_ADDR_LEN_2BYTE = 2,
|
|
MAC_ADDR_LEN_3BYTE = 3,
|
|
MAC_ADDR_LEN_4BYTE = 4,
|
|
MAC_ADDR_LEN_6BYTE = 6,
|
|
};
|
|
|
|
/* list of the command id */
|
|
enum plctxrx_command_id_e
|
|
{
|
|
/* mac and device type set/query/resp */
|
|
PLCTXRX_CID_MAC,
|
|
/* system clock, borcast in beacon */
|
|
PLCTXRX_CID_TIME,
|
|
/* run time and boot cnt/reason */
|
|
PLCTXRX_CID_BOOTINFO,
|
|
/* com0 config */
|
|
PLCTXRX_CID_UART,
|
|
/* plc network dev topo */
|
|
PLCTXRX_CID_TOPO,
|
|
#if INCLUDE_AT_COMMAND_MODULE
|
|
/* at send cmd */
|
|
PLCTXRX_CID_SEND,
|
|
#endif
|
|
/* wl tbl op */
|
|
PLCTXRX_CID_WHITELIST,
|
|
/* plc network search */
|
|
PLCTXRX_CID_FIND_NETWORK,
|
|
/* plc network join */
|
|
PLCTXRX_CID_JOIN_NETWORK,
|
|
/* plc network leave */
|
|
PLCTXRX_CID_LEAVE_NETWORK,//10
|
|
/* indication, net status */
|
|
PLCTXRX_CID_CCO_STATE, /* CCO network up or down indication */
|
|
/* beacon verder entry */
|
|
PLCTXRX_CID_VENDOR_INFO,
|
|
/* sw ver query */
|
|
PLCTXRX_CID_SWVER,
|
|
/* systems info qeury */
|
|
PLCTXRX_CID_SYSTEMINFO,
|
|
/* plc net info query */
|
|
PLCTXRX_CID_NET_STS,
|
|
/* disable wl, start netting */
|
|
PLCTXRX_CID_START_GROUP_NET,
|
|
/* enable wl, netted with joined */
|
|
PLCTXRX_CID_END_GROUP_NET,
|
|
/* plc txrx sts query */
|
|
PLCTXRX_CID_TXRX_STS,
|
|
/* network power set */
|
|
PLCTXRX_CID_TX_PWR,
|
|
/* net nid */
|
|
PLCTXRX_CID_NID, //20
|
|
/* indication, comm fail */
|
|
PLCTXRX_CID_COMM_FAULT,
|
|
/* indication, app start to run */
|
|
PLCTXRX_CID_GRAPP_REG_CONF,
|
|
/* remove monitor since leave by itself */
|
|
PLCTXRX_CID_STA_POS_LEAVE,
|
|
/* band id */
|
|
PLCTXRX_CID_BAND_ID,
|
|
/* beacon verder data entry */
|
|
PLCTXRX_CID_VENDOR_DATA,
|
|
/* plc network time base*/
|
|
PLCTXRX_CID_NTB,
|
|
/* frequency band bitmap */
|
|
PLCTXRX_CID_FB_BITMAP,
|
|
/* Fixed rate */
|
|
PLCTXRX_CID_FIXED_RATE,
|
|
/* plc node info */
|
|
PLCTXRX_CID_NODE_INFO,
|
|
/* plc network info */
|
|
PLCTXRX_CID_NW_INFO,
|
|
/* set watchdog */
|
|
PLCTXRX_CID_WDG,
|
|
/* mode config */
|
|
PLCTXRX_CID_MODE_CONF,
|
|
/* reject sta */
|
|
PLCTXRX_CID_REJECT_STA,
|
|
/* ... */
|
|
|
|
PLCTXRX_CID_MAX
|
|
};
|
|
|
|
/* operation code */
|
|
enum plctxrx_command_opcode_e
|
|
{
|
|
/* command for change the configuration of device. */
|
|
PLCTXRX_OP_CONFIG,
|
|
/* response config result error or ok to upper layer */
|
|
PLCTXRX_OP_CFM,
|
|
/* command for query the status /configuration /statistics of device. */
|
|
PLCTXRX_OP_QUERY,
|
|
/* response query message to upper layer */
|
|
PLCTXRX_OP_RESPONSE,
|
|
/* command for simple actions, like PING /REBOOT...
|
|
* no configuration changed or any information exclude result of
|
|
* this command response.
|
|
*/
|
|
PLCTXRX_OP_EXECUTE,
|
|
/* ind message to upper layer */
|
|
PLCTXRX_OP_INDICATION,
|
|
/* Received a remote packet. */
|
|
PLCTXRX_OP_RECEIVE
|
|
};
|
|
|
|
/* return status of the command. */
|
|
enum plctxrx_command_response_e
|
|
{
|
|
PLCTXRX_RESP_OK,
|
|
PLCTXRX_RESP_ERROR,
|
|
PLCTXRX_RESP_BUSY,
|
|
PLCTXRX_RESP_UNKNOWN_CMD
|
|
};
|
|
|
|
/* flag in hdr to mark msdu type. unicast msdu may request receiver reply ack
|
|
but, ack itself is one msdu. pay attention on mac layer sack.
|
|
*/
|
|
typedef enum _msdu_data_type_e{
|
|
PLCTXRX_TYPE_ACK = 1,
|
|
PLCTXRX_TYPE_DATA = 2,
|
|
}msdu_data_type_e;
|
|
|
|
|
|
typedef enum _aggr_aband_reason_e{
|
|
/* vairous aggr fail reason */
|
|
REASON_DEST_MISMATCH = 1,
|
|
REASON_RETRY_CFG_MISMATCH = 2,
|
|
REASON_NO_SPACE = 3,
|
|
REASON_TYPE_MISMATCH = 4,
|
|
REASON_ACK_OPT_MISMATCH = 5,
|
|
REASON_ORG_MAC_MISMATCH = 6,
|
|
REASON_SRC_MAC_MISMATCH = 7,
|
|
/* connect or connless packet */
|
|
REASON_SEND_TYPE_FLAG_MISMATCH = 8,
|
|
}aggr_aband_reason_e;
|
|
|
|
/* query topo information type */
|
|
enum _topo_info_type_e {
|
|
TOPO_INFO_TYPE_V0 = 0,
|
|
TOPO_INFO_TYPE_V1 = 1,
|
|
TOPO_INFO_TYPE_V_MAX = 0xFF
|
|
};
|
|
|
|
/* query node information type */
|
|
enum _node_info_type_e {
|
|
NODE_INFO_TYPE_V1 = 1,
|
|
NODE_INFO_TYPE_V2 = 2,
|
|
NODE_INFO_TYPE_V3 = 3,
|
|
NODE_INFO_TYPE_V4 = 4,
|
|
NODE_INFO_TYPE_V5 = 5,
|
|
NODE_INFO_TYPE_V_MAX = 0xFF,
|
|
};
|
|
|
|
/* data rx info from plctxrx layer to protocol layer - structure need pack */
|
|
typedef struct _plctxrx_rx_data_info_t {
|
|
/* source mac */
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
/* conn less or normal */
|
|
bool_t rx_type;
|
|
/* reserved, use for 4 byte alignment */
|
|
uint8_t resv[3];
|
|
} plctxrx_rx_data_info_t;
|
|
|
|
typedef struct _plctxrx_net_sts_t {
|
|
/* source mac */
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
/* noise factor */
|
|
uint8_t nf;
|
|
/* signal snr */
|
|
int8_t snr;
|
|
/* up link tsf */
|
|
uint8_t ul_tf_sr;
|
|
/* downlink tsf*/
|
|
uint8_t dl_tf_sr;
|
|
} plctxrx_net_sts_t;
|
|
|
|
/* cco query net status info and response to mcu */
|
|
typedef struct _plctxrx_net_sts_data_info {
|
|
uint16_t count;
|
|
plctxrx_net_sts_t net_sts_data[0];
|
|
} plctxrx_net_sts_data_info_t;
|
|
|
|
/* proto layer registed. plctxrx layer used.
|
|
report network event to proto layer. eg connect,
|
|
signal change, proxy change, or disconnect */
|
|
typedef uint8_t(* proto_network_event_cb)(iot_pkt_t *pkt);
|
|
|
|
/* internal function, aggr proto layer frame to best fit link status,
|
|
pb size tmi etc. currently only support for gree. TODO, make it more
|
|
general
|
|
*/
|
|
typedef uint8_t(* proto_aggr_fn)(void *pkt);
|
|
|
|
/* internal plctxrx layer state anaysis. eg, tx/rx packets.
|
|
last active timestamp etc..*/
|
|
typedef uint8_t(* PLCTXRX_STATISTIC)(void *pkt);
|
|
|
|
/* proto register, txrx used. report vendor beacon info */
|
|
typedef uint8_t(* proto_vendr_cb)(iot_pkt_t *pkt);
|
|
|
|
typedef struct _plctxrx_cid
|
|
{
|
|
/* reference to enum plctxrx_command_id_e */
|
|
uint8_t cid;
|
|
/* reference to enum plctxrx_command_opcode_e */
|
|
uint8_t opcode;
|
|
} plctxrx_cid_t;
|
|
|
|
/* the argument for plctxrx command handle. */
|
|
typedef struct _plctxrx_cmd_arg
|
|
{
|
|
plctxrx_cid_t cid; /* plctxrx command id. */
|
|
uint16_t prio; /* priority of this command. */
|
|
uint16_t dlen;
|
|
uint16_t need_ack; /* if need ack */
|
|
uint8_t arg[0]; /* the argument for this command. */
|
|
} plctxrx_cmd_arg_t;
|
|
|
|
typedef struct _plctxrx_resp_idx
|
|
{
|
|
uint16_t current;/* current index of response frame. */
|
|
uint16_t total; /* total response frames count. */
|
|
} plctxrx_resp_idx_t;
|
|
|
|
/* response data from down layer to at command. */
|
|
typedef struct _plctxrx_command_response
|
|
{
|
|
plctxrx_cid_t cid; /* response command ID. */
|
|
plctxrx_resp_idx_t index;/* maybe there are more than one response frames */
|
|
uint16_t resp; /* return from executer, reference to enum
|
|
* at_command_response_e
|
|
*/
|
|
uint16_t dlen;
|
|
uint8_t resv; /* 4 bytes aligned for data[0] */
|
|
uint8_t done; /* response done */
|
|
uint8_t data[0]; /* response data from down layer. */
|
|
} plctxrx_cmd_resp_t;
|
|
|
|
/* the executer handle in plctxrx commands. */
|
|
typedef void(*plctxrx_handle)(plctxrx_cmd_arg_t *arg);
|
|
|
|
/* the table of plctxrx commands. */
|
|
typedef struct _plctxrx_cmd_table
|
|
{
|
|
plctxrx_handle *handle;
|
|
} plctxrx_cmd_table_t;
|
|
|
|
/* device info for sending data - structure need pack */
|
|
typedef struct _plctxrx_dev_info_t {
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
} plctxrx_dev_info_t;
|
|
|
|
typedef enum _txrx_type_e{
|
|
|
|
PLCTXRX_UNICAST = 1,
|
|
PLCTXRX_MULITCAST = 2,
|
|
PLCTXRX_BORADCAST = 3
|
|
} txrx_type_e;
|
|
|
|
typedef enum _cmd_queue_e {
|
|
PLCTXRX_FREEQ = 1,
|
|
PLCTXRX_SAVEQ = 2,
|
|
} cmd_queue_e;
|
|
typedef uint8_t cmd_queue_e_t;
|
|
|
|
typedef struct _plctxrx_command_handle_mac
|
|
{
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
uint8_t dev_type;
|
|
} plctxrx_handle_mac_t;
|
|
|
|
/* to fit gree proto, request 8 bytes to present time */
|
|
typedef struct _time_data
|
|
{
|
|
uint8_t time[GREE_TIME_DATA_LENGTH];
|
|
} time_data_t;
|
|
|
|
typedef struct _plctxrx_cmd_network_info
|
|
{
|
|
uint32_t nid;
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
int8_t snr;
|
|
} plctxrx_cmd_network_info_t;
|
|
|
|
typedef struct _plctxrx_cmd_handle_network
|
|
{
|
|
uint16_t count;
|
|
plctxrx_cmd_network_info_t node[0];
|
|
} plctxrx_cmd_network_t;
|
|
|
|
typedef struct _plctxrx_cmd_join_network
|
|
{
|
|
uint8_t nid;
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
} plctxrx_cmd_join_network_t;
|
|
|
|
typedef struct _plctxrx_cmd_joined_network
|
|
{
|
|
uint8_t role;
|
|
uint8_t nid;
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
uint8_t pco_mac[IOT_MAC_ADDR_LEN];
|
|
} plctxrx_cmd_joined_network_t;
|
|
|
|
typedef struct _plctxrx_cmd_leave_net
|
|
{
|
|
uint16_t cnt;
|
|
uint8_t mac[0][IOT_MAC_ADDR_LEN];
|
|
} plctxrx_cmd_leave_net_t;
|
|
|
|
typedef struct _plctxrx_cmd_reject_info
|
|
{
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
uint8_t reason;
|
|
} plctxrx_cmd_reject_info_t;
|
|
|
|
typedef struct _plctxrx_cmd_cco_sta_ind
|
|
{
|
|
bool_t dev_ready;
|
|
uint8_t nid;
|
|
} plctxrx_cmd_cco_sta_ind_t;
|
|
|
|
typedef struct _plctxrx_cmd_tx_pwr
|
|
{
|
|
uint8_t tx_pwr;
|
|
} plctxrx_cmd_tx_pwr_t;
|
|
|
|
typedef struct _plctxrx_cmd_nid
|
|
{
|
|
uint8_t nid;
|
|
} plctxrx_cmd_nid_t;
|
|
|
|
typedef struct _plctxrx_cmd_comm_fault_ind
|
|
{
|
|
uint8_t type;
|
|
uint8_t reason;
|
|
} plctxrx_cmd_comm_fault_ind_t;
|
|
|
|
typedef struct _plctxrx_cmd_whitelist
|
|
{
|
|
/* action for add or del white list */
|
|
uint8_t action;
|
|
uint16_t listcnt;
|
|
uint8_t maclist[0][IOT_MAC_ADDR_LEN];
|
|
} plctxrx_cmd_whitelist_t;
|
|
|
|
typedef struct _plctxrx_cmd_fb_bitmap
|
|
{
|
|
/* frequency band bitmap */
|
|
uint8_t fb_bitmap[IOT_GE_FB_SCAN_BITMAP_SIZE];
|
|
} plctxrx_cmd_fb_bitmap_t;
|
|
|
|
typedef struct _plctxrx_cmd_fix_rate
|
|
{
|
|
/* fixed rate mode 0:disable 1:enable */
|
|
uint8_t fix_rate_mode;
|
|
} plctxrx_cmd_fix_rate_t;
|
|
|
|
typedef struct _plctxrx_cmd_sta_pos_leave_ind
|
|
{
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
} plctxrx_cmd_sta_pos_leave_ind_t;
|
|
|
|
typedef struct _plctxrx_cmd_band_info
|
|
{
|
|
uint8_t band_id;
|
|
} plctxrx_cmd_band_info_t;
|
|
|
|
typedef struct _plctxrx_cmd_wdg
|
|
{
|
|
/* action to set watchdog, 1 to enable. 0 to disable*/
|
|
uint8_t action;
|
|
/* watch dog interval, unit is min, less than 30 minutes is disallowed. */
|
|
uint16_t interval;
|
|
} plctxrx_cmd_wdg_t;
|
|
|
|
typedef struct _plctxrx_cmd_query_topo_t
|
|
{
|
|
/* query topo type */
|
|
uint8_t ver;
|
|
/* query topo start */
|
|
uint16_t start;
|
|
/* query count */
|
|
uint16_t cnt;
|
|
} plctxrx_cmd_query_topo_t;
|
|
|
|
#pragma pack(push) // save the pack status
|
|
#pragma pack(1) // 1 byte align
|
|
|
|
typedef struct _dev_test_mode_cfg {
|
|
/* band ID to be configured, see PLC_LIB_FREQ_BAND_X */
|
|
uint8_t band_id;
|
|
/* configuring effective duration, uint is sec */
|
|
uint8_t dur;
|
|
/* the target device ID group that needs to respond to this command.
|
|
* see IOT_DEV_TEST_TARGET_ID_MSK_XXX.
|
|
*/
|
|
uint32_t target_id_mask;
|
|
} dev_test_mode_cfg_t;
|
|
|
|
typedef struct _protpkt_tx_info_t
|
|
{
|
|
/* the total cnt of sta that will receive the pkt */
|
|
uint16_t sta_cnt;
|
|
/* retry interval */
|
|
uint16_t retry_intvl;
|
|
/*
|
|
* proto set dest by mac. and sta plctxrx only set tei to 1. cco txrx do
|
|
* forward
|
|
*/
|
|
/* source mac address */
|
|
uint8_t src_mac[IOT_MAC_ADDR_LEN];
|
|
/* destination sta mac */
|
|
uint8_t dst_mac[IOT_MAC_ADDR_LEN];
|
|
/* origin sta MAC */
|
|
uint8_t org_mac[IOT_MAC_ADDR_LEN];
|
|
/* pkt send type,reference to enum txrx_type_e */
|
|
uint8_t send_type;
|
|
/* indicates if sta need response */
|
|
bool_t need_ack;
|
|
/* retry counter */
|
|
uint8_t retry_cnt;
|
|
/* tx power */
|
|
uint8_t txpwr;
|
|
/* identify msdu pkt comes from proto or at moudle */
|
|
uint8_t src_module;
|
|
/**
|
|
* 0: connect packet
|
|
* 1: connless packet
|
|
*/
|
|
uint8_t force_tx_connless;
|
|
/**
|
|
* 0: aggr
|
|
* 1: not aggr
|
|
*/
|
|
uint8_t force_noaggr;
|
|
} protpkt_tx_info_t;
|
|
|
|
/* proto pkt element */
|
|
typedef struct _list_node_t {
|
|
struct _list_node_t *next;
|
|
uint8_t* data;
|
|
uint16_t len;
|
|
} list_node_t;
|
|
|
|
/* list to save proto pkt */
|
|
typedef struct _protpkt_list
|
|
{
|
|
list_node_t* list_head;
|
|
uint16_t frame_cnt;
|
|
uint16_t total_len;
|
|
} protpkt_list_t;
|
|
|
|
/* cmd element (cmd from protocol layer) */
|
|
typedef struct _plctxrx_cmdsave_node_t {
|
|
list_node_t node;
|
|
/* pointer to iot packet */
|
|
void *data;
|
|
} plctxrx_cmdsave_node_t;
|
|
|
|
/* cmd list to cache */
|
|
typedef struct _plctxrx_cmdsave_list_t {
|
|
list_node_t *first;
|
|
list_node_t *tail;
|
|
uint8_t depth;
|
|
} plctxrx_cmdsave_list_t;
|
|
|
|
typedef struct plctxrx_command
|
|
{
|
|
plctxrx_cid_t cur_cid;
|
|
bool_t cmd_running;
|
|
/* indication current cmd need response cfm to proto */
|
|
bool_t need_ack;
|
|
/* node pool queue for command */
|
|
plctxrx_cmdsave_list_t free_q;
|
|
/* command save queue */
|
|
plctxrx_cmdsave_list_t save_q;
|
|
/* the table of plctxrx command. */
|
|
plctxrx_cmd_table_t table;
|
|
} plctxrx_command_t;
|
|
|
|
/* msdu header at begging of msdu payload. */
|
|
typedef struct _msdu_pkt_hdr {
|
|
/* 0 means, this is msdu.
|
|
* non-zero means, remote peer msdu received confirmation seq.
|
|
*/
|
|
uint16_t recvconf_seq;
|
|
/* msdu sent seq */
|
|
uint16_t msdusend_seq;
|
|
/* the total cnt of sta that will receive the pkt */
|
|
uint8_t dest_cnt;
|
|
/* indicating if confirmation is necessary for receivers*/
|
|
uint8_t need_ack : 1,
|
|
aes_encrypt : 1,
|
|
aes_padding : 4,
|
|
resv : 2;
|
|
|
|
/* identify msdu pkt comes from proto or at moudle */
|
|
uint8_t src_module;
|
|
/* below mac are for cco forward msdu from sta to sta */
|
|
/* src mac */
|
|
uint8_t src_mac[IOT_MAC_ADDR_LEN];
|
|
/* dst mac */
|
|
uint8_t dst_mac[IOT_MAC_ADDR_LEN];
|
|
/* org_mac */
|
|
uint8_t org_mac[IOT_MAC_ADDR_LEN];
|
|
} msdu_pkt_hdr_t;
|
|
|
|
/* store the aggred-pkt, need to put into the queue, followeing the ruls: FIFO*/
|
|
typedef struct _prot_pkt_t {
|
|
/* list node head */
|
|
list_node_t node;
|
|
/* msdu tx information */
|
|
protpkt_tx_info_t txinfo;
|
|
/* msdu sequence */
|
|
uint16_t msdu_seq;
|
|
/* payload size */
|
|
uint16_t msdu_data_len;
|
|
/* msdu been sent counter zero means new received buffer. non-zero means */
|
|
uint8_t send_cnt;
|
|
/* pkt need a plctxrx level ack */
|
|
uint8_t ack_flag;
|
|
/* data buffer */
|
|
uint8_t buf[TXRX_AGGR_PKT_LEN];
|
|
} prot_pkt_t;
|
|
|
|
typedef struct _prot_pktq
|
|
{
|
|
list_node_t* list_head;
|
|
/* first in, first out method. add frame in tail. remove from head*/
|
|
list_node_t* list_tail;
|
|
/* the queue depth */
|
|
uint32_t depth;
|
|
/* proto pkt fifo lock */
|
|
os_mutex_h lock;
|
|
} prot_pktq_t;
|
|
|
|
/* topo info v0 */
|
|
typedef struct _topo_info_v0_t {
|
|
uint8_t level;
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
} topo_info_v0_t;
|
|
|
|
/* topo info v1 include phase */
|
|
typedef struct _topo_info_v1_t {
|
|
uint8_t level;
|
|
uint8_t logic_phase;
|
|
uint8_t phy_phase;
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
} topo_info_v1_t;
|
|
|
|
/* node info include sta_tei */
|
|
typedef struct _node_info_v1_t {
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
uint16_t sta_tei;
|
|
uint16_t proxy_tei;
|
|
} node_info_v1_t;
|
|
|
|
/* node info include dev_type ... */
|
|
typedef struct _node_info_2_t {
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
uint8_t ul_tf_sr;
|
|
uint8_t dl_tf_sr;
|
|
uint32_t build_ver;
|
|
uint16_t vendor;
|
|
uint8_t dev_type;
|
|
uint8_t snr;
|
|
} node_info_v2_t;
|
|
|
|
/* node info include assoc_rx_cnt ... */
|
|
typedef struct _node_info_v3_t {
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
uint16_t assoc_rx_cnt;
|
|
uint16_t proxy_chg_accept_cnt;
|
|
uint32_t proxy_chg_rx_cnt;
|
|
} node_info_v3_t;
|
|
|
|
/* node info include in_network_time ... */
|
|
typedef struct _node_info_v4_t {
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
uint32_t in_network_time;
|
|
uint32_t inactive_time;
|
|
} node_info_v4_t;
|
|
|
|
/* node info include last_assoc_rx_time ... */
|
|
typedef struct _node_info_v5_t {
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
uint32_t last_assoc_rx_time;
|
|
uint32_t last_proxy_chg_time;
|
|
} node_info_v5_t;
|
|
|
|
/* proto layer registed, plctxrx layer use.
|
|
report sigle Gree frame list to proto layer.
|
|
Gree aggregation msdu de-aggr handled inside this layer
|
|
|
|
TODO: this API currently only support GREE. modify inside to be more general
|
|
*/
|
|
typedef uint8_t(* proto_recv_cb)(protpkt_list_t *report_framelist,
|
|
plctxrx_rx_data_info_t *rxinfo);
|
|
|
|
#pragma pack(pop)
|
|
|
|
typedef struct _plc_sta_net_statics
|
|
{
|
|
/* signal-noise ratio */
|
|
uint8_t snr;
|
|
/* logical phase of the station */
|
|
uint16_t phase;
|
|
/* received noise factor*/
|
|
uint8_t nr;
|
|
/* up link tsf */
|
|
uint8_t ul_tf_sr;
|
|
/* downlink tsf*/
|
|
uint8_t dl_tf_sr;
|
|
} plc_sta_net_statics_t;
|
|
|
|
typedef struct _plc_txrx_statics
|
|
{
|
|
/* counter for received msdu pkt */
|
|
uint32_t msdu_receivd_cnt;
|
|
/* counter for received proto frame plt */
|
|
uint32_t fram_send_cnt;
|
|
/* counter for indicating how many frame received from proto were drop */
|
|
uint32_t fram_send_drop_cnt;
|
|
/* counter for indicating how many frame received from plc */
|
|
uint32_t fram_report_cnt;
|
|
/* counter for msdu pkt sent by uincast method */
|
|
uint32_t msdu_sent_uni_cnt;
|
|
/* counter for msdu pkt to be sent by uincast method */
|
|
uint32_t msdu_remain_uni_cnt;
|
|
/* counter for msdu pkt sent by broadcast method */
|
|
uint32_t msdu_sent_brd_cnt;
|
|
/* counter for msdu pkt to be sent by broadcast method */
|
|
uint32_t msdu_remain_brd_cnt;
|
|
/* counter for lost msdu pkts */
|
|
uint32_t msdu_lost_pkt_cnt;
|
|
|
|
} plc_txrx_statics_t;
|
|
|
|
/* sta table to record each peer link state*/
|
|
typedef struct _plcsta_state_t
|
|
{
|
|
/* self role */
|
|
uint8_t role;
|
|
/* is dev ready */
|
|
uint8_t dev_ready;
|
|
/* self mac address */
|
|
uint8_t sta_mac[IOT_MAC_ADDR_LEN];
|
|
/* cco mac address */
|
|
uint8_t cco_mac[IOT_MAC_ADDR_LEN];
|
|
/* self tei */
|
|
uint16_t sta_tei;
|
|
/* net status */
|
|
plc_sta_net_statics_t net_status;
|
|
/* txrx status */
|
|
plc_txrx_statics_t txrx_status;
|
|
/* sequence of last received msdu pkt from plc*/
|
|
uint16_t lastrcv_msduseq;
|
|
/* counter of msdu which transmitting failed*/
|
|
uint16_t txfail_msdu_cnt;
|
|
/* rate node */
|
|
uint8_t rate_node;
|
|
/* rate node last*/
|
|
uint8_t rate_node_last;
|
|
}plcsta_state_t;
|
|
|
|
/* sta's information stored in cco*/
|
|
typedef struct _plcsta_info_t
|
|
{
|
|
/* valid sta, 1 means valid statio info, and sta level */
|
|
uint8_t valid : 1,
|
|
level : 4,
|
|
resv : 3;
|
|
/* self tei */
|
|
uint16_t sta_tei;
|
|
/* sequence of last received msdu pkt from plc*/
|
|
uint16_t lastrcv_msduseq;
|
|
/* counter for missed sequence since last receiving*/
|
|
uint16_t miss_msduseq_cnt;
|
|
/* role of the station */
|
|
uint8_t role;
|
|
/* self mac address */
|
|
uint8_t sta_mac[IOT_MAC_ADDR_LEN];
|
|
} plcsta_info_t;
|
|
|
|
/* connect_less pkt infor */
|
|
typedef struct _plcs_conn_less_pkt_info_t
|
|
{
|
|
/* msdu's sequnce number */
|
|
uint16_t msdu_sn;
|
|
/* life span cnt*/
|
|
uint8_t span_cnt;
|
|
/* src mac indicate who sends the pkt */
|
|
uint8_t src_mac[IOT_MAC_ADDR_LEN];
|
|
} plcs_conn_less_pkt_info_t;
|
|
|
|
typedef struct _plctxrx_cmd_systeminfo
|
|
{
|
|
/*enum plctxrx_command_device_reboot_reason_e*/
|
|
uint8_t last_reboot_reason;
|
|
/* statistics of total reboot times. */
|
|
uint32_t total_reboot_times;
|
|
/* system running time(seconds) since powerup. */
|
|
uint32_t os_running_time;
|
|
/* software version, reference to "iot_version_api.h" */
|
|
uint32_t software_ver;
|
|
} plctxrx_cmd_systeminfo_t;
|
|
|
|
typedef struct _plctxrx_cmd_handle_uart
|
|
{
|
|
/* Index of current uart port. */
|
|
uint8_t uart_port;
|
|
/* Data length, 5~8 */
|
|
uint8_t data_len;
|
|
/* 1 : 1 bit, 2 : 1.5 bits, 3 : 2 bits */
|
|
uint8_t stop_bit;
|
|
/* 0 : disable, 1 : odd, 2 : even */
|
|
uint8_t parity;
|
|
/* Bandrate of uart. 0 means auto-bandrate. */
|
|
uint32_t bandrate;
|
|
} plctxrx_handle_uart_t;
|
|
|
|
typedef struct _plctxrx_cmd_topo
|
|
{
|
|
/* level of the station */
|
|
uint8_t level;
|
|
/* logic phase of the station */
|
|
uint8_t logic_phase;
|
|
/* physical phase of the station */
|
|
uint8_t phy_phase;
|
|
/* device mac*/
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
} plctxrx_cmd_topo_t;
|
|
|
|
/* for IOT_PLC_CCO_TOPO_REQ_DATA_VER_V2 use */
|
|
typedef struct _plctxrx_cmd_topov2_t
|
|
{
|
|
/* level of the station */
|
|
uint8_t level;
|
|
/* device mac */
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
} plctxrx_cmd_topov2_t;
|
|
|
|
/* quey node info */
|
|
typedef struct _plctxrx_cmd_query_node_info
|
|
{
|
|
/* query node type see _node_info_type_e */
|
|
uint8_t type;
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
} plctxrx_cmd_query_node_info_t;
|
|
|
|
/* plctxrx node resp info */
|
|
typedef struct _plctxrx_command_handle_node_info
|
|
{
|
|
uint16_t cnt;
|
|
/* node info of each valid tei, see iot_plc_node_info_xxx_t */
|
|
uint8_t node[0];
|
|
} plctxrx_handle_node_info_t;
|
|
|
|
/* plctxrx topo resp info */
|
|
typedef struct _plctxrx_command_handle_topo
|
|
{
|
|
uint16_t cnt;
|
|
plctxrx_cmd_topo_t topo[0];
|
|
} plctxrx_handle_topo_t;
|
|
|
|
/* plctxrx topo info */
|
|
typedef struct _plctxrx_handle_topo_v2_t
|
|
{
|
|
uint16_t cnt;
|
|
plctxrx_cmd_topov2_t node[0];
|
|
} plctxrx_handle_topo_v2_t;
|
|
|
|
/* vendor info in beacon */
|
|
#if ENABLE_GE_DATA_SEND_TO_BEACON
|
|
typedef struct _plctxrx_cmd_vendor_info
|
|
{
|
|
uint8_t data[IOT_PLC_BEACON_DATA_MAX];
|
|
} plctxrx_cmd_vendor_info_t;
|
|
#endif
|
|
|
|
/* software version resp */
|
|
typedef struct _plctxrx_cmd_software_ver_resp
|
|
{
|
|
uint32_t version;
|
|
} plctxrx_cmd_software_ver_resp_t;
|
|
|
|
/* ntb resp */
|
|
typedef struct _plctxrx_cmd_ntb_resp
|
|
{
|
|
uint32_t ntb;
|
|
} plctxrx_cmd_ntb_resp_t;
|
|
|
|
/* fb bitmap resp */
|
|
typedef struct _plctxrx_cmd_fb_bitmap_resp
|
|
{
|
|
uint8_t is_scan_bitmap;
|
|
uint8_t fb_bitmap[IOT_GE_FB_SCAN_BITMAP_SIZE];
|
|
} plctxrx_cmd_fb_bitmap_resp_t;
|
|
|
|
/* fix rate mode resp */
|
|
typedef struct _plctxrx_cmd_fix_rate_mode_resp
|
|
{
|
|
/* 0:fix rate disable 1:fix rate enable */
|
|
uint8_t enable;
|
|
} plctxrx_cmd_fix_rate_mode_resp_t;
|
|
|
|
typedef struct _plctxrx_cmd_boot_info_resp
|
|
{
|
|
/* enum plctxrx_command_device_reboot_reason_e*/
|
|
uint8_t last_reboot_reason;
|
|
/* statistics of total boot count. */
|
|
uint16_t total_boot_cnt;
|
|
/* system running time(seconds) since powerup. */
|
|
uint32_t os_running_time;
|
|
} plctxrx_cmd_boot_info_resp_t;
|
|
|
|
typedef struct _plctxrx_cmd_handle_send
|
|
{
|
|
protpkt_tx_info_t txinfo;
|
|
uint8_t dlen;
|
|
uint8_t data[0];
|
|
} plctxrx_handle_send_t;
|
|
|
|
/* txrx callback to at with this structure */
|
|
typedef struct _plctxrx_handle_recv
|
|
{
|
|
/* data receive information */
|
|
plctxrx_rx_data_info_t rxinfo;
|
|
uint8_t resv; /* 4 bytes aligned for data[0]. */
|
|
/* data len */
|
|
uint8_t dlen;
|
|
/* payload */
|
|
uint8_t data[0];
|
|
} plctxrx_handle_recv_t;
|
|
|
|
/* message used in plc txrx layer task.
|
|
*/
|
|
typedef struct _plctxrx_task_msg_t {
|
|
/* standard iot_task message */
|
|
iot_task_msg_t msg;
|
|
/* pointer to message data */
|
|
void *data;
|
|
/* another data field */
|
|
uint32_t data2;
|
|
}plctxrx_task_msg_t;
|
|
|
|
/* proto layer hook function pointer. post message to proto task msg queue */
|
|
typedef struct _proto_callback_t
|
|
{
|
|
/* data path */
|
|
proto_recv_cb gree_proto_recv_cb;
|
|
/* control path */
|
|
proto_network_event_cb gree_network_event_cb;
|
|
/* vendor info path */
|
|
proto_vendr_cb gree_vendr_cb;
|
|
}proto_callback_t;
|
|
|
|
typedef uint8_t(*at_resp_cb)(iot_pkt_t * pkt);
|
|
|
|
typedef struct _atbcd_callback_t
|
|
{
|
|
at_resp_cb at_cmd_resp_cb;
|
|
}at_callback_t;
|
|
|
|
typedef uint8_t(* dev_test_recv_cb_t)(protpkt_list_t *report_framelist,
|
|
plctxrx_rx_data_info_t *rxinfo);
|
|
|
|
typedef uint8_t(* dev_test_event_cb_t)(iot_pkt_t *pkt);
|
|
|
|
typedef struct _dev_test_callback_t
|
|
{
|
|
dev_test_recv_cb_t dev_test_recv_cb;
|
|
dev_test_event_cb_t dev_test_event_cb;
|
|
}dev_test_callback_t;
|
|
|
|
/* plctxrx layer global variable */
|
|
typedef struct _plctxrx_contxt
|
|
{
|
|
/* plc lib handle */
|
|
uint32_t plclib_hdl;
|
|
/* plctxrx task handle. indicate this layer is one task */
|
|
iot_task_h task_handle;
|
|
|
|
/* link id used for sending msdu */
|
|
uint8_t link_id;
|
|
/* plctxrx message queue */
|
|
uint8_t msg_q;
|
|
/* current cmd handling */
|
|
plctxrx_command_t command;
|
|
|
|
/* proto layer registered callback */
|
|
proto_callback_t gree_cb;
|
|
|
|
/* at layer registered callback */
|
|
at_callback_t at_cb;
|
|
|
|
/* dev test layer registered callback */
|
|
dev_test_callback_t dev_test_cb;
|
|
|
|
/* internal aggr frame function */
|
|
proto_aggr_fn iotpkt_aggr_fn;
|
|
/* internal status analysis function */
|
|
PLCTXRX_STATISTIC plctxrx_status_fn;
|
|
|
|
/* the current queue that need to be send out */
|
|
prot_pktq_t *sendq;
|
|
/* the queue that free to hold prot_pkt */
|
|
prot_pktq_t *freeq;
|
|
/* pointer, current aggring pkt */
|
|
prot_pkt_t *aggrpkt;
|
|
|
|
/* data method timer, eg, re-send */
|
|
timer_id_t datapath_timer;
|
|
/* general timer for plctxrx period action */
|
|
timer_id_t txrx_timer;
|
|
/* general timer for plctxrx aggr_timeout action */
|
|
timer_id_t aggr_timer;
|
|
/* current online station number */
|
|
uint16_t cur_stanum;
|
|
/* peak online station number */
|
|
uint16_t peak_stanum;
|
|
/* local sta's status */
|
|
plcsta_state_t local_state;
|
|
/* the package sequence, allocated when needed to send to plc */
|
|
uint16_t pktseq;
|
|
/* each station information */
|
|
plcsta_info_t sta[STA_DEV_MAX];
|
|
/* buffer to hold gree time and passwd */
|
|
plctxrx_cmd_vendor_info_t verinfo;
|
|
/* role in network CCO or STA */
|
|
uint8_t nw_role;
|
|
/* to save query node infomation type */
|
|
uint8_t node_info_type;
|
|
/* counter of txrx timer triggered */
|
|
uint8_t txrx_tm_cnt;
|
|
/* indicate how many conn_less pkt infor buf are used */
|
|
uint8_t used_buf_cnt;
|
|
/* buffer for storing received conn_less pkt' infor */
|
|
plcs_conn_less_pkt_info_t conn_less_buf[IOT_PLCTXRX_CONN_LESS_PKT_BUF_CNT];
|
|
/* record last recv msdu snr */
|
|
int8_t u_snr;
|
|
}plctxrx_contxt_t;
|
|
|
|
/* post a message to execute the callback functions */
|
|
void iot_plctxrx_post_msg(uint16_t msg_type,uint16_t msg_id, void* data,
|
|
uint32_t data2);
|
|
|
|
/* txrx internal api. input is one agg-ed proto frame, and tx condition.
|
|
this function will allocate iot_pkt(a.k.a msdu) and send cvg.
|
|
mac layer will free iot_pkt.
|
|
but, prot_pkt still wait in sending list for waiting ack.
|
|
once ack received, remove prot_pkt from send list, and return to free list.
|
|
*/
|
|
|
|
uint8_t iot_plctxrx_msdu_send(prot_pkt_t* prot_pkt);
|
|
|
|
/* interface for lower layer to send data to txrx */
|
|
void iot_plctxrx_handle_mac_msg(iot_pkt_t *pkt);
|
|
|
|
/*
|
|
when txrx receive one iot_pkt(msdu) from plclib, if the pkt is a normal data,
|
|
send ack back immediately.
|
|
the ack pkt is based on the rececivd iot_pkt(msdu)
|
|
*/
|
|
uint8_t iot_plctxrx_msdu_send_ack_back(iot_plc_msdu_recv_t *msdu);
|
|
|
|
|
|
/*
|
|
once the prot_pkt is send out, if need ack, reset the retry timer
|
|
*/
|
|
void iot_plctxrx_timer_reset(timer_id_t task_timer, uint32_t period );
|
|
|
|
/*
|
|
when proto pkt not received in sending list, and retry timer fired,
|
|
check resend count, and do resend action.
|
|
*/
|
|
uint8_t iot_plctxrx_msdu_waitack_timeout(prot_pkt_t* prot_pkt);
|
|
|
|
/*
|
|
when one aggred proto pkt is ready to send, then add it in sending list.
|
|
note: first in , first out to keep send order.
|
|
*/
|
|
uint8_t iot_plctxrx_frame_add_queue(prot_pktq_t *queue ,\
|
|
protpkt_list_t *protpkt_list);
|
|
|
|
/*
|
|
internal function. when acked received, remove from send list,
|
|
and put to free list.
|
|
*/
|
|
prot_pktq_t* iot_plctxrx_frame_remove_queue(prot_pktq_t *queue);
|
|
|
|
/*
|
|
internal function. check queue is empty or not.
|
|
*/
|
|
uint8_t iot_plctxrx_queue_empty_check(prot_pktq_t *queue);
|
|
|
|
/*
|
|
internal function. check conditions for dequeue, if condition is satisfied,
|
|
execute remove queue operations
|
|
*/
|
|
uint8_t iot_plctxrx_dequeue_condition_check(prot_pktq_t *queue, \
|
|
plctxrx_rx_data_info_t *rxinfo);
|
|
|
|
/*
|
|
internal function, txrx handle aggred propkt ack frame from receiver side
|
|
*/
|
|
uint8_t iot_plctxrx_msdu_recvconf_handle(iot_pkt_t *pkt);
|
|
|
|
/*
|
|
internal function, txrx update stastics
|
|
*/
|
|
uint8_t iot_plctxrx_stastics_update(plc_txrx_statics_t stastic);
|
|
|
|
/*
|
|
internal function, when proto layer need send a pkt, before sending, this
|
|
function firstly check the dst ip/mac, if the dst ip/mac is same
|
|
as the previous, then check if aggr buffer space, if space is enough,
|
|
attach it to the aggr_buffer, if not, store it in the next aggr_buffer,
|
|
and send the current aggr_buffer into the queue; if the dst ip/mac is
|
|
different from the previous one, send the current aggr_buffer into the queue,
|
|
and store the pkt in the next aggr_buffer. Return 0 means condition satisfied,
|
|
none_zero means aggr abandoned, the return data indicate the reasons:
|
|
1. dst not match
|
|
2. retry config not match
|
|
3. buffer not enough
|
|
*/
|
|
uint32_t iot_plctxrx_aggr_frame_condition_check(prot_pkt_t* in_pkt, \
|
|
prot_pkt_t* aggr_pkt);
|
|
|
|
|
|
/*
|
|
txrx layer registerd and used by proto layer, when proto neen to send data,
|
|
call this funtion, this function will aggr the data, once the condiction
|
|
satisfied, send the aggred data to plc
|
|
*/
|
|
uint8_t iot_plctxrx_proto_data_send_cbk(uint8_t* data, uint16_t len,\
|
|
protpkt_tx_info_t *txinfo);
|
|
|
|
/*
|
|
initialize list for gree frame report
|
|
*/
|
|
uint8_t iot_plctxrx_list_init(void);
|
|
|
|
/*
|
|
free the mem for list pool after handled the list
|
|
*/
|
|
void iot_plctxrx_list_free(protpkt_list_t *list);
|
|
|
|
/* hook interface with proto layer */
|
|
uint8_t iot_plctxrx_proto_register(proto_recv_cb datacb,\
|
|
proto_network_event_cb netcb, proto_vendr_cb vendrcb);
|
|
|
|
/* callback function for proto layer to send data to plctcrx layer */
|
|
uint8_t gree_send_cbk(uint8_t* data, uint8_t len, protpkt_tx_info_t *txinfo);
|
|
|
|
/* callback function for proto layer to send cmd to plctcrx layer */
|
|
uint8_t plctxrx_cmd_send_mssage(iot_pkt_t *arg);
|
|
|
|
/* at command/machine binary command layer registed callback. plctxrx use to
|
|
response command previous received. cmd-resp works as ping-pong method */
|
|
|
|
|
|
/* hook interface with at layer */
|
|
uint8_t iot_plctxrx_at_register(at_resp_cb at_cb);
|
|
|
|
/* hook interface with dev test layer */
|
|
uint8_t iot_plctxrx_dev_test_register(dev_test_recv_cb_t recv_cb,
|
|
dev_test_event_cb_t event_cb);
|
|
|
|
/* cvg callback to post msdu from plc */
|
|
void iot_plctxrx_msdu_from_cvg(void *param, iot_pkt_t *pkt);
|
|
|
|
/* config device type and mac */
|
|
void plctxrx_set_device_mac(uint8_t *mac, uint8_t dev_type);
|
|
|
|
/* iot_plctxrx_task_init - init plctxrx task
|
|
* @return:
|
|
* ERR_AGAIN - reinit proto task
|
|
* ERR_NOMEM - no memory
|
|
* ERR_OK - OK
|
|
*/
|
|
int iot_plctxrx_task_init(void);
|
|
|
|
/* iot_plctxrx_task_deinit - deinit plctxrx task */
|
|
void iot_plctxrx_task_deinit(void);
|
|
|
|
/*
|
|
internal function, if txrx received a ack, according to the mac address,
|
|
update the ackbitmap
|
|
*/
|
|
uint8_t iot_plctxrx_ackflag_update(uint8_t *mac);
|
|
|
|
/*
|
|
internal function, if the retry timer is fired, check the bitmap,
|
|
find out which one is not send back ack
|
|
*/
|
|
uint8_t iot_plctxrx_ackbitmap_scan_for_retry(void);
|
|
|
|
/*
|
|
internal function, if the retry cnt reaches the max counter
|
|
remove from the queue
|
|
*/
|
|
uint8_t iot_plctxrx_retry_reach_max_cnt_check(void);
|
|
|
|
/*
|
|
check if STA is online, used only by CCO role.
|
|
*/
|
|
bool_t iot_plctxrx_check_sta_in_nw_by_mac(uint8_t* mac);
|
|
|
|
/*
|
|
get sta level, success:return 1 ~ 15, fail:return -1.
|
|
*/
|
|
int8_t iot_plctxrx_get_node_level(uint8_t *mac);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* IOT_PLCTXRX_H */
|
|
|
|
|