/**************************************************************************** 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_SG_CCO_X4_H #define IOT_SG_CCO_X4_H /* iot common header files */ #include "iot_errno_api.h" /* smart grid internal header files */ #include "iot_sg_fr.h" #ifdef __cplusplus extern "C" { #endif #if IOT_SMART_GRID_X4_ENABLE /** * @brief: set parameter for bcast collect task command. * @param cmd_entry: down link collect task command. * @return: ERR_OK for success case. Other value for failed case. */ uint32_t iot_sg_cco_send_bcast_clct_task_cmd(iot_buf_pool_entry_t *cmd_entry); /** * @brief: bcast collect task command split into unicast collect command. */ void iot_sg_cco_clct_task_bcast(); /** * @brief: send add collect task. * @param sta_mac: mac address of station, big-endian. * @param pm_mac: meter mac address, little-endian. * @param data: collect task data info pointer. * @param len: collect task data length. * @param sn: sequence number of the packet. */ void iot_sg_cco_clct_task_add_send(uint8_t *sta_mac, uint8_t *pm_mac, iot_sg_collect_task_t *data, uint8_t len, uint16_t sn); /** * @brief: set bcast ack flag in white list. * @param wl_entry: entry of the collect task whitelist. * @param buf_entry: entry of the collect task command. * @param rpt_result: collect task add result. */ void iot_sg_cco_clct_task_set_bcast_ack(iot_sg_wl_entry_t *wl_entry, iot_buf_pool_entry_t *buf_entry, uint8_t rpt_result); /** * @brief: report collect task add result to ul buf. * @param pm_mac: meter mac addr, little endian. * @param buf_entry: entry of collect task command. * @param rpt_state: add collect task state, see IOT_SG_CCO_CLCT_TASK_XXX. */ void iot_sg_cco_clct_task_add_rpt(uint8_t *pm_mac, iot_buf_pool_entry_t *buf_entry, uint8_t rpt_state); /** * @brief: reset collect task parameter. */ void iot_sg_cco_clct_task_param_reset(); /** * @brief: initialize collect task. */ void iot_sg_cco_node_init_clct_task(); /** * @brief: collect task get white list entry by sn. * @param sn: the sn for app packet. value range is in [1,0xFFFF] * @return: entry of the white list. */ iot_sg_wl_entry_t *iot_sg_cco_get_clct_bcast_task_wl(uint16_t sn); /** * @brief: handle init collection task ack. * @param src_sta_mac: mac address of the source STA, big-endian. * @param ack: unicast response, 0 - ack, others - nack. */ void iot_sg_cco_handle_init_clct_task_ack(uint8_t *src_sta_mac, uint8_t ack); /** * @brief: get collect task data len. * @param proto_type: type of pm protocol, see IOT_SG_CCO_PROTO_TYPE_XXX. * @param di_cnt: di count in clct task info. * @return: 0 - proto_type err, others - data len include di data and crc. */ uint8_t iot_sg_cco_get_clct_task_data_len(uint8_t proto_type, uint8_t di_cnt); #else /* IOT_SMART_GRID_X4_ENABLE */ #define iot_sg_cco_send_bcast_clct_task_cmd(cmd_entry) (ERR_FAIL) #define iot_sg_cco_clct_task_bcast() #define iot_sg_cco_clct_task_add_send(sta_mac, pm_mac, data, len, sn) #define iot_sg_cco_clct_task_set_bcast_ack(wl_entry, buf_entry, rpt_result) #define iot_sg_cco_clct_task_add_rpt(pm_mac, buf_entry, rpt_state) #define iot_sg_cco_clct_task_param_reset() #define iot_sg_cco_node_init_clct_task() #define iot_sg_cco_get_clct_bcast_task_wl(sn) (NULL) #define iot_sg_cco_handle_init_clct_task_ack(src_sta_mac, ack) #define iot_sg_cco_get_clct_task_data_len(proto_type, di_cnt) (0) #endif /* IOT_SMART_GRID_X4_ENABLE */ #ifdef __cplusplus } #endif #endif /* IOT_SG_CCO_X4_H */