Files
kunlun/app/smart_grid/inc/internal/iot_gw_app_cco.h
2024-09-28 14:24:04 +08:00

808 lines
32 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_GW_APP_CCO_H
#define IOT_GW_APP_CCO_H
/* os shim includes */
#include "os_types_api.h"
/* smart grid internal header files */
#include "iot_sg_msg.h"
#include "iot_sg_fr.h"
/* iot common header files */
#include "iot_plc_msg_api.h"
#ifdef __cplusplus
extern "C" {
#endif
#if (PLC_SUPPORT_CCO_ROLE && IOT_SMART_GRID_ENABLE && IOT_GW_APP_ENABLE)
/**
* @brief iot_gw_handle_read_meter() - send meter data to plc.
* @param meter_mac: meter mac.
* @param sta_mac: station mac.
* @param data_type: protocol type, see GW_APP_DATA_TYPE_XXX.
* @param data: meter data.
* @param len: meter data length.
* @param sn: sequence number.
* @param read_type: meter type, see IOT_SG_RMT_XXX.
* @param retry_cnt: retry count. only valid for bcast meter reading.
* @param mr_cmd_tx_done_func: meter reading send done callback.
* @param mr_entry: meter reading entry.
*/
void iot_gw_handle_read_meter(uint8_t *meter_mac, uint8_t *sta_mac,
uint8_t data_type, uint8_t *data, uint16_t len,
uint32_t sn, uint32_t read_type, uint32_t retry_cnt,
iot_pkt_free_func_t mr_cmd_tx_done_func, iot_buf_pool_entry_t *mr_entry);
/**
* @brief iot_gw_handle_correct_time() - send correct time data to plc.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
* @param data: meter data.
* @param len: meter data length.
* @param sta_mac: sta mac address, big endian.
*/
void iot_gw_handle_correct_time(uint8_t intf_type, uint8_t *data,
uint16_t len, uint8_t *sta_mac);
/**
* @brief iot_gw_handle_correct_time_ext() - send correct time extend
* data to plc.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
* @param data: meter data.
* @param len: meter data length.
*/
void iot_gw_handle_correct_time_ext(uint8_t intf_type, uint8_t *data,
uint16_t len);
/**
* @brief iot_gw_handle_accurate_correct_time() - send accurate correct
* time data to plc.
* @param data: meter data.
* @param len: meter data length.
* @param seq sequence number.
* @param sta_mac: mac address of the station, big endian.
* @param ntb: ntb for recv correct time message.
*/
void iot_gw_handle_accurate_correct_time(uint8_t *data, uint16_t len,
uint8_t seq, uint8_t *sta_mac, uint32_t ntb);
/**
* @brief send clock manage correct time data to plc.
* @param time_data: time struct, bcd format.
*/
void iot_gw_handle_clock_manager_corr_time(iot_sg_cco_time_t *time_data);
/**
* @brief iot_gw_handle_clock_manager() - send clock manage data to plc.
* @param cmd_type: cmd type, see GW_APP_CLOCK_MANAGER_XXX.
* @param len: data length.
* @param data: clock manage data.
* @param msg_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_mac: sta mac, big endian.
*/
void iot_gw_handle_clock_manager(uint8_t cmd_type, uint8_t len, uint8_t *data,
uint8_t msg_type, uint8_t *sta_mac);
/**
* @brief iot_gw_handle_clock_query() - send clock manage query data to plc.
* @param msg_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_mac: sta mac, big endian.
*/
void iot_gw_handle_clock_query(uint8_t msg_type, uint8_t *sta_mac);
/**
* @brief iot_gw_handle_correct_sta_time() - send correct sta time data
* to plc.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
* @param data: meter data.
* @param len: meter data length.
*/
void iot_gw_handle_correct_sta_time(uint8_t intf_type, uint8_t *data,
uint16_t len);
/**
* @brief set sta collect parameter.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_mac : mac address of the destination STA, big-endian.
* @param sn: message seq number.
* @param proto_type: proto type, see PROTO_TYPE_XXX.
*/
void iot_gw_handle_set_sta_clct_param(uint8_t intf_type, uint8_t send_type,
uint8_t *sta_mac, uint32_t sn, uint8_t proto_type);
/**
* @brief set sta collect parameter v2.8.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_mac : mac address of the destination STA, big-endian.
* @param sn: message seq number.
* @param task_id: sta collect parameter v2.8 task id.
* @param dev_type: type of dev the STA module attached,
* see IOT_PLC_DEV_TYPE_XXX.
* @param pm_mac: meter address, little endian.
* @param retval: ERR_OK - for success case
* @param retval: otherwise - error code
*/
uint32_t iot_gw_handle_set_sta_clct_param_v28(uint8_t intf_type,
uint8_t send_type, uint8_t *sta_mac, uint32_t sn, uint8_t task_id,
uint8_t dev_type, uint8_t *pm_mac);
/**
* @brief read sta collect data v2.8.
* @param sta_mac : mac address of the destination STA, big-endian.
* @param sn: message seq number.
* @param task_id: sta collect parameter v2.8 task id.
* @param proto_type: proto type, see PROTO_TYPE_XXX.
* @param pm_type: power meter type, 0 - single phase meter,
* 1 - three phase meter.
* @param pm_mac: meter address, little endian.
* @param year: frozen time, year.
* @param month: frozen time, month.
* @param day: frozen time, day.
* @param hour: frozen time, hour.
* @param min: frozen time, min.
* @param sec: frozen time, sec.
* @param retval: ERR_OK - for success case
* @param retval: otherwise - error code
*/
void iot_gw_handle_qry_sta_clct_data_v28(uint8_t *sta_mac, uint32_t sn,
uint8_t task_id, uint8_t proto_type, uint8_t pm_type, uint8_t *pm_mac,
uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min,
uint8_t sec);
/**
* @brief query power meter parameter.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_mac: station mac.
* @param sn: sequence number.
*/
void iot_gw_cco_query_meter_param(uint8_t send_type, uint8_t *sta_mac,
uint32_t sn);
/**
* @brief iot_gw_handle_broadcast_data() - send broadcast data to plc.
* @param if_type: argument.
* @param data_type: protocol type, see GW_APP_DATA_TYPE_XXX.
* @param data: data.
* @param len: data length.
*/
void iot_gw_handle_broadcast_data(uint8_t if_type, uint8_t data_type,
uint8_t *data, uint16_t len);
/**
* @brief iot_gw_handle_comm_test() - send communication test data to plc.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
* @param dev_mac: destination station mac.
* @param data_type: protocol type, see GW_APP_DATA_TYPE_XXX.
* @param data: meter data.
* @param len: meter data length.
*/
void iot_gw_handle_comm_test(uint8_t intf_type, uint8_t *dev_mac,
uint8_t data_type, uint8_t *data, uint16_t len);
/**
* @brief iot_gw_send_evt_rpt_ctrl() - event info transfer to plc.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_mac: mac address of the station, only valid for unicast.
* @param fn: fn code. see GW_APP_EVENT_FN_XXX.
* @param start: 0 - reply. 1 - send evt rpt packet actively.
* @param pkt: the iot_pkt containing gw data received from PLC.
* @param sn: sn of the packet to send, only valid for start = 0;
* @param new_s: if it is 1, a new seq number is gets. only valid for
* start = 1;
* @param pm_addr: address of smart meter, only available in report
* response message.
*/
void iot_gw_send_evt_rpt_ctrl(uint8_t send_type,
uint8_t *sta_mac, uint8_t fn, uint8_t start, uint16_t sn, uint32_t new_s,
uint8_t *pm_addr);
/**
* @brief iot_gw_send_evt_rpt_ctrl_en() - event info transfer to plc.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_mac: mac address of the station, only valid for unicast.
* @param new_s: if it is 1, a new seq number is gets.
*/
#define iot_gw_send_evt_rpt_ctrl_en(send_type, sta_addr, new_s) \
iot_gw_send_evt_rpt_ctrl(send_type, sta_addr, GW_APP_EVENT_FN_ALLOW_RPT, \
1, 0, new_s, NULL)
/**
* @brief iot_gw_send_evt_rpt_ctrl_dis() - send prohibited event report message
* to plc.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_mac: mac address of the station, only valid for unicast.
* @param new_s: if it is 1, a new seq number is gets.
*/
#define iot_gw_send_evt_rpt_ctrl_dis(send_type, sta_addr, new_s) \
iot_gw_send_evt_rpt_ctrl(send_type, sta_addr, GW_APP_EVENT_FN_FORBID_RPT, \
1, 0, new_s, NULL)
/**
* @brief iot_gw_send_evt_rpt_rsp() - send event report response message to
* plc.
* @param sta_addr: mac address of the station.
* @param rsp_type: response types for event reporting. as fllows:
* - GW_APP_EVENT_FN_CONF_ACK
* - GW_APP_EVENT_FN_ALLOW_RPT
* - GW_APP_EVENT_FN_FORBID_RPT
* @param pm_addr: address of the smart meter.
* @param sn: message seq number.
*/
#define iot_gw_send_evt_rpt_rsp(sta_addr, rsp_type, sn, pm_addr) \
iot_gw_send_evt_rpt_ctrl(IOT_PLC_MSG_TYPE_UNICAST, sta_addr, rsp_type, 0, \
sn, 0, pm_addr)
/**
* @brief iot_gw_send_start_sec_node_reg() - send commands of start secondary
* node registration.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_mac: mac address of the station, only valid for unicast.
* @param new_s: if it is 1, a new seq number is gets.
*/
void iot_gw_send_start_sec_node_reg(uint8_t send_type, uint8_t *sta_mac,
uint32_t new_s);
/**
* @brief iot_gw_lp_meter_query_dev_type() - send query low power secondary node
* reg dev type command.
* @param sta_addr: mac address of the station, big-endian.
* @param qr_sn: return seq number.
* @param inc_sn: flag indicating if dl sn shall increase.
* 1 to increase the sn, 0 not increase the sn.
*/
void iot_gw_lp_meter_query_dev_type(uint8_t *sta_addr, uint32_t *qr_sn,
uint8_t inc_sn);
/**
* @brief iot_gw_query_lp_meter_rssi() - send query low power meter rssi
* @param sta_addr: mac address of the station, big-endian.
* @param qr_sn: return seq number.
* @param start_index: start query low power meter rssi seq number.
* @param query_cnt: query low power meter rssi count.
* @param inc_sn: flag indicating if dl sn shall increase.
* 1 to increase the sn, 0 not increase the sn.
*/
void iot_gw_query_lp_meter_rssi(uint8_t *sta_addr, uint32_t *qr_sn,
uint16_t start_index, uint8_t query_cnt, uint8_t inc_sn);
/**
* @brief iot_gw_send_query_sec_node_reg() - send query secondary node reg
* command.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_addr: mac address of the station, only valid for unicast.
* @param dev_type: device type of station.
* @param reg_param: register parameter, see GW_APP_REG_PARAM_XXX.
* @param qr_sn: return seq number.
* @param retval: 0 - for success case
* @param retval: otherwise - error code
*/
uint32_t iot_gw_send_query_sec_node_reg(uint8_t send_type, uint8_t *sta_addr,
uint8_t dev_type, uint8_t reg_param, uint32_t *qr_sn);
/**
* @brief iot_gw_send_sec_node_net_lock_cmd() - send secondary node
* network lock command.
* @param sta_addr: mac address of the station, big endian.
* @param qr_sn: seq number.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XXX.
*/
void iot_gw_send_sec_node_net_lock_cmd(uint8_t *sta_addr, uint32_t qr_sn,
uint8_t send_type);
/**
* @brief iot_gw_send_sec_node_net_unlock_cmd() - send secondary node
* network unlock command.
* @param sta_addr: mac address of the station, big endian.
* @param qr_sn: seq number.
* @param delay: delay time, unit is 1min.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XXX.
*/
void iot_gw_send_sec_node_net_unlock_cmd(uint8_t *sta_addr,
uint32_t qr_sn, uint8_t delay, uint8_t send_type);
/**
* @brief iot_gw_send_query_lp_meter_read() - send query low power meter info
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_addr: mac address of the station, only valid for unicast.
* @param reg_param: register parameter, see GW_APP_REG_PARAM_XXX.
* @param qr_sn: return seq number.
* @param start_seq: start query low power meter seq number.
* @param query_cnt: query low power meter count.
* @param retval: 0 - for success case
* @param retval: otherwise - error code
*/
void iot_gw_send_query_lp_meter_read(uint8_t send_type, uint8_t *sta_addr,
uint8_t reg_param, uint8_t *qr_sn, uint8_t start_seq, uint8_t query_cnt);
/**
* @brief: send a packet to query STA version.
* @param bcast_flag: if use unicast or bcast packet to query.
* 1 - bcast, 0 - unicast.
* @param sta_addr: mac address of the destination STA, big-endian.
* @param sn: seq number of the query packet.
*/
void iot_gw_send_query_sta_version(uint32_t bcast_flag,
uint8_t *sta_addr, uint16_t sn);
/**
* @brief iot_gw_send_stop_sec_node_reg() - send stop query secondary node reg
* command.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
*/
void iot_gw_send_stop_sec_node_reg(uint8_t intf_type);
/**
* @brief iot_gw_cco_msdu_recv - receive a msdu
* @param src_sta_mac: the msdu source address
* @param data: msdu payload
* @param msdu_len: msdu data len
* @param pkt: plc lib message data.
* include plc lib head, msdu head and msdu payload.
* @param is_bcast: 0 - unicast, others - bcast
* @retval: 0 - the pkt is not consumed.
* 1 - the pkt is consumed.
*/
uint32_t iot_gw_cco_msdu_recv(uint8_t *src_sta_mac, uint8_t *data,
uint32_t msdu_len, iot_pkt_t *pkt, uint8_t is_bcast);
/**
* @brief iot_gw_cco_send_ctrl_proto - respond message to ctrl proto.
* @param pkt: iot_pkt_t containing the data that send to controller,
* the pkt will be free.
* @param proto_type: protocol type of the pkt, see IOT_SG_CCO_CTRL_PROTO_XXX.
*/
void iot_gw_cco_send_ctrl_proto(iot_pkt_t *pkt, uint8_t proto_type);
/**
* @brief iot_gw_cco_send_ctrl_proto_passthrough - respond message to ctrl proto
* @param pkt: iot_pkt_t containing the data that send to controller,
* the pkt will be free in function.
*/
void iot_gw_cco_send_ctrl_proto_passthrough(iot_pkt_t *pkt);
/**
* @brief start collect transformer ntb.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
* @param seq: sequence number.
* @param start_ntb: collection start ntb.
* @param collect_cnt: collection count.
* @param collect_seq: collection sequence, the value range is 1-255.
*/
void iot_gw_handle_tsfm_detect_collect_ntb(uint8_t intf_type, uint16_t seq,
uint32_t start_ntb, uint8_t collect_cnt, uint8_t collect_seq);
/**
* @brief broadcast cco's transformer ntb.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
* @param seq: packet sequence number.
* @param clct_cnt: collection count, include two edge data.
* @param clct_type: edge type, see IOT_PLC_ZC_CT_XXX_EDGE.
* @param collect_seq: collect sequence number.
* @param data: transformer feature data.
* @param data_len: data length.
*/
void iot_gw_handle_tsfm_detect_bcast_ntb(uint8_t intf_type, uint16_t seq,
uint8_t clct_cnt, uint8_t clct_type, uint8_t collect_seq,
iot_plc_zc_data_t *data, uint16_t data_len);
/**
* @brief query node transformer detect result.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
* @param msg_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_addr: mac address of the station, big-endian.
* @param seq: sequence number.
* @param phase: collect phase, see GW_APP_DATA_PHASE_XXX.
* @param collect_type:transformer feature collection type,
* see GW_APP_TSFM_COLLECT_XXX
* @param qr_sn: station transformer detect packet query sequence.
*/
void iot_gw_handle_tsfm_detect_query_result(uint8_t intf_type, uint8_t msg_type,
uint8_t *sta_addr, uint16_t seq, uint8_t phase, uint8_t collect_type,
uint8_t qr_sn);
/**
* @brief collect sec node transformer feature information.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
* @param msg_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_addr: mac address of the station, big-endian.
* @param seq: sequence number.
* @param phase: collect phase, see GW_APP_DATA_PHASE_XXX.
*/
void iot_gw_handle_tsfm_detect_feature_collect(uint8_t intf_type,
uint8_t msg_type, uint8_t *sta_addr, uint16_t seq, uint8_t phase);
/**
* @brief set node transformer detect transformer address.
* @param seq: sequence number.
* @param sta_addr: mac address of the station, big-endian.
* @param tsfm_addr: transformer address, big-endian.
* @param msg_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XXX.
*/
void iot_gw_handle_tsfm_detect_set_tsfm_addr(uint16_t seq, uint8_t *sta_addr,
uint8_t *tsfm_addr, uint8_t msg_type);
/**
* @brief delete node transformer detect transformer address.
* @param seq: sequence number.
* @param sta_addr: mac address of the station, big-endian.
* @param msg_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XXX.
*/
void iot_gw_handle_tsfm_detect_del_tsfm_addr(uint16_t seq, uint8_t *sta_addr,
uint8_t msg_type);
/**
* @brief query node module id info.
* @param intf_type: type of interface, see IOT_SG_CALLER_TYPE_XXX.
* @param msg_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_addr: mac address of the station, big-endian.
* @param seq: sequence number.
* @param qr_cnt: query count of the sta module id
*/
void iot_gw_handle_query_mod_id_info(uint8_t intf_type, uint8_t msg_type,
uint8_t *sta_addr, uint16_t seq, uint8_t qr_cnt);
/*
* @brief: send a start upgrading cmd to STA.
* @param upgrade_id: upgrading id.
* @param file_crc: crc of the upgrading file.
* @param file_len: length of the upgrading file.
* @param block_size: upgrading block size.
* @param dest_mac: mac address of the STA.
* @param msg_type: msg type.
* @param retry_cnt: retry count in mac layer.
* @param upgrade_win: time for upgrading, unit is minute.
*/
void iot_gw_cco_send_start_cmd(uint32_t upgrade_id, uint32_t file_crc,
uint32_t file_len, uint16_t block_size, uint8_t * dest_mac,
uint8_t msg_type, uint8_t retry_cnt, uint16_t upgrade_win);
/*
* @brief: send a query sta info command to STA.
* @param dest_mac: mac address of the STA.
* @param elements: elements to be queried, see GW_APP_STA_INFO_ID_XXX.
* @param e_count: count of elements
* @param retry_cnt: retry count in mac layer.
*/
void iot_gw_cco_upgrade_query_sta_info(uint8_t *dest_mac, uint8_t *elements,
uint32_t e_count, uint8_t retry_cnt);
/**
* @brief - send query status message to query sta upgrading status
* @param dest_mac: mac of STA to query upgrading status
* @param cnt: count of block to query
* @param start_index: start index of the block
* @param upgrade_id: upgrade id of this upgrade session
* @param retry_cnt: retry count in mac layer.
*/
void iot_gw_cco_upgrade_query_status(uint8_t *dest_mac, uint32_t cnt,
uint32_t start_idx, uint32_t upgrade_id, uint8_t retry_cnt);
/**
* @brief - send upgrading data block to a STA
* @param upgrade_id: the upgrade session id
* @param dest_sta_mac: mac address of the destination STA
* @param block_index: index of the block
* @param data: pointer to data buffer
* @param data_len: length of this upgrading data block
* @param msg_type: type of msg to be send
* @param sta_fwd: shall STA forward this msg as local broadcast
* @param retry_cnt: retry count in mac layer.
* @param bcast_tx_done_func: upgrade bcast tx done callback.
* @param p_info: cco upgrade info
*/
void iot_gw_cco_upgrade_send_data(uint32_t upgrade_id, uint8_t *dest_sta_mac,
uint32_t block_index, const uint8_t *data, uint32_t data_len,
uint8_t msg_type, uint8_t sta_fwd, uint8_t retry_cnt,
iot_pkt_free_func_t bcast_tx_done_func, iot_sg_cco_upgrade_t *p_info);
/**
* @brief - send stop upgrading command to a STA
* @param upgrade_id: the upgrade session id
* @param dest_sta_mac: mac address of the destination STA
* @param msg_type: type of msg to be send
* @param retry_cnt: retry count in mac layer.
*/
void iot_gw_cco_send_stop_upgrade_cmd(uint32_t upgrade_id, uint8_t *dest_mac,
uint8_t msg_type, uint8_t retry_cnt);
/**
* @brief - send execute upgrading command to a STA
* @param dest_mac: mac address of the destination STA
* @param reset_timeout: time to delay before the STA reset
* @param trail_run_timeout:duration that the STA shall trail run after reset
* @param msg_type: type of msg to be send
* @param retry_cnt: retry count in mac layer.
* @param bcast_tx_done_func: upgrade bcast tx done callback.
*/
void iot_gw_cco_upgrade_send_exe_cmd(uint8_t *dest_mac, uint16_t reset_timeout,
uint32_t trail_run_timeout, uint8_t msg_type, uint8_t retry_cnt,
iot_pkt_free_func_t bcast_tx_done_func);
/**
* @brief - bcast query low power meter.
* @param sn :sequence number.
* @param bm :sec node bitmap.
* @param bm_size :bitmap size.
* @param sta_cnt :sta count.
* @param lp_meter_cnt: low power meter count.
*/
void iot_gw_cco_lp_meter_bcast_qr(uint32_t sn, uint8_t *bm, uint16_t bm_size,
uint16_t sta_cnt, uint16_t lp_meter_cnt);
/**
* @brief - transformer detect lock time handle.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_addr: mac address of the station, only valid for unicast.
* @param sn :sequence number.
* @param net_lock_time :net lock time, uint is 1min.
* @param abn_lock_time :the lock time of abnormal leave net, uint is 1min.
* @param fn :set or query, see GW_APP_LOCK_TIME_FN_XXX.
*/
void iot_gw_cco_lock_time_handle(uint8_t send_type, uint8_t *sta_mac,
uint8_t sn, uint16_t net_lock_time, uint16_t abn_lock_time, uint8_t fn);
/**
* @brief - set lock time for zhejiang protocol.
*/
#define iot_gw_cco_lock_time_handle_set(send_type, sta_mac, sn, net_lock_time, \
abn_lock_time) \
iot_gw_cco_lock_time_handle(send_type, sta_mac, sn, net_lock_time, \
abn_lock_time, GW_APP_LOCK_TIME_FN_SET)
/**
* @brief - query lock time for zhejiang protocol.
*/
#define iot_gw_cco_lock_time_handle_qr(send_type, sta_mac, sn, net_lock_time, \
abn_lock_time) \
iot_gw_cco_lock_time_handle(send_type, sta_mac, sn, net_lock_time, \
abn_lock_time, GW_APP_LOCK_TIME_FN_QUERY)
/**
* @brief rtc timer synchronization.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX.
* @param sta_addr: mac address of the station, only valid for unicast.
* @param rtc_time: rtc time, bcd format, little endian.
* @param ntb_time: NTB time, unit is 1NTB.
*/
void iot_gw_cco_rtc_timer_sync(uint8_t send_type, uint8_t *sta_addr,
iot_sg_cco_time_t *rtc_time, uint32_t ntb_time);
/**
* @brief broadcast sta join certification state.
* @param check_enable: sta join certification state: 0 - disabled, 1 - enable.
*/
void iot_gw_cco_bcast_sta_join_check_state(uint8_t check_enable);
/**
* @brief check the node if is online.
* @param sta_mac: mac address of the station, big endian.
* @param sn: sequence number.
*/
void iot_gw_cco_node_call(uint8_t *sta_mac, uint16_t sn);
/**
* @brief configure abnormal electric current event report.
* @param sta_mac: mac address of the station, big endian.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX..
* @param cmd_type: cmd type, see GW_APP_ABNORMAL_NLI_CMD_XXX.
* @param enable: flag to mark if enable report.
*/
void iot_gw_cco_nli_abnormal_cfg(uint8_t *sta_mac, uint8_t send_type,
uint8_t cmd_type, uint8_t enable);
/**
* @brief set minute collection config information
* @param sta_mac: mac address of the station, big endian.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX..
* @param seq: sequence number.
* @param data_len: config data length.
* @param data: config data.
*/
void iot_gw_cco_min_clct2_cfg_set(uint8_t *sta_mac, uint8_t send_type,
uint16_t seq, uint16_t data_len, uint8_t *data);
/**
* @brief query minute collection config information
* @param sta_mac: mac address of the station, big endian.
* @param seq: sequence number.
*/
void iot_gw_cco_min_clct2_cfg_qry(uint8_t *sta_mac, uint16_t seq);
/**
* @brief set minute collection config information
* @param sta_mac: mac address of the station, big endian.
* @param send_type: indicate if the msg is bcast or unicast,
* see IOT_PLC_MSG_TYPE_XX..
* @param seq: sequence number.
* @param data_len: config data length.
* @param data: config data.
*/
void iot_gw_cco_min_clct2_con_mr(uint8_t *sta_mac, uint8_t send_type,
uint16_t seq, uint16_t data_len, uint8_t *data);
#else /* PLC_SUPPORT_CCO_ROLE && IOT_SMART_GRID_ENABLE && IOT_GW_APP_ENABLE */
void iot_gw_handle_comm_test(uint8_t intf_type, uint8_t *dev_mac,
uint8_t data_type, uint8_t *data, uint16_t len);
uint32_t iot_gw_cco_msdu_recv(uint8_t *src_sta_mac, uint8_t *data,
uint32_t msdu_len, iot_pkt_t *pkt, uint8_t is_bcast);
void iot_gw_handle_tsfm_detect_bcast_ntb(uint8_t intf_type, uint16_t seq,
uint8_t clct_cnt, uint8_t clct_type, uint8_t collect_seq,
iot_plc_zc_data_t *data, uint16_t data_len);
void iot_gw_handle_set_sta_clct_param(uint8_t intf_type, uint8_t send_type,
uint8_t *sta_mac, uint32_t sn, uint8_t proto_type);
uint32_t iot_gw_handle_set_sta_clct_param_v28(uint8_t intf_type, uint8_t send_type,
uint8_t *sta_mac, uint32_t sn, uint8_t task_id, uint8_t dev_type,
uint8_t *pm_mac);
#define iot_gw_handle_qry_sta_clct_data_v28(sta_mac, sn, task_id, proto_type, \
pm_type, pm_mac, year, month, day, hour, min, sec)
uint32_t iot_gw_send_query_sec_node_reg(uint8_t send_type, uint8_t *sta_addr,
uint8_t dev_type, uint8_t reg_param, uint32_t *qr_sn);
#define iot_gw_cco_query_meter_param(send_type, sta_mac, sn)
#define iot_gw_handle_read_meter(meter_mac, sta_mac, data_type, data, len, \
sn, read_type, retry_cnt, mr_cmd_tx_done_func, mr_entry)
#define iot_gw_handle_correct_time(intf_type, data, len, sta_mac)
#define iot_gw_handle_correct_time_ext(intf_type, data, len)
#define iot_gw_handle_accurate_correct_time(data, len, seq, sta_mac, ntb)
#define iot_gw_handle_clock_manager_corr_time(time_data)
#define iot_gw_handle_clock_manager(cmd_type, len, data, msg_type, sta_mac)
#define iot_gw_handle_clock_query(msg_type, sta_mac)
#define iot_gw_handle_correct_sta_time(intf_type, data, len)
#define iot_gw_handle_broadcast_data(if_type, data_type, data, len)
#define iot_gw_send_evt_rpt_ctrl(send_type, sta_mac, fn, start, sn, new_s, \
pm_addr)
#define iot_gw_send_evt_rpt_ctrl_en(send_type, sta_addr, new_s)
#define iot_gw_send_evt_rpt_ctrl_dis(send_type, sta_addr, new_s)
#define iot_gw_send_evt_rpt_rsp(sta_addr, rsp_type, sn, pm_addr)
#define iot_gw_send_start_sec_node_reg(send_type, sta_mac, new_s)
#define iot_gw_send_sec_node_net_lock_cmd(sta_addr, qr_sn, send_type)
#define iot_gw_send_sec_node_net_unlock_cmd(sta_addr, qr_sn, delay, \
send_type)
#define iot_gw_lp_meter_query_dev_type(sta_addr, qr_sn, inc_sn)
#define iot_gw_query_lp_meter_rssi(sta_addr, qr_sn, start_index, query_cnt, \
inc_sn)
#define iot_gw_send_query_lp_meter_read(send_type, sta_addr, reg_param, \
qr_sn, start_seq, query_cnt)
#define iot_gw_send_stop_sec_node_reg(intf_type)
#define iot_gw_send_query_sta_version(bcast_flag, sta_addr, sn)
#define iot_gw_cco_send_ctrl_proto(pkt, proto_type)
#define iot_gw_cco_send_ctrl_proto_passthrough(pkt)
#define iot_gw_handle_tsfm_detect_collect_ntb(intf_type, seq, start_ntb, \
collect_cnt, collect_seq)
#define iot_gw_handle_tsfm_detect_query_result(intf_type, msg_type, \
sta_addr, seq, phase, collect_type, qr_sn)
#define iot_gw_handle_tsfm_detect_feature_collect(intf_type, msg_type, \
sta_addr, seq, phase)
#define iot_gw_handle_tsfm_detect_set_tsfm_addr(seq, sta_addr, tsfm_addr, \
msg_type)
#define iot_gw_handle_tsfm_detect_del_tsfm_addr(seq, sta_addr, msg_type)
#define iot_gw_handle_query_mod_id_info(intf_type, msg_type, sta_addr, seq, \
qr_cnt)
#define iot_gw_cco_send_start_cmd(upgrade_id, file_crc, file_len, \
block_size, dest_mac, msg_type, retry_cnt, upgrade_win)
#define iot_gw_cco_upgrade_query_sta_info(dest_mac, elements, e_count, \
retry_cnt)
#define iot_gw_cco_upgrade_query_status(dest_mac, cnt, start_idx, \
upgrade_id, retry_cnt)
#define iot_gw_cco_upgrade_send_data(upgrade_id, dest_sta_mac, block_index, \
data, data_len, msg_type, sta_fwd, retry_cnt, bcast_tx_done_func, p_info)
#define iot_gw_cco_send_stop_upgrade_cmd(upgrade_id, dest_mac, msg_type, \
retry_cnt)
#define iot_gw_cco_upgrade_send_exe_cmd(dest_mac, reset_timeout, \
trail_run_timeout, msg_type, retry_cnt, bcast_tx_done_func)
#define iot_gw_cco_lp_meter_bcast_qr(sn, bm, bm_size, sta_cnt, lp_meter_cnt)
#define iot_gw_cco_lock_time_handle(send_type, sta_mac, sn, net_lock_time, \
abn_lock_time, fn)
#define iot_gw_cco_lock_time_handle_set(send_type, sta_mac, sn, net_lock_time, \
abn_lock_time)
#define iot_gw_cco_lock_time_handle_qr(send_type, sta_mac, sn, net_lock_time, \
abn_lock_time)
#define iot_gw_cco_rtc_timer_sync(send_type, sta_addr, rtc_time, ntb_time)
#define iot_gw_cco_bcast_sta_join_check_state(check_enable)
#define iot_gw_cco_node_call(sta_mac, sn)
#define iot_gw_cco_nli_abnormal_cfg(sta_mac, send_type, cmd_type, enable)
#define iot_gw_cco_min_clct2_cfg_set(sta_mac, send_type, seq, data_len, data)
#define iot_gw_cco_min_clct2_cfg_qry(sta_mac, seq)
#define iot_gw_cco_min_clct2_con_mr(sta_mac, send_type, seq, data_len, data)
#endif /* PLC_SUPPORT_CCO_ROLE && IOT_SMART_GRID_ENABLE && IOT_GW_APP_ENABLE */
#ifdef __cplusplus
}
#endif
#endif /* IOT_GW_APP_CCO_H */