Files
kunlun/export/inc/cli/iot_cli_sg_api.h
2024-09-28 14:24:04 +08:00

680 lines
25 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_SG_API_H
#define IOT_CLI_SG_API_H
#include "os_types_api.h"
#include "iot_pkt_api.h"
#include "iot_utils_api.h"
#include "iot_config_api.h"
#ifdef __cplusplus
extern "C" {
#endif
#if (PLC_SUPPORT_CCO_ROLE || \
((IOT_STA_CONTROL_MODE == IOT_STA_CONTROL_TYPE_STA) && \
(IOT_SG_CONTROLLER_ENABLE == 1)) || IOT_SMART_CONFIG)
/* cli and sg Transmission channel */
#define IOT_CLI_SG_INTERFACE_ENABLE 1
#else
#define IOT_CLI_SG_INTERFACE_ENABLE 0
#endif
#pragma pack(push) /* save the pack status */
#pragma pack(1) /* 1 byte align */
/* message id used for cli report message to sg */
#define IOT_CLI_SG_MSG_START_METER_LIST (0x1)
#define IOT_CLI_SG_MSG_STOP_METER_LIST (0x2)
#define IOT_CLI_SG_MSG_GET_METER_LIST (0x3)
#define IOT_CLI_SG_MSG_QUERY_WL_STATE (0x4)
#define IOT_CLI_SG_MSG_QUERY_WL (0x5)
#define IOT_CLI_SG_MSG_ADD_WL (0x6)
#define IOT_CLI_SG_MSG_RM_WL (0x7)
#define IOT_CLI_SG_MSG_SET_WL_STATE (0x8)
#define IOT_CLI_SG_MSG_GET_METER (0x9)
#define IOT_CLI_SG_MSG_QUERY_UPGRADE_STATUS (0xA)
#define IOT_CLI_SG_MSG_QUERY_UPGRADE_PROGRESS (0xB)
#define IOT_CLI_SG_MSG_SET_TSFM_DETECT_STATE (0xC)
#define IOT_CLI_SG_MSG_QUERY_TSFM_DETECT_STATE (0xD)
#define IOT_CLI_SG_MSG_HANDLE_USER_DATA (0xE)
#define IOT_CLI_SG_MSG_SET_EVENT_RPT_ENABLED (0xF)
#define IOT_CLI_SG_MSG_GET_RT_METER (0x10)
#define IOT_CLI_SG_MSG_SET_CCTT_DATA_ENABLED (0x11)
#define IOT_CLI_SG_MSG_SET_CON_MR_PARAM (0x12)
#define IOT_CLI_SG_MSG_QUERY_CON_MR_PARAM (0x13)
#define IOT_CLI_SG_MSG_PLC_MGR_STATE_CHANGE (0x14)
#define IOT_CLI_SG_MSG_GET_REPORT_ACK (0x15)
#define IOT_CLI_SG_MSG_BD_START (0x16)
#define IOT_CLI_SG_MSG_BD_QUERY_STATE (0x17)
#define IOT_CLI_SG_MSG_BD_QUERY_RESULT (0x18)
#define IOT_CLI_SG_MSG_SET_ESP (0x19)
#define IOT_CLI_SG_MSG_QUERY_ESP (0x1A)
#define IOT_CLI_SG_MSG_QUERY_NODE_INFO (0x1B)
#define IOT_CLI_SG_MSG_SEND_BROADCAST_DATA (0x1C)
#define IOT_CLI_SG_MSG_SET_MAC (0x1D)
#define IOT_CLI_SG_TRANS_LOCAL_PROTO_DATA (0x1E)
/* message id used for sg report message to cli */
#define IOT_CLI_SG_MSG_RPT_START_METER_LIST (0x1)
#define IOT_CLI_SG_MSG_RPT_STOP_METER_LIST (0x2)
#define IOT_CLI_SG_MSG_RPT_SEARCH_METER_DONE (0x3)
#define IOT_CLI_SG_MSG_RPT_METER_LIST (0x4)
#define IOT_CLI_SG_MSG_RPT_WL_STATE (0x5)
#define IOT_CLI_SG_MSG_RPT_WL (0x6)
#define IOT_CLI_SG_MSG_RPT_ADD_WL (0x7)
#define IOT_CLI_SG_MSG_RPT_RM_WL (0x8)
#define IOT_CLI_SG_MSG_RPT_SET_WL_STATE (0x9)
#define IOT_CLI_SG_MSG_PRT_SEARCH_METER_LIST (0xA)
#define IOT_CLI_SG_MSG_PRT_METER (0xB)
#define IOT_CLI_SG_MSG_PRT_METER_DATA (0xC)
#define IOT_CLI_SG_MSG_PRT_UPGRADE_STATUS (0xD)
#define IOT_CLI_SG_MSG_PRT_UPGRADE_PROGRESS (0xE)
#define IOT_CLI_SG_MSG_RPT_EVT_DATA (0xF)
#define IOT_CLI_SG_MSG_RPT_SET_TSFM_DETECT_STATE (0x10)
#define IOT_CLI_SG_MSG_RPT_TSFM_DETECT_STATE (0x11)
#define IOT_CLI_SG_MSG_RPT_USER_DATA (0x12)
#define IOT_CLI_SG_MSG_RPT_SET_EVENT_RPT_ENABLED (0x13)
#define IOT_CLI_SG_MSG_PRT_RT_REQ_MR_DATA (0x14)
#define IOT_CLI_SG_MSG_RPT_SET_CCTT_DATA_ENABLED (0x15)
#define IOT_CLI_SG_MSG_RPT_SET_CON_MR_PARAM (0x16)
#define IOT_CLI_SG_MSG_RPT_QUERY_CON_MR_PARAM (0x17)
#define IOT_CLI_SG_MSG_RPT_CONFIG_INFO (0x18)
#define IOT_CLI_SG_MSG_RPT_BD_START (0x19)
#define IOT_CLI_SG_MSG_RPT_BD_QUERY_STATE (0x1A)
#define IOT_CLI_SG_MSG_RPT_BD_QUERY_RESULT (0x1B)
#define IOT_CLI_SG_MSG_RPT_ESP_RESULT (0x1C)
#define IOT_CLI_SG_MSG_RPT_NODE_INFO (0x1D)
#define IOT_CLI_SG_MSG_RPT_SEND_BROADCAST_DATA (0x1E)
#define IOT_CLI_SG_MSG_RPT_MAC (0x1F)
#define IOT_CLI_SG_MSG_RPT_LOCAL_PROTO_DATA (0x20)
/* Message request identification */
#define IOT_CLI_SG_REQ_ID_DEFAULT (0x0)
/* sg register cli interface result */
#define IOT_CLI_SG_REGISTER_SUCCESS (0x0)
#define IOT_CLI_SG_REGISTER_FAILURE (0x1)
/* meter communication protocol on plc */
#define IOT_CLI_SG_PROTO_TYPE_RAW_DATA (0x00)
#define IOT_CLI_SG_PROTO_TYPE_645_1997 (0x01)
#define IOT_CLI_SG_PROTO_TYPE_645_2007 (0x02)
#define IOT_CLI_SG_PROTO_TYPE_698 (0x03)
/* meter device type on plc */
#define IOT_CLI_SG_DEVICE_TYPE_COLLECTOR (0)
#define IOT_CLI_SG_DEVICE_TYPE_STA (1)
/* always disable white list */
#define IOT_CLI_SG_WL_STATE_DISABLE (0)
/* always enable white list */
#define IOT_CLI_SG_WL_STATE_ENABLE (1)
/* if cctt and meter entry exist, enable white list,
* else disable white list.
*/
#define IOT_CLI_SG_WL_STATE_AUTO (2)
/* route meter reading action */
/* start route meter read */
#define IOT_CLI_SG_RT_START_MR_CMD (1)
/* running route meter read */
#define IOT_CLI_SG_RT_RUNNING_MR_CMD (2)
/* stop route meter read */
#define IOT_CLI_SG_RT_STOP_MR_CMD (3)
/* reserved length of the data */
#define IOT_CLI_SG_RSVD_LEN (16)
/** extention cli error is based on the common error in iot_errno_api.h */
#define EXTEN_CLI_ERRNO_BASE (0x80)
/** errno report to plc manager */
/** exceed support count for devices */
#define EXCEED_DEV_MAX_CONCURRENT_COUNT (EXTEN_CLI_ERRNO_BASE + 0x01)
/** exceed support pkt count for devices */
#define EXCEED_DEV_PKT_COUNT (EXTEN_CLI_ERRNO_BASE + 0x02)
#define IOT_CLI_SG_RSVD_RSP (1)
#define IOT_CLI_SG_MR_DATA_RSP (2)
#define IOT_CLI_SG_EVT_DATA_RSP (3)
#define IOT_CLI_SG_SEC_NODE_REG_DATA_RSP (4)
/* branch detect state */
#define IOT_CLI_SG_BD_CLEAR (0)
#define IOT_CLI_SG_BD_SHOOT (1)
#define IOT_CLI_SG_BD_TOPO_GEN (2)
#define IOT_CLI_SG_BD_DONE (3)
/* branch detect node special father index */
#define IOT_CLI_SG_BD_FATHER_CCO (0)
#define IOT_CLI_SG_BD_FATHER_INVALID (0xFFFF)
/* device type */
#define IOT_CLI_SG_DEV_TYPE_POWER_METER (1)
#define IOT_CLI_SG_DEV_TYPE_POWER_METER_3P (2)
#define IOT_CLI_SG_DEV_TYPE_SWITCH_MONITOR (3)
#define IOT_CLI_SG_DEV_TYPE_TSFM_MONITOR (4)
#define IOT_CLI_SG_DEV_TYPE_BRK_MONITOR (5)
#define IOT_CLI_SG_MODULE_ID_LEN (11)
/* node info report max count */
#define IOT_CLI_SG_NODE_RPT_MAX_CNT (64)
/** cli and sg transfer data msg header */
typedef struct _iot_cli_sg_msg_header {
/** msg id */
uint8_t msg_id;
/** request id */
uint8_t req_id;
/** reserved for future */
uint16_t reserved;
} iot_cli_sg_msg_header_t;
/**
* @brief (*iot_cli_sg_recv_func_t)() - callback to receive event from
* cli host.
* @param param: parameter registered in iot_cli_sg_interface_register
* @param pkt: buffer to store the event detail, application should call
* iot_free_pkt function ASAP to free the iot_pkt_t. it's very
* scarce resource.
*/
typedef void(*iot_cli_sg_recv_func_t)(void *param, iot_pkt_t *pkt);
/** sg config */
typedef struct _iot_cli_sg_config {
uint8_t proto;
} iot_cli_sg_config_t;
/** sg result */
typedef struct _iot_cli_sg_result {
/** see ERR_XXX */
uint32_t result;
} iot_cli_sg_result_t;
typedef struct _iot_cli_sg_interface {
/** callback to receive event from cli host */
iot_cli_sg_recv_func_t recv;
/** parameter that will be transferred back alone with the callback */
void *param;
} iot_cli_sg_interface_t;
/** report data that from meter */
typedef struct _iot_cli_sg_rpt_mr_data_ul {
/** reserved space for future use. */
uint8_t reserved[IOT_CLI_SG_RSVD_LEN];
/** ack of the meter reading */
uint8_t result;
/** pm proto type : 645 698 and so on */
uint8_t proto_type;
/** pm mac address */
uint8_t mac[IOT_MAC_ADDR_LEN];
/** packet serial number */
uint8_t sn;
/** length of the data variable */
uint16_t datalen;
/** pm effective data up link */
uint8_t data[0];
} iot_cli_sg_rpt_mr_data_ul;
/** read meter type - cctt active read meter from plc manager down link */
typedef struct _iot_cli_sg_rpt_mr_data_dl {
/** reserved space for future use. */
uint8_t reserved[IOT_CLI_SG_RSVD_LEN];
/** cctt active read meter or cctt active concurrently read meter */
uint8_t mr_type;
/** pm proto type : 645 698 and so on */
uint8_t proto_type;
/** pm mac address */
uint8_t mac[IOT_MAC_ADDR_LEN];
/** packet serial number */
uint8_t sn;
/** length of the data variable */
uint16_t data_len;
/** cli effective data down link */
uint8_t data[0];
} iot_cli_sg_rpt_mr_data_dl;
/** request route meter reading data up link */
typedef struct _iot_cli_sg_requst_rt_mr_data_ul {
/** reserved space for future use. */
uint8_t reserved[IOT_CLI_SG_RSVD_LEN];
/** packet serial number */
uint8_t sn;
/** 0 - complete meter reading, 1 - request reading data */
uint8_t opt_flag;
/** pm phase msg */
uint8_t phase;
/** pm mac address */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/** secondary node index */
uint16_t node_index;
}iot_cli_request_rt_mr_data_ul;
/** read meter type - cctt active route read meter from plc manager down link */
typedef struct _iot_cli_sg_rpt_rt_mr_data_dl {
/** reserved space for future use. */
uint8_t reserved[IOT_CLI_SG_RSVD_LEN];
/**
* operate flag
* 0 invalid
* others : see IOT_CLI_SG_RT_XX_MR_CMD
*/
uint8_t action;
/** read flag - 0 read fail 1 read successful 2 ready read */
uint8_t read_flag;
/** pm proto type : 645 698 and so on */
uint8_t proto_type;
/** pm mac address */
uint8_t mac[IOT_MAC_ADDR_LEN];
/** packet serial number */
uint8_t sn;
/** length of the data variable */
uint8_t data_len;
/** cli down effective data */
uint8_t data[0];
} iot_cli_sg_rpt_rt_mr_data_dl;
/** report ack - report ack from plc manager down link */
typedef struct _iot_cli_sg_rpt_ack_dl {
/** reserved space for future use. */
uint8_t reserved[IOT_CLI_SG_RSVD_LEN];
/**
* ack type: IOT_BUF_DT_XX
* for example: IOT_BUF_DT_SG_METER_DATA,IOT_BUF_DT_EVT_RPT...
*/
uint8_t type;
/** result : see ERR_XX */
uint32_t result;
/** packet serial number */
uint8_t sn;
} iot_cli_sg_rpt_ack_dl_t;
/** request upgrade progress */
typedef struct _iot_cli_sg_upgrade_progress_dl {
uint16_t start_index;
uint16_t dst_num;
} iot_cli_sg_upgrade_progress_dl;
/** start sec node reg */
typedef struct _iot_cli_sg_start_sec_node_reg_dl {
/** reserved space for future use. */
uint8_t reserved[IOT_CLI_SG_RSVD_LEN];
/** sec node registration duration. unit is 1 min. */
uint16_t duration;
} iot_cli_sg_start_sec_node_reg_dl_t;
typedef struct _iot_cli_sg_get_sec_node_info_dl {
/** query start node index */
uint16_t sec_node_start_index;
/** query node count */
uint8_t sec_node_count;
} iot_cli_sg_get_sec_node_info_dl_t;
/** sec node info */
typedef struct _iot_cli_sg_sec_node_info {
/** meter mac address */
uint8_t meter_mac[IOT_MAC_ADDR_LEN];
/** station mac address */
uint8_t sta_mac[IOT_MAC_ADDR_LEN];
/** proto type, see IOT_CLI_SG_PROTO_TYPE_xxx */
uint8_t proto_type :4,
/** device type, see IOT_CLI_SG_DEVICE_TYPE_xxx */
dev_type :4;
} iot_cli_sg_sec_node_info_t;
/** sec node info report */
typedef struct _iot_cli_sg_rpt_sec_node_info_ul {
/** reserved space for future use. */
uint8_t reserved[IOT_CLI_SG_RSVD_LEN];
/** data serial number */
uint8_t sn;
/** this time report node total count */
uint16_t sec_node_count;
/** this time report node count */
uint8_t rsp_sec_node_count;
/** sec node information */
iot_cli_sg_sec_node_info_t node_info[0];
} iot_cli_sg_rpt_sec_node_info_ul_t;
/** wl node info */
typedef struct _iot_cli_sg_node_info {
/** mac address of secondary node */
uint8_t mac[IOT_MAC_ADDR_LEN];
/** protocol the node supports, see IOT_CLI_SG_PROTO_TYPE_xxx */
uint8_t proto_type;
} iot_cli_sg_node_info_t;
/** query white list */
typedef struct _iot_cli_sg_query_wl {
/** query start node index */
uint16_t start_index;
/** query node count */
uint16_t count;
} iot_cli_sg_query_wl_t;
typedef struct _iot_cli_sg_rpt_wl {
/** report node total count */
uint16_t total_count;
/** this time report node count */
uint8_t rsp_count;
/** sec node information */
iot_cli_sg_node_info_t node_info[0];
} iot_cli_sg_rpt_wl_t;
/** add wl */
typedef struct _iot_cli_sg_add_wl {
/** count of meter mac */
uint8_t count;
/** info of node for wl operation */
iot_cli_sg_node_info_t node_info[0];
} iot_cli_sg_add_wl_t;
/** rm wl */
typedef struct _iot_cli_sg_rm_wl {
/** count of meter mac */
uint8_t count;
/** mac address array */
uint8_t mac_addr[0][IOT_MAC_ADDR_LEN];
} iot_cli_sg_rm_wl_t;
/** set white list state */
typedef struct _iot_cli_sg_set_wl_state {
/** white list state, see IOT_CLI_SG_WL_STATE_XXX */
uint8_t state;
} iot_cli_sg_set_wl_state_t;
/** white list state */
typedef struct _iot_cli_sg_rpt_wl_state {
/** white list state, see IOT_CLI_SG_WL_STATE_XXX */
uint8_t state;
} iot_cli_sg_rpt_wl_state_t;
/** report event data */
typedef struct _iot_cli_sg_rpt_evt_data {
/** data serial number */
uint8_t sn;
/** device type, see IOT_SG_CCO_DEV_TYPE_XXX. */
uint8_t dev_type;
/** protocol type, see PROTO_TYPE_XXX */
uint8_t proto_type;
/** data len */
uint16_t data_len;
/** event data */
uint8_t data[0];
} iot_cli_sg_rpt_evt_data_t;
/* recv cli user data */
typedef struct _iot_cli_sg_user_data_dl {
/** source mac the data come from */
uint8_t src_mac[IOT_MAC_ADDR_LEN];
/** data len */
uint16_t data_len;
/** data */
uint8_t data[0];
} iot_cli_sg_user_data_dl_t;
/** send user data */
typedef struct _iot_cli_sg_send_user_data {
/** target mac */
uint8_t target_mac[IOT_MAC_ADDR_LEN];
/** data len */
uint16_t data_len;
/** data */
uint8_t data[0];
} iot_cli_sg_send_user_data_t;
/** cco event enabled setting down link */
typedef struct _iot_cli_sg_set_event_enabled_dl {
/** enable event report sw */
uint8_t event_enabled;
} iot_cli_sg_set_event_enabled_t;
/** cco don't deal with data from cctt */
typedef struct _iot_cli_sg_set_cctt_data_enabled_dl {
/** do deal with cctt data */
uint8_t cctt_data_enabled;
} iot_cli_sg_set_cctt_data_enabled_t;
/** set transformer detect state */
typedef struct _iot_cli_sg_set_tsfm_detect_state {
/** transformer detect state, 0 - disabled, 1 - enabled */
uint8_t tsfm_detect_state;
/** station lock, 0 - unlock station, 1 - lock station */
uint8_t sta_lock;
} iot_cli_sg_set_tsfm_detect_state_t;
/** query transformer detect state */
typedef struct _iot_cli_sg_rpt_tsfm_detect_state {
/** transformer detect state, 0 - disabled, 1 - enabled */
uint8_t tsfm_detect_state;
/** station lock, 0 - unlock station, 1 - lock station */
uint8_t sta_lock;
/** transformer detect progress, 0 - done, 1- doing */
uint8_t tsfm_detect_progress;
} iot_cli_sg_rpt_tsfm_detect_state_t;
/** concurrence meter reading param */
typedef struct _iot_cli_sg_con_mr_param {
/** default meter reading timeout, unit is 1s.
* for cco set sec node max timeout before. the min value is 20.
* 0 means doesn't change the value.
*/
uint8_t sec_node_monitor_timeout;
/** bcast meter reading max concurrent count.
* 0 means doesn't change the value.
*/
uint8_t max_bcast_con_count;
} iot_cli_sg_con_mr_param_t;
/** cli notify plc mgr state to sg */
typedef struct _iot_cli_sg_plc_mgr_state_change {
/** new state of plc mgr */
uint8_t state;
} iot_cli_sg_plc_mgr_state_change_t;
/** start or stop branch detect */
typedef struct _iot_cli_sg_bd_start {
/** 0 - stop, 1 - start */
uint8_t value;
} iot_cli_sg_bd_start_t;
/** branch detect node information */
typedef struct _iot_cli_sg_bd_node_info {
/** node index */
uint16_t index;
/** node mac address, little-endian */
uint8_t mac[IOT_MAC_ADDR_LEN];
/** device type, see IOT_CLI_SG_DEV_TYPE_XXX */
uint8_t dev_type;
/** father index, special father index see IOT_CLI_SG_BD_FATHER_XXX */
uint16_t father_index;
/** reserved for future */
uint8_t rsvd[6];
} iot_cli_sg_bd_node_info_t;
/** branch detect query result */
typedef struct _iot_cli_sg_bd_query_ret {
/** start index, value range: 1 - 65535 */
uint16_t start_index;
/** query count */
uint8_t count;
} iot_cli_sg_bd_query_ret_t;
/** branch detect result report */
typedef struct _iot_cli_sg_bd_ret_rpt {
/** total node count */
uint16_t total_cnt;
/** start index, value range */
uint16_t start_index;
/** report node count */
uint8_t rpt_cnt;
/** node information */
iot_cli_sg_bd_node_info_t node_info[0];
} iot_cli_sg_bd_ret_rpt_t;
/** report branch detect state */
typedef struct _iot_cli_sg_bd_rpt_state {
/** branch detect state, see IOT_CLI_SG_BD_XXX */
uint16_t state;
} iot_cli_sg_bd_rpt_state_t;
/** set cco esp */
typedef struct _iot_cli_sg_set_esp {
/** equipment service provider, see IOT_SG_CCO_ESP_XXX */
uint8_t esp;
} iot_cli_sg_set_esp_t;
/** report cco esp */
typedef struct _iot_cli_sg_rpt_esp {
/** equipment service provider, see IOT_SG_CCO_ESP_XXX */
uint8_t esp;
} iot_cli_sg_rpt_esp_t;
/** query node id information */
typedef struct _iot_cli_sg_qr_node_info_dl {
/** start index, value range: 1 - 65535 */
uint16_t start_index;
/** query count */
uint8_t count;
} iot_cli_sg_qr_node_info_dl_t;
typedef struct _iot_cli_sg_node_detail_info {
/** address, little - endian */
uint8_t addr[IOT_MAC_ADDR_LEN];
/** module id */
uint8_t module_id[IOT_CLI_SG_MODULE_ID_LEN];
/** phase that device is connected to.
* bit0 set to 1 means device is connected to phase A.
* bit1 set to 1 means device is connected to phase B.
* bit2 set to 1 means device is connected to phase C.
*/
uint8_t phase :3,
/** power meter type, 0: single phase, 1: three phase */
pm_type :1,
/** flag to mark if opposite phase
* 0: line normal or not support identification.
* 1: line abnormal.
* it means neutral wire and live wire reversed when pm type is single
* phase.
* it means reverse phase sequence when pm type is three phase.
*/
opposite_phase :1,
/** phase type of three phase meter, see IOT_SG_CCO_PHASE_SEQ_XXX */
phase_type :3;
/** reserved */
uint8_t rsvd[11];
} iot_cli_sg_node_detail_info_t;
/** report node id information */
typedef struct _iot_cli_sg_qr_node_info_ul {
/** total node count */
uint16_t total_cnt;
/** start index, value range */
uint16_t start_index;
/** report node count */
uint8_t rpt_cnt;
/** node information */
iot_cli_sg_node_detail_info_t node_info[0];
} iot_cli_sg_qr_node_info_ul_t;
/** send boardcast data dl */
typedef struct _iot_cli_sg_send_broadcast_data_dl {
/** data proto type */
uint8_t proto_type;
/** reserved */
uint8_t rsvd[15];
/** broadcast data length */
uint16_t len;
/** broadcast data */
uint8_t data[0];
} iot_cli_sg_send_broadcast_data_dl;
/** set mac addr dl */
typedef struct _iot_cli_sg_set_mac_dl {
/** new mac */
uint8_t mac[IOT_MAC_ADDR_LEN];
} iot_cli_sg_set_mac_dl_t;
typedef struct _iot_cli_sg_trans_local_proto_data_dl {
/* reserved */
uint8_t rsvd[4];
/* trans data len */
uint16_t data_len;
/* 376.2 data */
uint8_t data[0];
} iot_cli_sg_trans_local_proto_data_dl_t;
typedef struct _iot_cli_sg_resp_local_proto_data_ul {
/* response data len */
uint16_t date_len;
/* response data */
uint8_t data[0];
} iot_cli_sg_resp_local_proto_data_ul_t;
#if IOT_CLI_SG_INTERFACE_ENABLE
/**
* @brief iot_cli_sg_get_headroom_req() - when sg transter iot_pkt_t to cli
* that the iot_pkt_t need reserve some
* space in iot_pkt_t head part.
* @return: the space size to be reserved.
*/
uint8_t iot_cli_sg_get_headroom_req();
/**
* @brief iot_cli_sg_interface_register() - register smart grid interface to
* cli module.
* @param cli_interface: smart grid interface.
* @return: register result, see IOT_CLI_SG_REG_xxx.
*/
uint32_t iot_cli_sg_interface_register(iot_cli_sg_interface_t *cli_interface);
/**
* @brief iot_cli_sg_send_data_to_cli_interface() - sg send data to cli
* interface.
* @param pkt: meter list data.
* @param msg_id: the data identify
* @param req_id: request id
*/
void iot_cli_sg_send_data_to_cli_interface(iot_pkt_t *pkt, uint8_t msg_id,
uint8_t req_id);
#else
#define iot_cli_sg_get_headroom_req() (0)
#define iot_cli_sg_interface_register(cli_interface) \
IOT_CLI_SG_REGISTER_FAILURE
#define iot_cli_sg_send_data_to_cli_interface(pkt, msg_id, req_id) IOT_ASSERT(0)
#endif
#pragma pack(pop) /* restore the pack status */
/* reserved for cli channel header. */
#define IOT_SG_CLI_CHANNEL_HEADROOM \
(sizeof(iot_cli_sg_resp_local_proto_data_ul_t) + \
sizeof(iot_cli_sg_msg_header_t))
#ifdef __cplusplus
}
#endif
#endif /* IOT_CLI_SG_API_H */