2028 lines
69 KiB
C
2028 lines
69 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 PROTO_NW_APP_H
|
|
#define PROTO_NW_APP_H
|
|
|
|
#include "os_types_api.h"
|
|
#include "iot_utils_api.h"
|
|
#include "iot_config_api.h"
|
|
#include "proto_645.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* pack for the structures in the whole file */
|
|
#pragma pack(push) /* save the pack status */
|
|
#pragma pack(1) /* 1 byte align */
|
|
|
|
/* south power grid application protocol frame type field definitions */
|
|
#define NW_APP_FRAME_TYPE_ACK_NACK (0x00)
|
|
#define NW_APP_FRAME_TYPE_DATA_FWD (0x01)
|
|
#define NW_APP_FRAME_TYPE_CMD (0x02)
|
|
#define NW_APP_FRAME_TYPE_RPT (0x03)
|
|
#define NW_APP_FRAME_TYPE_CTRL (0x04)
|
|
#define NW_APP_FRAME_TYPE_BCAST_CMD (0x05)
|
|
#define NW_APP_FRAME_TYPE_ROUTE_FWD (0x06)
|
|
#define NW_APP_FRAME_TYPE_CUSTOM (0x0E)
|
|
#define NW_APP_FRAME_TYPE_PT (0x0F)
|
|
|
|
/* south power grid application protocol work type definitions */
|
|
/* confirm/denial */
|
|
#define NW_APP_WORK_ACK (0x00)
|
|
#define NW_APP_WORK_NACK (0x01)
|
|
/* data forwarding */
|
|
#define NW_APP_WORK_DATA_FWD_TRANSPARENT (0x00)
|
|
#define NW_APP_WORK_DATA_FWD_TRANS_MODULE (0x01)
|
|
/* command */
|
|
#define NW_APP_WORK_CMD_QUERY_SEARCH_METER_RESULT (0x00)
|
|
#define NW_APP_WORK_CMD_DL_SEARCH_METER_LIST (0x01)
|
|
#define NW_APP_WORK_CMD_FILE_TRANSFER (0x02)
|
|
#define NW_APP_WORK_CMD_SEC_NODE_EVT (0x03)
|
|
#define NW_APP_WORK_CMD_SEC_NODE_REBOOT (0x04)
|
|
#define NW_APP_WORK_CMD_SEC_NODE_INFO_QUERY (0x05)
|
|
#define NW_APP_WORK_CMD_DL_ADDR_MAP_LIST (0x06)
|
|
#define NW_APP_WORK_CMD_SEC_NODE_ID_QUERY (0x10)
|
|
#define NW_APP_WORK_CMD_SEC_NODE_NET_QUERY (0x11)
|
|
#define NW_APP_WORK_CMD_PM_SCORE_QUERY (0x20)
|
|
#define NW_APP_WORK_CMD_TSFM (0x21)
|
|
#define NW_APP_WORK_CMD_EDGE_COMPUTING (0xA0)
|
|
#define NW_APP_WORK_CMD_COMM_TEST (0xF0)
|
|
/* command for guangdong protocol */
|
|
#define NW_APP_WORK_CMD_RUN_STATE_QUERY (0x07)
|
|
#define NW_APP_WORK_CMD_NEIGHBOUR_QUERY (0x08)
|
|
#define NW_APP_WORK_CMD_TSFM_GD (0x10)
|
|
#define NW_APP_WORK_CMD_CLCT_INIT (0x20)
|
|
#define NW_APP_WORK_CMD_CLCT_ADD (0x21)
|
|
#define NW_APP_WORK_CMD_CLCT_DEL (0x22)
|
|
#define NW_APP_WORK_CMD_CLCT_ID_QUERY (0x23)
|
|
#define NW_APP_WORK_CMD_CLCT_INFO_QUERY (0x24)
|
|
#define NW_APP_WORK_CMD_CLCT_DATA_QUERY (0x25)
|
|
#define NW_APP_WORK_CMD_CORRECT (0x30)
|
|
/* ctrl for guangdong protocol */
|
|
#define NW_APP_WORK_CTRL_PROTO (0x00)
|
|
#define NW_APP_WORK_CTRL_PASSTHROUGH (0x01)
|
|
/* event report */
|
|
#define NW_APP_WORK_RPT_EVT_RPT (0x00)
|
|
/* event report for guangdong protocol */
|
|
#define NW_APP_WORK_RPT_POWER_RPT (0x01)
|
|
#define NW_APP_WORK_RPT_DEV_RPT (0x02)
|
|
#define NW_APP_WORK_RPT_EDGE_COMPUTING (0x40)
|
|
|
|
/* expand the defined work id for SPG production testing system.
|
|
*/
|
|
#define NW_APP_WORT_ID_PT_SET_MAC (0x04)
|
|
#define NW_APP_WORT_ID_PT_QR_MAC (0x05)
|
|
#define NW_APP_WORT_ID_PT_READ_VER (0x3B)
|
|
|
|
/* vendor information flag */
|
|
#define NW_APP_CONTROL_NO_VENDOR_INFO (0x00)
|
|
#define NW_APP_CONTROL_VENDOR_INFO (0x01)
|
|
|
|
/* route fwd work id */
|
|
#define NW_APP_ROUTE_FWD_DATA (0x00)
|
|
|
|
/* respond flag */
|
|
#define NW_APP_CONTROL_NO_NEED_RSP (0x00)
|
|
#define NW_APP_CONTROL_NEED_RSP (0x01)
|
|
|
|
/* start flag */
|
|
#define NW_APP_CONTROL_PRM_MASTER (0x01)
|
|
#define NW_APP_CONTROL_PRM_SLAVE (0x00)
|
|
|
|
/* dir flag */
|
|
#define NW_APP_CONTROL_DOWN_LINK (0x00)
|
|
#define NW_APP_CONTROL_UP_LINK (0x01)
|
|
|
|
/* nw frame priority definition */
|
|
#define NW_APP_PRIO_ACK_NACK 3
|
|
#define NW_APP_PRIO_TASK 3
|
|
#define NW_APP_PRIO_CLCT_TASK 3
|
|
#define NW_APP_PRIO_CORRECTING_TIME 3
|
|
#define NW_APP_PRIO_QUERY_SM_RESULT 2
|
|
#define NW_APP_PRIO_DL_METER_LIST 3
|
|
#define NW_APP_PRIO_DL_ADDR_MAP_LIST 3
|
|
#define NW_APP_PRIO_FILE_TRANS 2
|
|
#define NW_APP_PRIO_SEC_NODE_EVT_EN 3
|
|
#define NW_APP_PRIO_SEC_NODE_REBOOT 2
|
|
#define NW_APP_PRIO_QUERY_SEC_NODE_INFO 3
|
|
#define NW_APP_PRIO_TSFM_DETECT 3
|
|
#define NW_APP_PRIO_COMM_TEST 2
|
|
#define NW_APP_PRIO_DEFAULT 2
|
|
|
|
/* nw device type definition */
|
|
#define NW_APP_DEV_TYPE_POWER_METER 0
|
|
#define NW_APP_DEV_TYPE_COLLECTOR_T1 1
|
|
#define NW_APP_DEV_TYPE_COLLECTOR_T2 2
|
|
|
|
/* south power grid application protocol data type definition */
|
|
#define NW_APP_DATA_TYPE_TRANSPARENT (0x00)
|
|
#define NW_APP_DATA_TYPE_645_1997 (0x01)
|
|
#define NW_APP_DATA_TYPE_645_2007 (0x02)
|
|
#define NW_APP_DATA_TYPE_T188 (0x03)
|
|
|
|
/* define nw meter addr len to add address map list */
|
|
#define NW_APP_METER_ADDR_LEN 12
|
|
|
|
/* OK to upgrade */
|
|
#define NW_APP_UPGRADE_OK 0
|
|
/* receive request in invalid state */
|
|
#define NW_APP_UPGRADE_STATE_ERR 1
|
|
/* same version. don't upgrade */
|
|
#define NW_APP_UPGRADE_ERR_SAME_VERSION 2
|
|
/* flash operation error */
|
|
#define NW_APP_UPGRADE_FLASH_ERROR 3
|
|
/* don't upgrade in trail run state*/
|
|
#define NW_APP_UPGRADE_TRAIL_RUN_REJ 4
|
|
/* upgrade err because no memory */
|
|
#define NW_APP_UPGRADE_ERR_NO_MEM 5
|
|
/* block size error */
|
|
#define NW_APP_UPGRADE_ERR_BLOCK_SIZE 6
|
|
/* unknown error */
|
|
#define NW_APP_UPGRADE_OTHER_ERR 7
|
|
|
|
/* translate file msg id */
|
|
/* information of file from cco down link */
|
|
#define NW_APP_CMD_FILE_INFO (0x00)
|
|
/* data of file send from cco down link */
|
|
#define NW_APP_CMD_FILE_DATA (0x01)
|
|
/* query device received status from cco down link */
|
|
#define NW_APP_CMD_QUERY_RECV_STATUS (0x02)
|
|
/* translate file finish from cco down link */
|
|
#define NW_APP_CMD_FILE_SEND_DONE (0x03)
|
|
/* data of file send from cco down link. STA shall locally bcast it. */
|
|
#define NW_APP_CMD_FILE_DATA_B (0x04)
|
|
|
|
/* upgrade file attribute */
|
|
/* clear device file */
|
|
#define NW_APP_FILE_ATTRIBUTE_CLR (0x00)
|
|
/* STA file */
|
|
#define NW_APP_FILE_ATTRIBUTE_STA (0x02)
|
|
/* collector file */
|
|
#define NW_APP_FILE_ATTRIBUTE_COLLECT (0x03)
|
|
/* power meter file */
|
|
#define NW_APP_FILE_ATTRIBUTE_PM (0x04)
|
|
|
|
/* query elements id */
|
|
/* manufacture code */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_OEM_CODE (0x00)
|
|
/* version id */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_VER_INFO (0x01)
|
|
/* bootload version */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_BOOTLOADER (0x02)
|
|
/* crc value of the upgrade file */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_UPGRADE_CRC (0x03)
|
|
/* length of the upgrade file */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_UPGRADE_LEN (0x04)
|
|
/* chip code */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_CHIP_CODE (0x05)
|
|
/* version date */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_VER_DATE (0x06)
|
|
/* upgrade result status words */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_UPGRADE_WORDS (0x07)
|
|
/* module mac addr */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_MOD_MAC (0x08)
|
|
/* module hardware version id */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_HW_MOD_VER_INFO (0x09)
|
|
/* module hardware version date */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_HW_MOD_DATE (0x0A)
|
|
/* chip software version id */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_SW_CHIP_VER_INFO (0x0B)
|
|
/* chip software version date */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_SW_CHIP_VER_DATE (0x0C)
|
|
/* chip hardware version id */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_HW_CHIP_VER_INFO (0x0D)
|
|
/* chip hardware version date */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_HW_CHIP_VER_DATE (0x0E)
|
|
/* application version id */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_APP_VER_INFO (0x0F)
|
|
/* module device id */
|
|
#define NW_APP_CMD_SEC_NODE_INFO_DEV_ID (0x10)
|
|
|
|
/* nw upgrade block query definition */
|
|
#define NW_APP_UPGRADE_QUERY_ALL_BLOCK (0xFFFF)
|
|
|
|
/* upgrade status words */
|
|
/* normal status words */
|
|
#define NW_APP_UPGRADE_WORDS_NORMAL (0x00)
|
|
/* upgrade file mismatch words */
|
|
#define NW_APP_UPGRADE_WORDS_MISMATCH (0x01)
|
|
/* other upgrade status words */
|
|
#define NW_APP_UPGRADE_WORDS_OTHERS (0x02)
|
|
|
|
/* idle status */
|
|
#define NW_APP_FILE_ST_IDLE (0x00)
|
|
/* sta is receiving data form cco down link */
|
|
#define NW_APP_FILE_ST_SENDING (0x01)
|
|
/* sta had received that all data from cco down link */
|
|
#define NW_APP_FILE_ST_SEND_DONE (0x02)
|
|
/* reserved segment1 */
|
|
#define NW_APP_FILE_ST_RSVD1 (0x03)
|
|
/* reserved segment2 */
|
|
#define NW_APP_FILE_ST_RSVD2 (0x04)
|
|
/* sta had received that all data from cco down link and
|
|
* upgrade done msg from cco
|
|
*/
|
|
#define NW_APP_FILE_ST_DEST_DONE (0x05)
|
|
/* STA failed to receive file, or STA failed to send file to
|
|
* final dest device. Final device failed to get the whole file.
|
|
*/
|
|
#define NW_APP_FILE_ST_DEST_FAIL (0x06)
|
|
|
|
/* chip id length */
|
|
#define NW_APP_CHIP_ID_LEN (5)
|
|
/* chip id crc length */
|
|
#define NW_APP_CHIP_ID_CRC_LEN (8)
|
|
|
|
/* transformer detection feature collection type */
|
|
#define NW_APP_TSFM_COLLECT_START (1)
|
|
#define NW_APP_TSFM_COLLECT_COLLECT (2)
|
|
#define NW_APP_TSFM_COLLECT_REPORT (3)
|
|
#define NW_APP_TSFM_COLLECT_QUERY (4)
|
|
#define NW_APP_TSFM_COLLECT_RESULT (5)
|
|
#define NW_APP_TSFM_COLLECT_PHASE_IND (6)
|
|
#define NW_APP_TSFM_COLLECT_PHASE_RPT (7)
|
|
|
|
#define NW_APP_TSFM_COLLECT_QUERY_PW (180)
|
|
#define NW_APP_TSFM_COLLECT_RESULT_PW (181)
|
|
|
|
/* transformer detection feature type */
|
|
#define NW_APP_TSFM_FEATURE_INVALID (0)
|
|
#define NW_APP_TSFM_FEATURE_VOLTAGE (1)
|
|
#define NW_APP_TSFM_FEATURE_FREQUENCY (2)
|
|
#define NW_APP_TSFM_FEATURE_PERIOD (3)
|
|
|
|
/* transformer detect result */
|
|
#define NW_APP_TSFM_DETECT_RET_UNKNOWN (0)
|
|
#define NW_APP_TSFM_DETECT_RET_SAME (1)
|
|
#define NW_APP_TSFM_DETECT_RET_DIFFERENT (2)
|
|
|
|
/* collect type */
|
|
#define NW_APP_TSFM_COLLECT_TYPE_DEFAULT (0)
|
|
#define NW_APP_TSFM_COLLECT_TYPE_FALLING (1)
|
|
#define NW_APP_TSFM_COLLECT_TYPE_RISING (2)
|
|
#define NW_APP_TSFM_COLLECT_TYPE_EDGE (3)
|
|
|
|
/* nw protocol phase definition */
|
|
#define NW_APP_DATA_PHASE_DEFAULT (0)
|
|
#define NW_APP_DATA_PHASE_A (1)
|
|
#define NW_APP_DATA_PHASE_B (2)
|
|
#define NW_APP_DATA_PHASE_C (3)
|
|
|
|
/* convert ntb to ms. in HW, the ntb clock freq is 25 mhz. */
|
|
#define NW_APP_NTB_TO_MS(ntb) ((ntb) / (25 * 1000))
|
|
/* convert ms to ntb. in HW, the ntb clock freq is 25 mhz. */
|
|
#define NW_APP_MS_TO_NTB(ms) ((ms) * (25 * 1000))
|
|
|
|
/* nw protocol sta communication mode definition */
|
|
#define NW_APP_COMM_MOD_UNKNOW (0)
|
|
#define NW_APP_COMM_MOD_CARRIER (1)
|
|
#define NW_APP_COMM_MOD_WIRELESS (2)
|
|
|
|
/* id type */
|
|
#define NW_APP_ID_TYPE_MOD_COMPATIBLE (0)
|
|
#define NW_APP_ID_TYPE_CHIP (1)
|
|
#define NW_APP_ID_TYPE_MOD (2)
|
|
|
|
/* nw power off bitmap TEI definitions */
|
|
#define NW_APP_EVENT_TEI_FIRST (1)
|
|
#define NW_APP_EVENT_TEI_LAST (PLC_NETWORK_SCALE)
|
|
|
|
/* nw node id information len */
|
|
#define NW_APP_NODE_ID_INFO_LEN (24)
|
|
|
|
#define NW_APP_EVENT_TEI_IS_VALID(__tei) \
|
|
((__tei) >= NW_APP_EVENT_TEI_FIRST && (__tei) <= NW_APP_EVENT_TEI_LAST)
|
|
|
|
/* nw tei to bitmap index conversion */
|
|
#define NW_APP_TEI_TO_BM(tei) (tei + 1)
|
|
|
|
/* nan wang controller primary request message flag */
|
|
#define NW_APP_CTRL_PRM_MASTER (1)
|
|
#define NW_APP_CTRL_PRM_SLAVE (0)
|
|
|
|
/* nan wang controller protocol type */
|
|
#define NW_APP_CTRL_PROTO_TYPE_DEF (0)
|
|
|
|
/* nw state run state info id */
|
|
#define NW_APP_RUN_STATE_ID_RUNTIME (0)
|
|
#define NW_APP_RUN_STATE_ID_ZC (1)
|
|
#define NW_APP_RUN_STATE_ID_UART (2)
|
|
#define NW_APP_RUN_STATE_ID_LEAVE (3)
|
|
#define NW_APP_RUN_STATE_ID_RESET (4)
|
|
|
|
/* uart state, used for NW_APP_RUN_STATE_ID_UART */
|
|
#define NW_APP_RUN_UART_STATE_NORMAL 0
|
|
#define NW_APP_RUN_UART_STATE_ONCE_ABNORMAL 1
|
|
#define NW_APP_RUN_UART_STATE_ABNORMAL 2
|
|
|
|
/* leave net reason, used for NW_APP_RUN_STATE_ID_LEAVE */
|
|
#define NW_APP_RUN_LEAVE_REASON_UNKNOWN 0
|
|
#define NW_APP_RUN_LEAVE_REASON_SN_CHG 1
|
|
#define NW_APP_RUN_LEAVE_REASON_NO_BC_RX 2
|
|
#define NW_APP_RUN_LEAVE_REASON_TF_0 3
|
|
#define NW_APP_RUN_LEAVE_REASON_LEVEL 4
|
|
#define NW_APP_RUN_LEAVE_REASON_LEAVE_IND 5
|
|
|
|
/* reset reason, used for NW_APP_RUN_STATE_ID_RESET */
|
|
#define NW_APP_RUN_RESET_REASON_POWER 0
|
|
#define NW_APP_RUN_RESET_REASON_GPIO 1
|
|
#define NW_APP_RUN_RESET_REASON_UPGRADE 2
|
|
#define NW_APP_RUN_RESET_REASON_CCO 3
|
|
|
|
/* define neighbor node query max count */
|
|
#define NW_APP_NEIGHBOR_NODE_QUREY_MAX_CNT 6
|
|
|
|
/* work code */
|
|
#define NW_APP_WORK_CODE_TRANS_645 0x00
|
|
#define NW_APP_WORK_CODE_CORR_TIME 0x01
|
|
#define NW_APP_WORK_CODE_LOAD_CURVE 0x02
|
|
|
|
/* define load curve function code for shenzhen */
|
|
#define NW_APP_LR_FN_CFG_CLCT_INTERVAL_SZ 0x01
|
|
#define NW_APP_LR_FN_QUERY_CLCT_INTERVAL_SZ 0x02
|
|
#define NW_APP_LR_FN_READ_DI_DATA_SZ 0x03
|
|
|
|
/* define load curve function code for NW */
|
|
#define NW_APP_LR_FN_CFG_CLCT_INTERVAL 0x01
|
|
#define NW_APP_LR_FN_READ_DI_DATA 0x02
|
|
|
|
/* define load curve meter type */
|
|
#define NW_APP_LR_METER_TYPE_SINGLE_PHASE 0x00
|
|
#define NW_APP_LR_METER_TYPE_THREE_PHASE 0x01
|
|
#define NW_APP_LR_METER_TYPE_MAX \
|
|
(NW_APP_LR_METER_TYPE_THREE_PHASE + 1)
|
|
|
|
/* define correct time port id */
|
|
#define NW_APP_CORRECT_TIME_PORT_ID 0x01
|
|
|
|
/* edge computing event report type */
|
|
#define NW_APP_EDGE_COMP_EVT_TYPE_UNDERVOLTAGE (0xA1)
|
|
#define NW_APP_EDGE_COMP_EVT_TYPE_OVERVOLTAGE (0xA2)
|
|
#define NW_APP_EDGE_COMP_EVT_TYPE_SEC_PULSE (0xA3)
|
|
#define NW_APP_EDGE_COMP_EVT_TYPE_HEALTH_STATUS (0xA4)
|
|
|
|
/* south power grid application protocol frame header */
|
|
typedef struct _nw_app_header {
|
|
/* message port, set as 0x11 or 0x13, see NW_APP_PORT */
|
|
uint8_t port;
|
|
/* message identifier, in application level set as 0x0101 */
|
|
uint16_t id;
|
|
/* reserved for future, set as 0 */
|
|
uint8_t reserved;
|
|
} nw_app_header_t;
|
|
|
|
/* frame control field in application level message data */
|
|
typedef struct _nw_app_control {
|
|
uint16_t frame_type : 4, /* D0 - D3 */
|
|
reserved : 8, /* D4 - D11 */
|
|
work_append : 1, /* D12 */
|
|
respond : 1, /* D13 */
|
|
start : 1, /* D14 */
|
|
dir : 1; /* D15 */
|
|
} nw_app_control_t;
|
|
|
|
/* south power grid application level message data */
|
|
typedef struct _nw_app_data {
|
|
/* control field */
|
|
nw_app_control_t control_field;
|
|
/* work id */
|
|
uint8_t work_id;
|
|
/* application version */
|
|
uint8_t ver;
|
|
/* sequence number */
|
|
uint16_t sn;
|
|
/* data length */
|
|
uint16_t len;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_data_t;
|
|
|
|
/* south power grid protocol version definition */
|
|
#define NW_APP_VERSION (0x01)
|
|
#define NW_APP_PORT (0x11)
|
|
#define NW_APP_PORT_MGR (0x13) /* manager message port */
|
|
#define NW_APP_PORT_PT (0xFF) /* production test message port */
|
|
#define NW_APP_ID (0x0101)
|
|
#define NW_APP_CONTROL (0x00)
|
|
|
|
#define NW_APP_NACK_COMM_TIMEOUT (0x00)
|
|
#define NW_APP_NACK_WORD_ID_NO_SUPPORT (0x01)
|
|
#define NW_APP_NACK_CCO_BUSY (0x02)
|
|
#define NW_APP_NACK_METER_LEVEL_NO_ACK (0x03)
|
|
#define NW_APP_NACK_FORMAT_ERROR (0x04)
|
|
#define NW_APP_NACK_OTHER (0xFF)
|
|
/* nack payload between cco and sta */
|
|
typedef struct _nw_app_nack {
|
|
/* reason code */
|
|
uint8_t reason;
|
|
} nw_app_nack_t;
|
|
|
|
/* transfer payload from cco to sta module */
|
|
typedef struct _nw_app_fwd_module_dl {
|
|
/* primary node address, default set as 0 */
|
|
uint8_t src_addr[IOT_MAC_ADDR_LEN];
|
|
/* sta module address */
|
|
uint8_t dst_addr[IOT_MAC_ADDR_LEN];
|
|
/* work code for hainan and shenzhen, see NW_APP_WORK_CODE_XXX */
|
|
uint8_t work_code_other;
|
|
/* work code, see NW_APP_WORK_CODE_XXX */
|
|
uint8_t work_code;
|
|
/* data length */
|
|
uint16_t data_len;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_fwd_module_dl_t;
|
|
|
|
/* transfer payload from cco to sta */
|
|
typedef struct _nw_app_fwd_dl {
|
|
/* primary node address, default set as 0 */
|
|
uint8_t src_addr[IOT_MAC_ADDR_LEN];
|
|
/* meter address */
|
|
uint8_t dst_addr[IOT_MAC_ADDR_LEN];
|
|
/* device timeout, unit: 100ms */
|
|
uint8_t dev_timeout;
|
|
/* reserved for future, default set as 0 */
|
|
uint8_t reserved;
|
|
/* data length */
|
|
uint16_t data_len;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_fwd_dl_t;
|
|
|
|
/* transfer payload from sta to cco */
|
|
typedef struct _nw_app_fwd_ul {
|
|
/* meter address */
|
|
uint8_t src_addr[IOT_MAC_ADDR_LEN];
|
|
/* primary node address, default set as 0 */
|
|
uint8_t dst_addr[IOT_MAC_ADDR_LEN];
|
|
/* work code for hainan and shenzhen, see NW_APP_WORK_CODE_XXX */
|
|
uint8_t work_code_other;
|
|
/* work code, see NW_APP_WORK_CODE_XXX */
|
|
uint8_t work_code;
|
|
/* data length */
|
|
uint16_t data_len;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_fwd_ul_t;
|
|
|
|
/* base element */
|
|
typedef struct _nw_app_base_meter_info {
|
|
/* meter address */
|
|
uint8_t meter_addr[IOT_MAC_ADDR_LEN];
|
|
/* power meter proto type. see NW_APP_DATA_TYPE_XXX */
|
|
uint8_t proto_type;
|
|
/* reserved for future, default set as 0 */
|
|
uint8_t reserved;
|
|
} nw_app_base_meter_info_t;
|
|
|
|
/* query search meter result */
|
|
typedef struct _nw_app_cmd_query_meter_result {
|
|
/* meter count */
|
|
uint8_t meter_count;
|
|
/* reserved for future, default set as 0 */
|
|
uint8_t rsvd[3];
|
|
/* meter information */
|
|
nw_app_base_meter_info_t meter_info[0];
|
|
} nw_app_cmd_query_meter_result_t;
|
|
|
|
/* cco add meter list to sta */
|
|
typedef struct _nw_app_cmd_dl_meter_list {
|
|
/* meter count */
|
|
uint8_t meter_count;
|
|
/* reserved for future, default set as 0 */
|
|
uint8_t rsvd[3];
|
|
/* meter information */
|
|
nw_app_base_meter_info_t meter_info[0];
|
|
} nw_app_cmd_dl_meter_list_t;
|
|
|
|
typedef struct _nw_app_cmd_net_info {
|
|
/* major node addr, little endian */
|
|
uint8_t major_node_mac[IOT_MAC_ADDR_LEN];
|
|
/* meter addr, little endian */
|
|
uint8_t meter_mac[IOT_MAC_ADDR_LEN];
|
|
/* communication mode, see NW_APP_COMM_MOD_XXX */
|
|
uint8_t comm_mode;
|
|
/* time of joined network */
|
|
uint8_t join_sec;
|
|
uint8_t join_min;
|
|
uint8_t join_hour;
|
|
uint8_t join_day;
|
|
uint8_t join_mon;
|
|
uint8_t join_year;
|
|
/* flag to mark if the sec node in the network */
|
|
uint8_t in_net;
|
|
/* cost time from power on to join network, unit is 1s */
|
|
uint32_t cost_time;
|
|
} nw_app_cmd_net_info_t;
|
|
|
|
/* transfer file payload from cco to sta */
|
|
typedef struct _nw_app_cmd_file {
|
|
/* file transfer information id */
|
|
uint8_t id;
|
|
/* reserved for future, set as 0 */
|
|
uint8_t rsvd[3];
|
|
/* file transfer information */
|
|
uint8_t data[0];
|
|
} nw_app_cmd_file_t;
|
|
|
|
/* transfer file info from cco to sta by nw_app_cmd_file_t */
|
|
typedef struct _nw_app_cmd_file_dl_file_info_dl {
|
|
/* file attribute - see : NW_APP_FILE_ATTRIBUTE_XXX */
|
|
uint8_t file_type;
|
|
/* reserved for future, set as 0 */
|
|
uint8_t reserved;
|
|
/* upgrade destination address, little endian,
|
|
* broadcast set as 0x999999999999.
|
|
*/
|
|
uint8_t dest_addr[IOT_MAC_ADDR_LEN];
|
|
/* upgrade file crc */
|
|
uint32_t file_crc;
|
|
/* file size, unit: byte */
|
|
uint32_t file_size;
|
|
/* file total block count */
|
|
uint16_t file_block_count;
|
|
/* upgrade time window - uint: minute */
|
|
uint16_t window;
|
|
/* file identity */
|
|
uint32_t file_id;
|
|
} nw_app_cmd_file_dl_file_info_dl_t;
|
|
|
|
/* result of upgrade file info received */
|
|
#define NW_APP_RECV_UPGRADE_INFO_SUCCESS (0)
|
|
#define NW_APP_RECV_UPGRADE_INFO_FAIL (1)
|
|
|
|
/* sta ack cco that the file info receive result */
|
|
typedef struct _nw_app_cmd_file_dl_file_info_ul {
|
|
/* file transfer id */
|
|
uint32_t file_tran_id;
|
|
/* file info receive result, see NW_APP_RECV_UPGRADE_INFO_XXX */
|
|
uint16_t result;
|
|
/* 0 - no error, other - reserved */
|
|
uint16_t error_code;
|
|
} nw_app_cmd_file_dl_file_info_ul_t;
|
|
|
|
/* transfer file data from coo to sta */
|
|
typedef struct _nw_app_cmd_file_data_dl {
|
|
/* file block id */
|
|
uint16_t file_block_id;
|
|
/* file total block count */
|
|
uint16_t file_block_count;
|
|
/* file transfer id */
|
|
uint32_t file_tran_id;
|
|
/* data length */
|
|
uint16_t data_len;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_cmd_file_data_dl_t;
|
|
|
|
/* sta ack cco that the file data receive result */
|
|
typedef struct _nw_app_cmd_file_dl_file_data_ul {
|
|
/* file transfer id */
|
|
uint32_t file_tran_id;
|
|
/* 0 - success, other - reserved */
|
|
uint32_t result;
|
|
} nw_app_cmd_file_dl_file_data_ul_t;
|
|
|
|
/* query file data package receive state from sta */
|
|
typedef struct _nw_app_cmd_file_pkg_state_dl {
|
|
/* file identity */
|
|
uint32_t file_tran_id;
|
|
/* file start block id */
|
|
uint16_t start_block_id;
|
|
/* continuous N file block state bitmap */
|
|
uint16_t block_state_bitmap;
|
|
} nw_app_cmd_file_pkg_state_dl_t;
|
|
|
|
/* sta upload file data package receive state to cco */
|
|
typedef struct _nw_app_cmd_file_pkg_state_ul {
|
|
/* file transfer id */
|
|
uint32_t file_tran_id;
|
|
/* sequence of first block to be queried */
|
|
uint16_t start_seq;
|
|
/* upgrade status. See NW_APP_FILE_ST_DEST_XXX */
|
|
uint8_t status;
|
|
/* reserved for future */
|
|
uint8_t reserved;
|
|
/* bitmap, size = (N+7)/8 */
|
|
uint8_t bm[0];
|
|
} nw_app_cmd_file_pkg_state_ul_t;
|
|
|
|
/* file transfer finish done notice */
|
|
typedef struct _nw_app_cmd_file_finish_dl {
|
|
/* file transfer id */
|
|
uint32_t file_tran_id;
|
|
/* delay use the file time, unit: s */
|
|
uint16_t reset_dur;
|
|
} nw_app_cmd_file_finish_dl_t;
|
|
|
|
/* sta ack cco that the file data transfer finish done result */
|
|
typedef struct _nw_app_cmd_file_send_done_ul {
|
|
/* file transfer id */
|
|
uint32_t file_tran_id;
|
|
/* 0 - success, other - reserved */
|
|
uint32_t result;
|
|
} nw_app_cmd_file_send_done_ul_t;
|
|
|
|
#define NW_APP_CMD_SEC_NODE_EVENT_DIS (0x00)
|
|
#define NW_APP_CMD_SEC_NODE_EVENT_EN (0x01)
|
|
/* cco set sta sec node reg state */
|
|
typedef struct _nw_app_cmd_sec_node_evt {
|
|
/* flag to mark if enable sec node event report */
|
|
uint8_t evt_rpt_enable;
|
|
/* reserved for future, default set as 0 */
|
|
uint8_t rsvd[3];
|
|
} nw_app_cmd_sec_node_evt_t;
|
|
|
|
/* cco reboot the station delay max time, uint is 1ms*/
|
|
#define NW_APP_SEC_REBOOT_DELAY_MAX_TIME (60 * 1000)
|
|
|
|
/* cco reboot the station */
|
|
typedef struct _nw_app_cmd_sec_node_reboot {
|
|
/* delay reboot time, unit: s */
|
|
uint8_t delay;
|
|
/* reserved for future, default set as 0 */
|
|
uint8_t rsvd[3];
|
|
} nw_app_cmd_sec_node_reboot_t;
|
|
|
|
/* query sec node info from cco to sta */
|
|
typedef struct _nw_app_cmd_sec_info_query_dl {
|
|
/* info list element count */
|
|
uint8_t count;
|
|
/* info element id - see : NW_APP_CMD_SEC_NODE_INFO_XXX */
|
|
uint8_t info_id[0];
|
|
} nw_app_cmd_sec_info_query_dl_t;
|
|
|
|
/* base element */
|
|
typedef struct _nw_app_base_sec_node_info {
|
|
/* element id */
|
|
uint8_t id;
|
|
/* element data length */
|
|
uint8_t data_len;
|
|
/* element data */
|
|
//uint8_t data[0];
|
|
} nw_app_base_sec_node_info_t;
|
|
|
|
/* vendor id base element */
|
|
typedef struct _nw_app_base_sec_node_vendor_id {
|
|
/* vendor code, 2 byte ASCII */
|
|
uint16_t vendor_id;
|
|
} nw_app_base_sec_node_vendor_id_t;
|
|
|
|
/* version number base element */
|
|
typedef struct _nw_app_base_sec_node_ver {
|
|
/* version information, 2 byte BCD code */
|
|
uint16_t ver;
|
|
} nw_app_base_sec_node_ver_t;
|
|
|
|
/* bootloader version base element */
|
|
typedef struct _nw_app_base_sec_node_bootloader_ver {
|
|
/* bootloader version number, 1 byte BIN */
|
|
uint8_t bootloader_ver;
|
|
} nw_app_base_sec_node_bootloader_ver_t;
|
|
|
|
/* upgrade file crc base element */
|
|
typedef struct _nw_app_base_sec_node_upfile_crc {
|
|
/* upgrade file CRC32, 4 byte BIN */
|
|
uint32_t upfile_crc;
|
|
} nw_app_base_sec_node_upfile_crc_t;
|
|
|
|
/* upgrade file len base element */
|
|
typedef struct _nw_app_base_sec_node_upfile_len {
|
|
/* upgrade file length, 4 bytes BIN */
|
|
uint32_t upfile_len;
|
|
} nw_app_base_sec_node_upfile_len_t;
|
|
|
|
/* chip code base element */
|
|
typedef struct _nw_app_base_sec_node_chip_code {
|
|
/* chip code, 2 bytes ASCII */
|
|
uint16_t chip_code;
|
|
} nw_app_base_sec_node_chip_code_t;
|
|
|
|
/* version date base element */
|
|
typedef struct _nw_app_base_sec_node_ver_date {
|
|
/* version date, 3 bytes BIN */
|
|
uint8_t day;
|
|
uint8_t month;
|
|
uint8_t year;
|
|
} nw_app_base_sec_node_ver_date_t;
|
|
|
|
/* upgrade status words base element */
|
|
typedef struct _nw_app_base_upgrade_words {
|
|
/* upgrade status words, 8 bytes BIN */
|
|
uint8_t word1;
|
|
uint8_t rsvd[7];
|
|
} nw_app_base_upgrade_words_t;
|
|
|
|
/* module mac addr info base element */
|
|
typedef struct _nw_app_base_module_mac {
|
|
/* module mac addr, little endian */
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
} nw_app_base_module_mac_t;
|
|
|
|
/* ack node info from sta to cco */
|
|
typedef struct _nw_app_cmd_sec_info_query_ul {
|
|
/* info list element count */
|
|
uint8_t count;
|
|
/* info element data */
|
|
nw_app_base_sec_node_info_t info[0];
|
|
} nw_app_cmd_sec_info_query_ul_t;
|
|
|
|
/* map list base element */
|
|
typedef struct _nw_app_base_map_list_info {
|
|
/* login address */
|
|
uint8_t login_addr[IOT_MAC_ADDR_LEN];
|
|
/* meter address */
|
|
uint8_t meter_addr[NW_APP_METER_ADDR_LEN];
|
|
} nw_app_base_map_list_info_t;
|
|
|
|
/* cco add addr map list to sta */
|
|
typedef struct _nw_app_cmd_dl_map_list {
|
|
/* map list count */
|
|
uint8_t list_count;
|
|
/* reserved for future, default set as 0 */
|
|
uint8_t rsvd[3];
|
|
/* map list information */
|
|
nw_app_base_map_list_info_t map_info[0];
|
|
} nw_app_cmd_dl_map_list_t;
|
|
|
|
/* base element */
|
|
typedef struct _nw_app_base_cycle_test {
|
|
/* frequency band */
|
|
uint8_t freq_band : 4;
|
|
/* reserved for future */
|
|
uint8_t reserved : 4;
|
|
} nw_app_base_cycle_test_t;
|
|
|
|
/* base element */
|
|
typedef struct _nw_app_base_tran_test {
|
|
/* frequency band */
|
|
uint8_t freq_band : 4;
|
|
/* reserved for future */
|
|
uint8_t reserved : 4;
|
|
} nw_app_base_tran_test_t;
|
|
|
|
#define NW_APP_CMD_COMM_TEST_CYCLE (0x00)
|
|
#define NW_APP_CMD_COMM_TEST_TRAN (0x01)
|
|
/* communication test frame from cco to sta */
|
|
typedef struct _nw_app_cmd_comm_test {
|
|
/* test id */
|
|
uint8_t test_id;
|
|
/* reserved for future */
|
|
uint8_t reserved;
|
|
/* data length */
|
|
uint16_t data_len;
|
|
union {
|
|
/* loopback test mode data */
|
|
nw_app_base_cycle_test_t cycle;
|
|
/* transparent forwarding mode data */
|
|
nw_app_base_tran_test_t trans;
|
|
} res;
|
|
} nw_app_cmd_comm_test_t;
|
|
|
|
/* event report payload between cco and sta */
|
|
typedef struct _nw_app_rpt_evt_rpt_gd {
|
|
/* header length */
|
|
uint32_t header_len :6,
|
|
/* function code. see NW_APP_EVENT_FN_XXX */
|
|
fn :6,
|
|
/* data length */
|
|
data_len :12,
|
|
/* reserved for future */
|
|
rsvd1 :8;
|
|
/* reserved for future */
|
|
uint16_t rsvd2;
|
|
/* power meter mac address */
|
|
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_rpt_evt_rpt_gd_t;
|
|
|
|
/* event report from sta to cco */
|
|
typedef struct _nw_app_rpt_evt_rpt {
|
|
/* meter address */
|
|
uint8_t meter_addr[IOT_MAC_ADDR_LEN];
|
|
/* meter report data */
|
|
uint8_t data[0];
|
|
} nw_app_rpt_evt_rpt_t;
|
|
|
|
/* nw protocol event function code */
|
|
#define NW_APP_EVENT_FN_MODULE_RPT (0x1E)
|
|
#define NW_APP_EVENT_FN_SCORE_RPT (0x1F)
|
|
/* guangdong protocol event function */
|
|
/* downlink function code */
|
|
#define NW_APP_EVENT_FN_CONF_ACK (1)
|
|
#define NW_APP_EVENT_FN_ALLOW_RPT (2)
|
|
#define NW_APP_EVENT_FN_FORBID_RPT (3)
|
|
#define NW_APP_EVENT_FN_FULL_ACK (4)
|
|
/* uplink function code */
|
|
/* event triggered by sta modular */
|
|
#define NW_APP_EVENT_FN_STA_RPT (1)
|
|
/* event triggered by collector */
|
|
#define NW_APP_EVENT_FN_COLLECTOR_RPT (2)
|
|
|
|
/* bitmap type data */
|
|
#define NW_APP_EVENT_TYPE_POWER_DOWN (1)
|
|
#define NW_APP_EVENT_TYPE_POWER_UP (2)
|
|
/* address type data */
|
|
#define NW_APP_EVENT_TYPE_POWER_DOWN_ADDR (3)
|
|
#define NW_APP_EVENT_TYPE_POWER_UP_ADDR (4)
|
|
|
|
/* query node score donw link */
|
|
typedef struct _nw_app_query_score_dl {
|
|
/* meter mac addr, little endian */
|
|
uint8_t meter_mac[IOT_MAC_ADDR_LEN];
|
|
} nw_app_query_score_dl_t;
|
|
|
|
/* power meter score info */
|
|
typedef struct _nw_app_pm_score_info {
|
|
/* assessment score */
|
|
uint8_t score;
|
|
/* trouble data item, 4 byte to 32 bit.
|
|
* each bit corresponding to trouble data item.
|
|
* example: D0 is trouble, set bit0 is 1.
|
|
*/
|
|
uint32_t err_bm;
|
|
/* power meter mac address, little endian */
|
|
uint8_t pm_mac[IOT_MAC_ADDR_LEN];
|
|
} nw_app_pm_score_info_t;
|
|
|
|
/* power meter score info */
|
|
typedef struct _nw_app_query_score_ul {
|
|
/* power meter score info */
|
|
nw_app_pm_score_info_t score_info[0];
|
|
} nw_app_query_score_ul_t;
|
|
|
|
/* score event data field */
|
|
typedef struct _nw_app_score_evt_data_field {
|
|
/* event function code, see NW_APP_EVENT_FN_XXX */
|
|
uint8_t fn_code;
|
|
/* power meter score info */
|
|
nw_app_pm_score_info_t pm_info[0];
|
|
} nw_app_score_evt_data_field_t;
|
|
|
|
/* power event data field */
|
|
typedef struct _nw_app_evt_data_field {
|
|
/* event function code, see NW_APP_EVENT_FN_XXX */
|
|
uint8_t fn_code;
|
|
/* reserve for future */
|
|
uint8_t rsvd;
|
|
/* types of reported events, see NW_APP_EVENT_TYPE_POWER_XXX */
|
|
uint8_t type;
|
|
} nw_app_evt_data_field_t;
|
|
|
|
/* event data field */
|
|
typedef struct _nw_app_evt_data_field_gd {
|
|
/* event type, see NW_APP_EVENT_TYPE_XXX */
|
|
uint8_t evt_type;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_evt_data_field_gd_t;
|
|
|
|
/* bitmap type for event data field */
|
|
typedef struct _nw_app_evt_data_bitmap {
|
|
/* the tei of the start bit in the bitmap */
|
|
uint16_t tei;
|
|
/* tei map */
|
|
uint8_t map[0];
|
|
} nw_app_evt_data_bitmap_t;
|
|
|
|
/* power meter info for module event report */
|
|
typedef struct _nw_app_power_evt_pm_info {
|
|
/* power meter mac address, little endian */
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
/* 0 - power off, 1- power on */
|
|
uint8_t power_state;
|
|
} nw_app_power_evt_pm_info_t;
|
|
|
|
/* addr type for event data field */
|
|
typedef struct _nw_app_evt_data_addr {
|
|
/* power meter count */
|
|
uint16_t pm_count;
|
|
/* power meter info */
|
|
nw_app_power_evt_pm_info_t pm_info[0];
|
|
} nw_app_evt_data_addr_t;
|
|
|
|
/* query id info donw link */
|
|
typedef struct _nw_app_cmd_id_dl {
|
|
/* id type, see NW_APP_ID_TYPE_XXX */
|
|
uint8_t id_type;
|
|
/* id length */
|
|
uint8_t id_len;
|
|
/* meter mac addr, little endian */
|
|
uint8_t meter_mac[IOT_MAC_ADDR_LEN];
|
|
} nw_app_cmd_id_dl_t;
|
|
|
|
/* chip id information */
|
|
typedef struct _nw_app_chip_id {
|
|
/** check code */
|
|
uint8_t check_code[NW_APP_CHIP_ID_CRC_LEN];
|
|
/** equipment serial number */
|
|
uint8_t dev_code[NW_APP_CHIP_ID_LEN];
|
|
/** chip mode */
|
|
uint16_t chip_mode;
|
|
/** chip vendor code */
|
|
uint16_t vendor;
|
|
/** 1 - narrowband, 2 - broadband */
|
|
uint8_t dev_type;
|
|
/** fixed value: 0x01C1FB */
|
|
uint8_t hd4_3;
|
|
uint8_t hd4_2;
|
|
uint8_t hd4_1;
|
|
/** fixed value: 0x9C */
|
|
uint8_t hd3;
|
|
/** fixed value: 0x02 */
|
|
uint8_t hd2;
|
|
/** fixed value: 0x01 */
|
|
uint8_t hd1;
|
|
} nw_app_chip_id_t;
|
|
|
|
/* query id info ul link */
|
|
typedef struct _nw_app_cmd_id_info_hdr_ul {
|
|
/* id type, see NW_APP_ID_TYPE_XXX */
|
|
uint8_t id_type;
|
|
/* id length */
|
|
uint8_t id_len;
|
|
} nw_app_cmd_id_info_hdr_ul_t;
|
|
|
|
/* query chip id info ul link */
|
|
typedef struct _nw_app_cmd_chip_id {
|
|
/* meter mac addr, little endian */
|
|
uint8_t meter_mac[IOT_MAC_ADDR_LEN];
|
|
/* chip id */
|
|
nw_app_chip_id_t chip_id;
|
|
/* device type, see IOT_PLC_DEV_TYPE_XXX */
|
|
uint8_t dev_type;
|
|
/* flag to mark if have super capacitance */
|
|
uint8_t super_cap : 2,
|
|
/* flag to mark if could fix position */
|
|
fix_position : 2,
|
|
/* reserved */
|
|
rsvd : 4;
|
|
} nw_app_cmd_chip_id_t;
|
|
|
|
/* query node id info ul link */
|
|
typedef struct _nw_app_cmd_node_id {
|
|
/* meter mac addr, little endian */
|
|
uint8_t meter_mac[IOT_MAC_ADDR_LEN];
|
|
/* id info */
|
|
uint8_t id_info[NW_APP_NODE_ID_INFO_LEN];
|
|
/* device type, see IOT_PLC_DEV_TYPE_XXX */
|
|
uint8_t dev_type;
|
|
/* flag to mark if have super capacitance */
|
|
uint8_t super_cap : 2,
|
|
/* flag to mark if could fix position */
|
|
fix_position : 2,
|
|
/* reserved */
|
|
rsvd : 4;
|
|
} nw_app_cmd_node_id_t;
|
|
|
|
/* guangdong transformer detect package */
|
|
typedef struct _nw_app_tsfm_detect_guangdong {
|
|
/* header length */
|
|
uint8_t header_len :6,
|
|
/* collect phase, see NW_APP_DATA_PHASE_XXX. */
|
|
phase :2;
|
|
/* reserved for future, default set as 0 */
|
|
uint8_t rsvd[3];
|
|
/* cco mac address or sta mac address, big-endian */
|
|
uint8_t addr[IOT_MAC_ADDR_LEN];
|
|
/* transformer feature type, see NW_APP_TSFM_FEATURE_XXX */
|
|
uint8_t feature_type;
|
|
/* transformer feature collection type, see NW_APP_TSFM_COLLECT_XXX */
|
|
uint8_t collect_type;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_tsfm_detect_guangdong_t;
|
|
|
|
/* transformer detect package */
|
|
typedef struct _nw_app_tsfm_detect {
|
|
/* header length */
|
|
uint8_t header_len :6,
|
|
/* collect phase, see NW_APP_DATA_PHASE_XXX. */
|
|
phase :2;
|
|
/* cco mac address or sta mac address, big-endian */
|
|
uint8_t addr[IOT_MAC_ADDR_LEN];
|
|
/* transformer feature type, see NW_APP_TSFM_FEATURE_XXX */
|
|
uint8_t feature_type;
|
|
/* transformer feature collection type, see NW_APP_TSFM_COLLECT_XXX */
|
|
uint8_t collect_type;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_tsfm_detect_t;
|
|
|
|
/* transformer feature collection type package.
|
|
* NW_APP_TSFM_COLLECT_START package
|
|
*/
|
|
typedef struct _nw_app_tsfm_collect_start {
|
|
/* NTB at the start of the whole network collection */
|
|
uint32_t start_ntb;
|
|
/* collection interval, uint is 1s. when transformer
|
|
* feature type is NW_APP_TSFM_FEATURE_PERIOD, interval
|
|
* is invalid.
|
|
*/
|
|
uint8_t interval;
|
|
/* collection cnt */
|
|
uint8_t cnt;
|
|
/* collection sequence, the sequence is generated by CCO
|
|
* the value range of sequence is 1-255.
|
|
*/
|
|
uint8_t seq;
|
|
/* reserve for future */
|
|
uint8_t rsvd;
|
|
} nw_app_tsfm_collect_start_t;
|
|
|
|
/* transformer feature collection type package.
|
|
* NW_APP_TSFM_COLLECT_REPORT package
|
|
*/
|
|
typedef struct _nw_app_tsfm_collect_report {
|
|
/* tei of cco or sta */
|
|
uint16_t tei :12,
|
|
/* collect type, see NW_APP_TSFM_COLLECT_TYPE_XXX.
|
|
* valid only in the NW_APP_TSFM_FEATURE_PERIOD.
|
|
*/
|
|
clct_type :2,
|
|
/* reserved for future */
|
|
rsvd :2;
|
|
/* collection sequence, the sequence is generated by CCO
|
|
* the value range of sequence is 1-255.
|
|
*/
|
|
uint8_t seq;
|
|
/* report feature total cnt */
|
|
uint8_t cnt;
|
|
/* transformer feature collection data */
|
|
uint8_t data[0];
|
|
} nw_app_tsfm_collect_report_t;
|
|
|
|
/* transformer feature collection data */
|
|
typedef struct _nw_app_tsfm_collect_data {
|
|
/* NTB at the start of the first collection */
|
|
uint32_t start_ntb;
|
|
/* reserved for future */
|
|
uint8_t rsvd;
|
|
/* phase a report count */
|
|
uint8_t phase1_cnt;
|
|
/* phase b report count */
|
|
uint8_t phase2_cnt;
|
|
/* phase c report count */
|
|
uint8_t phase3_cnt;
|
|
/* feature data */
|
|
int16_t data[0];
|
|
} nw_app_tsfm_collect_data_t;
|
|
|
|
/* transformer detection feature type package.
|
|
* NW_APP_TSFM_FEATURE_VOLTAGE package
|
|
*/
|
|
typedef struct _nw_app_tsfm_collect_v {
|
|
/* A phase voltage. use 2 bytes of BCD code to represent the voltage.
|
|
* for example, 220.0V uses 2 bytes of BCD code to represent
|
|
* the following 0x22, 0x00.
|
|
*/
|
|
uint8_t bcd[PROTO_645_V_LEN];
|
|
} nw_app_tsfm_collect_v_t;
|
|
|
|
/* transformer detection feature type package.
|
|
* NW_APP_TSFM_FEATURE_FREQUENCY package
|
|
*/
|
|
typedef struct _nw_app_tsfm_collect_freq {
|
|
/* frequency. use 2 bytes of BCD code to represent the frequency.
|
|
* for example, 50.00V uses 2 bytes of BCD code to represent
|
|
* the following 0x50, 0x00.
|
|
*/
|
|
uint8_t bcd[PROTO_645_FREQ_LEN];
|
|
} nw_app_tsfm_collect_freq_t;
|
|
|
|
/* transformer detection feature type package.
|
|
* NW_APP_TSFM_FEATURE_PERIOD package
|
|
*/
|
|
typedef struct _nw_app_tsfm_collect_period {
|
|
/* Each period value represents the difference
|
|
* between a zero-crossing period and 20ms.
|
|
* unit is 1/3125000S (the 8-minute frequency
|
|
* of the counting frequency is 25MHz, that is
|
|
* 3.125 MHz).
|
|
*/
|
|
int16_t period;
|
|
} nw_app_tsfm_collect_period_t;
|
|
|
|
/* transformer detect result */
|
|
typedef struct _nw_app_tsfm_detect_result {
|
|
/* node tei */
|
|
uint16_t tei;
|
|
/* 0 - transformer detect in progress, 1 - transformer detect done */
|
|
uint8_t done;
|
|
/* see NW_APP_TSFM_DETECT_RET_XXX */
|
|
uint8_t result;
|
|
/* real transformer mac address, big-endian */
|
|
uint8_t tsfm_addr[IOT_MAC_ADDR_LEN];
|
|
} nw_app_tsfm_detect_result_t;
|
|
|
|
/* phase feature collection indication */
|
|
typedef struct _nw_app_phase_collect_ind {
|
|
/* collection feature total cnt */
|
|
uint8_t cnt;
|
|
/* collection seq, generated by CCO, the value is 0-255 */
|
|
uint8_t seq;
|
|
/* reserved for future */
|
|
uint16_t rsvd;
|
|
} nw_app_phase_collect_ind_t;
|
|
|
|
/* phase feature collection report */
|
|
typedef struct _nw_app_phase_collect_rpt {
|
|
/* sta tei */
|
|
uint16_t tei :12,
|
|
/* collection edge type, see NW_APP_TSFM_COLLECT_TYPE_XXX */
|
|
edge_type :2,
|
|
/* reserved for future */
|
|
rsvd1 :2;
|
|
/* collection seq, generated by CCO, the value is 0-255 */
|
|
uint8_t seq;
|
|
/* report feature total cnt */
|
|
uint8_t cnt;
|
|
/* standard NTB */
|
|
uint32_t std_ntb;
|
|
/* reserved for future */
|
|
uint8_t rsvd2;
|
|
/* phase a report count */
|
|
uint8_t phase1_cnt;
|
|
/* phase b report count */
|
|
uint8_t phase2_cnt;
|
|
/* phase c report count */
|
|
uint8_t phase3_cnt;
|
|
/* transformer feature collection data */
|
|
uint16_t data[0];
|
|
} nw_app_phase_collect_rpt_t;
|
|
|
|
/* private protocol transformer detect result */
|
|
typedef struct _nw_app_tsfm_detect_result_pw {
|
|
/* node tei */
|
|
uint16_t tei;
|
|
/* 0 - transformer detect in progress, 1 - transformer detect done */
|
|
uint8_t done;
|
|
/* see NW_APP_TSFM_DETECT_RET_XXX */
|
|
uint8_t result;
|
|
/* real transformer mac address, big-endian */
|
|
uint8_t tsfm_addr[IOT_MAC_ADDR_LEN];
|
|
/* hardware transformer mac address, big-endian */
|
|
uint8_t hw_tsfm_addr[IOT_MAC_ADDR_LEN];
|
|
} nw_app_tsfm_detect_result_pw_t;
|
|
|
|
/* collection task structure definition */
|
|
/* define pm protocol type in collection task structure */
|
|
#define NW_APP_CLCT_TASK_PROTO_TYPE_UNKNOWN 0
|
|
#define NW_APP_CLCT_TASK_PROTO_TYPE_645_97 1
|
|
#define NW_APP_CLCT_TASK_PROTO_TYPE_645_07 2
|
|
|
|
/* define pm type in collection task structure */
|
|
#define NW_APP_CLCT_TASK_PM_TYPE_INVALID 0
|
|
#define NW_APP_CLCT_TASK_PM_TYPE_SINGE 1
|
|
#define NW_APP_CLCT_TASK_PM_TYPE_3P 2
|
|
|
|
/* define collection period in collection task structure */
|
|
#define NW_APP_CLCT_TASK_PERIOD_DEFAULT 0
|
|
#define NW_APP_CLCT_TASK_PERIOD_15MIN 3
|
|
#define NW_APP_CLCT_TASK_PERIOD_30MIN 4
|
|
#define NW_APP_CLCT_TASK_PERIOD_60MIN 5
|
|
#define NW_APP_CLCT_TASK_PERIOD_DAY 6
|
|
#define NW_APP_CLCT_TASK_PERIOD_15MIN_LR 13
|
|
#define NW_APP_CLCT_TASK_PERIOD_30MIN_LR 14
|
|
#define NW_APP_CLCT_TASK_PERIOD_60MIN_LR 15
|
|
#define NW_APP_CLCT_TASK_PERIOD_SINGLE 16
|
|
|
|
/* define add collection task result */
|
|
#define NW_APP_CLCT_TASK_ADD_OK 0
|
|
#define NW_APP_CLCT_TASK_ADD_ERR_CRC 1
|
|
#define NW_APP_CLCT_TASK_ADD_ERR_PROTO 2
|
|
#define NW_APP_CLCT_TASK_ADD_ERR_NOMEM 3
|
|
#define NW_APP_CLCT_TASK_ADD_ERR_PM 4
|
|
|
|
/* define del collection task result */
|
|
#define NW_APP_CLCT_TASK_DEL_OK 0
|
|
#define NW_APP_CLCT_TASK_DEL_ERR_NOTASK 1
|
|
|
|
/* define max cnt of support collection task */
|
|
#define NW_APP_CLCT_TASK_SUPP_MAX 5
|
|
|
|
/* define task data flag */
|
|
#define NW_APP_CLCT_TASK_DATA_VALID 0
|
|
#define NW_APP_CLCT_TASK_DATA_INVALID 1
|
|
|
|
/* define task data invalid error code */
|
|
#define NW_APP_CLCT_TASK_DATA_ERR_NOTASK 1
|
|
#define NW_APP_CLCT_TASK_DATA_ERR_NOCCO 2
|
|
|
|
/* define max cnt of di in collect task */
|
|
#define NW_APP_CLCT_TASK_DI_MAX 4
|
|
|
|
/* define length of clct passthrough baud */
|
|
#define NW_APP_CLCT_TASK_BAUD_LEN 4
|
|
|
|
/* collection task correct time from cco to sta */
|
|
typedef struct _nw_app_clct_task_correct_time_req {
|
|
/* major mac addr, BIN type, big endian */
|
|
uint8_t major_mac[IOT_MAC_ADDR_LEN];
|
|
/* correct time, BCD type */
|
|
uint8_t second;
|
|
uint8_t minute;
|
|
uint8_t hour;
|
|
uint8_t day;
|
|
uint8_t month;
|
|
uint8_t year;
|
|
} nw_app_clct_task_correct_time_req_t;
|
|
|
|
/* collection task init resp structure from sta to cco */
|
|
typedef struct _nw_app_clct_task_init_resp {
|
|
/* unicast response, 0 - ack, others - nack */
|
|
uint8_t ack;
|
|
} nw_app_clct_task_init_resp_t;
|
|
|
|
/* collection di structure in collection task add req for dl/t 645-97 */
|
|
typedef struct _nw_app_clct_task_id_97 {
|
|
/* control code */
|
|
uint8_t control_code;
|
|
/* di of collection data, add 0x33 */
|
|
uint16_t di;
|
|
/* length of collection data */
|
|
uint8_t len_data;
|
|
} nw_app_clct_task_id_97_t;
|
|
|
|
/* collection di structure in collection task add req for dl/t 645-07 */
|
|
typedef struct _nw_app_clct_task_id_07 {
|
|
/* control code */
|
|
uint8_t control_code;
|
|
/* di of collection data, add 0x33 */
|
|
uint32_t di;
|
|
/* length of collection data */
|
|
uint8_t len_data;
|
|
} nw_app_clct_task_id_07_t;
|
|
|
|
/* collection fn structure in collection task */
|
|
typedef struct _nw_app_clct_task_fn {
|
|
/* type of pm protocol, see NW_APP_CLCT_TASK_PROTO_TYPE_XXX */
|
|
uint16_t proto_type : 3,
|
|
/* type of pm, see NW_APP_CLCT_TASK_PM_TYPE_XXX */
|
|
meter_type : 2,
|
|
/* reserved for future */
|
|
rsvd : 11;
|
|
} nw_app_clct_task_fn_t;
|
|
|
|
/* collection data time structure, Guangdong appendix A.1 */
|
|
typedef struct _nw_app_clct_task_data_time {
|
|
/* data time, BIN type */
|
|
uint16_t base_min : 6, /* D0 - D5 */
|
|
base_hour : 5, /* D6 - D10 */
|
|
base_day : 5; /* D11 - D15 */
|
|
} nw_app_clct_task_data_time_t;
|
|
|
|
/* collection task time structure */
|
|
typedef struct _nw_app_clct_task_time {
|
|
/* task time, BCD code */
|
|
uint8_t sec;
|
|
uint8_t min;
|
|
uint8_t hour;
|
|
uint8_t day;
|
|
uint8_t month;
|
|
uint8_t year;
|
|
} nw_app_clct_task_time_t;
|
|
|
|
/* collection task info structure in collection task */
|
|
typedef struct _nw_app_clct_task_info {
|
|
/* task id */
|
|
uint8_t task_id;
|
|
/* task control code */
|
|
nw_app_clct_task_fn_t fn;
|
|
/* task timout time, uint is 1s */
|
|
uint16_t timeout;
|
|
/* collection base time */
|
|
nw_app_clct_task_data_time_t base_time;
|
|
/* collection period, see NW_APP_CLCT_TASK_PERIOD_XXX */
|
|
uint8_t period;
|
|
/* cnt of di */
|
|
uint8_t di_cnt;
|
|
/* collection data info, see nw_app_clct_task_id_97_t or
|
|
* nw_app_clct_task_id_07_t base on proto_type.
|
|
*/
|
|
uint8_t data[0];
|
|
/* There is a CRC check behind the data
|
|
* CRC check from fn to data
|
|
*/
|
|
//uint16_t crc;
|
|
} nw_app_clct_task_info_t;
|
|
|
|
/* collection task add req structure from cco to sta */
|
|
typedef struct _nw_app_clct_task_add_req {
|
|
/* pm address, little-endian */
|
|
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
|
|
/* time stamp, BCD code to represent */
|
|
nw_app_clct_task_time_t tm;
|
|
/* cco address, big-endian */
|
|
uint8_t cco_addr[IOT_MAC_ADDR_LEN];
|
|
/* collection task info */
|
|
nw_app_clct_task_info_t task_info;
|
|
} nw_app_clct_task_add_req_t;
|
|
|
|
/* collection task add resp structure from sta to cco */
|
|
typedef struct _nw_app_clct_task_add_resp {
|
|
/* result of collection task add function,
|
|
* see NW_APP_CLCT_TASK_ADD_XXX
|
|
*/
|
|
uint8_t result;
|
|
} nw_app_clct_task_add_resp_t;
|
|
|
|
/* collection task delete req structure from cco to sta */
|
|
typedef struct _nw_app_clct_task_del_req {
|
|
/* pm address, little-endian */
|
|
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
|
|
/* task id */
|
|
uint8_t task_id;
|
|
} nw_app_clct_task_del_req_t;
|
|
|
|
/* collection task add resp structure from sta to cco */
|
|
typedef struct _nw_app_clct_task_del_resp {
|
|
/* result of collection task delete function,
|
|
* see NW_APP_CLCT_TASK_DEL_XXX
|
|
*/
|
|
uint8_t result;
|
|
} nw_app_clct_task_del_resp_t;
|
|
|
|
/* collection task id query req structure from cco to sta */
|
|
typedef struct _nw_app_clct_task_id_query_req {
|
|
/* pm address, little-endian */
|
|
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
|
|
} nw_app_clct_task_id_query_req_t;
|
|
|
|
/* collection task id query resp structure from sta to cco */
|
|
typedef struct _nw_app_clct_task_id_query_resp {
|
|
/* pm address, little-endian */
|
|
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
|
|
/* max cnt of support task, see NW_APP_CLCT_TASK_SUPP_MAX */
|
|
uint8_t max_cnt;
|
|
/* task cnt */
|
|
uint8_t task_cnt;
|
|
/* task id list */
|
|
uint8_t task_id[0];
|
|
} nw_app_clct_task_id_query_resp_t;
|
|
|
|
/* collection task id info query req structure from cco to sta */
|
|
typedef struct _nw_app_clct_task_id_info_query_req {
|
|
/* pm address, little-endian */
|
|
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
|
|
/* cco address, big-endian */
|
|
uint8_t cco_addr[IOT_MAC_ADDR_LEN];
|
|
/* task id */
|
|
uint8_t task_id;
|
|
} nw_app_clct_task_id_info_query_req_t;
|
|
|
|
/* collection task id info query normal resp structure from sta to cco */
|
|
typedef struct _nw_app_clct_task_id_info_query_nor_resp {
|
|
/* pm address, little-endian */
|
|
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
|
|
/* task info flag, see NW_APP_CLCT_TASK_DATA_VALID */
|
|
uint8_t info_valid_flag;
|
|
/* collection task info */
|
|
nw_app_clct_task_info_t task_info;
|
|
} nw_app_clct_task_id_info_query_nor_resp_t;
|
|
|
|
/* collection task id info query abnormal resp structure from sta to cco */
|
|
typedef struct _nw_app_clct_task_id_info_query_abn_resp {
|
|
/* pm address, little-endian */
|
|
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
|
|
/* task info flag, see NW_APP_CLCT_TASK_DATA_INVALID */
|
|
uint8_t info_valid_flag;
|
|
/* error code, see NW_APP_CLCT_TASK_DATA_ERR_XXX */
|
|
uint8_t err;
|
|
} nw_app_clct_task_id_info_query_abn_resp_t;
|
|
|
|
/* collection data query req structure from cco to sta */
|
|
typedef struct _nw_app_clct_data_query_req {
|
|
/* pm address, little-endian */
|
|
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
|
|
/* cco address, big-endian */
|
|
uint8_t cco_addr[IOT_MAC_ADDR_LEN];
|
|
/* task id */
|
|
uint8_t task_id;
|
|
/* start time */
|
|
nw_app_clct_task_data_time_t start_time;
|
|
/* cnt of collection data */
|
|
uint8_t cnt;
|
|
} nw_app_clct_data_query_req_t;
|
|
|
|
/* collection data query normal resp structure from sta to cco */
|
|
typedef struct _nw_app_clct_data_query_nor_resp {
|
|
/* pm address, little-endian */
|
|
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
|
|
/* time stamp, BCD code to represent */
|
|
nw_app_clct_task_time_t tm;
|
|
/* task data flag, see NW_APP_CLCT_TASK_DATA_VALID */
|
|
uint8_t data_valid_flag;
|
|
/* task id list */
|
|
uint8_t task_id;
|
|
/* crc code, as same as crc code in nw_app_clct_task_add_req_t */
|
|
uint16_t crc_code;
|
|
/* collection data */
|
|
uint8_t data[0];
|
|
} nw_app_clct_data_query_nor_resp_t;
|
|
|
|
/* collection data structure */
|
|
typedef struct _nw_app_clct_data_struct {
|
|
/* control code as same as control in proto_645_header_t */
|
|
uint8_t control;
|
|
/* data field as same as data field in dl/t 645 */
|
|
uint8_t data[0];
|
|
/* There is a CS check behind the data
|
|
* CS as same as data field in dl/t 645
|
|
*/
|
|
//uint8_t cs;
|
|
} nw_app_clct_data_struct_t;
|
|
|
|
/* collection data query abnormal resp structure from sta to cco */
|
|
typedef struct _nw_app_clct_data_query_abn_resp {
|
|
/* pm address, little-endian */
|
|
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
|
|
/* time stamp, BCD code to represent */
|
|
nw_app_clct_task_time_t tm;
|
|
/* task data flag, see NW_APP_CLCT_TASK_DATA_INVALID */
|
|
uint8_t data_valid_flag;
|
|
/* error code, see NW_APP_CLCT_TASK_DATA_ERR_XXX */
|
|
uint8_t err;
|
|
} nw_app_clct_data_query_abn_resp_t;
|
|
|
|
/* ctrl proto payload */
|
|
typedef struct _nw_app_ctrl_proto {
|
|
/* protocol type, default value is 0 */
|
|
uint8_t proto_type;
|
|
/* sequence number */
|
|
uint8_t sn;
|
|
/* data length */
|
|
uint16_t data_len;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_ctrl_proto_t;
|
|
|
|
/* ctrl passthrough proto payload */
|
|
typedef struct _nw_app_ctrl_proto_passthrough {
|
|
/* passthrough data protocol type, see NW_APP_CTRL_PROTO_TYPE_XXX */
|
|
uint8_t proto_type;
|
|
/* primary request message flag, see NW_APP_CTRL_PRM_XXX */
|
|
uint8_t prm : 1,
|
|
/* reserve1 for future */
|
|
rsvd1 : 7;
|
|
/* baudrate: small endian */
|
|
uint8_t baud[NW_APP_CLCT_TASK_BAUD_LEN];
|
|
/* sequence number */
|
|
uint8_t sn;
|
|
/* reserve2 for future */
|
|
uint8_t rsvd2;
|
|
/* reserve3 for future */
|
|
uint8_t rsvd3;
|
|
/* reserve4 for future */
|
|
uint8_t rsvd4;
|
|
/* data length */
|
|
uint16_t data_len;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_ctrl_proto_passthrough_t;
|
|
|
|
/* sta run state query req structure from cco to sta */
|
|
typedef struct _nw_app_run_state_query_req {
|
|
/* query info cnt */
|
|
uint8_t cnt;
|
|
/* info id, see NW_APP_RUN_STATE_ID_XXX */
|
|
uint8_t id[0];
|
|
} nw_app_run_state_query_req_t;
|
|
|
|
/* sta run state query resp structure from sta to cco */
|
|
typedef struct _nw_app_run_state_query_resp {
|
|
/* query info cnt */
|
|
uint8_t cnt;
|
|
/* info data */
|
|
uint8_t data[0];
|
|
} nw_app_run_state_query_resp_t;
|
|
|
|
/* sta run state id info header */
|
|
typedef struct _nw_app_run_state_id_hdr {
|
|
/* info id */
|
|
uint8_t id;
|
|
/* info data lenght */
|
|
uint8_t len;
|
|
/* info data */
|
|
uint8_t data[0];
|
|
} nw_app_run_state_id_hdr_t;
|
|
|
|
/* sta runtime info structure, id is NW_APP_RUN_STATE_ID_RUNTIME */
|
|
typedef struct _nw_app_node_runtime_info {
|
|
/* runtime, uint is 1s */
|
|
uint32_t runtime;
|
|
} nw_app_node_runtime_info_t;
|
|
|
|
/* sta run other info structure,
|
|
* id is NW_APP_RUN_STATE_ID_ZC.
|
|
* id is NW_APP_RUN_STATE_ID_UART.
|
|
* id is NW_APP_RUN_STATE_ID_LEAVE.
|
|
* id is NW_APP_RUN_STATE_ID_RESET.
|
|
*/
|
|
typedef struct _nw_app_node_run_other_info {
|
|
uint8_t result;
|
|
} nw_app_node_run_other_info_t;
|
|
|
|
/* sta neighbor node query req structure from cco to sta */
|
|
typedef struct _nw_app_neighbor_query_req {
|
|
/* query index */
|
|
uint16_t index;
|
|
/* query cnt */
|
|
uint8_t cnt;
|
|
} nw_app_neighbor_query_req;
|
|
|
|
/* sta neighbor node info uint structure */
|
|
typedef struct _nw_app_neighbor_node_info {
|
|
/* neighbor node mac address, little endian */
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
/* neighbor node tei */
|
|
uint16_t tei;
|
|
/* neighbor node proxy tei */
|
|
uint16_t proxy_tei;
|
|
/* neighbor node level */
|
|
uint8_t level;
|
|
/* success rate of uplink communication
|
|
* between neighbor node and local node
|
|
*/
|
|
uint8_t ul_sr;
|
|
/* success rate of downlink communication
|
|
* between neighbor node and local node
|
|
*/
|
|
uint8_t dl_sr;
|
|
/* success rate of uplink and downlink communication
|
|
* between neighbor node and local node
|
|
*/
|
|
uint8_t ul_dl_sr;
|
|
/* snr between neighbor node and local node */
|
|
int8_t snr;
|
|
/* signal attenuation between neighbor node and local node */
|
|
int8_t signal_attenuation;
|
|
} nw_app_neighbor_node_info_t;
|
|
|
|
/* sta neighbor node query resp structure from sta to cco */
|
|
typedef struct _nw_app_neighbor_query_resp {
|
|
/* neighbor node total cnt */
|
|
uint16_t total_cnt;
|
|
/* report cnt */
|
|
uint8_t cnt;
|
|
/* neighbor node info */
|
|
nw_app_neighbor_node_info_t node_info[0];
|
|
} nw_app_neighbor_query_resp;
|
|
|
|
/* sta transparent forwarding data for correct time */
|
|
typedef struct _nw_app_trans_module_corr_time {
|
|
/* port id, hplc 0x01 */
|
|
uint16_t port;
|
|
/* seq, start from 1 */
|
|
uint8_t seq;
|
|
/* reserved for future */
|
|
uint8_t reserved;
|
|
/* cco ntb */
|
|
uint32_t cco_ntb;
|
|
/* correct data */
|
|
uint8_t data[0];
|
|
} nw_app_trans_module_corr_time_t;
|
|
|
|
/* shenzhen load curve config di unit */
|
|
typedef struct _nw_app_lc_cfg_di_unit_sz {
|
|
/* di, see DL/T 645-2007 */
|
|
uint8_t di[PROTO_645_2007_DI_LEN];
|
|
/* collect interval time, unit is 1min */
|
|
uint8_t interval;
|
|
} nw_app_lc_cfg_di_unit_sz_t;
|
|
|
|
/* shenzhen load curve config di infomation */
|
|
typedef struct _nw_app_lc_cfg_di_info_sz {
|
|
/* meter type, see NW_APP_LR_METER_TYPE_XXX */
|
|
uint8_t meter_type;
|
|
/* di count */
|
|
uint8_t di_cnt;
|
|
/* di unit */
|
|
nw_app_lc_cfg_di_unit_sz_t di_unit[0];
|
|
} nw_app_lc_cfg_di_info_sz_t;
|
|
|
|
/* shenzhen load curve config infomation */
|
|
typedef struct _nw_app_lc_cfg_info_sz {
|
|
/* function code, see NW_APP_LR_FN_CFG_CLCT_INTERVAL_SZ */
|
|
uint8_t fn;
|
|
/* flag for start and stop, 0 is stop 1 is start */
|
|
uint8_t flag_start;
|
|
/* di infomation, see nw_app_lc_cfg_di_info_sz_t */
|
|
uint8_t di_info[0];
|
|
} nw_app_lc_cfg_info_sz_t;
|
|
|
|
/* shenzhen load curve interval time query dl */
|
|
typedef struct _nw_app_lc_interval_time_query_dl_sz {
|
|
/* function code, see NW_APP_LR_FN_QUERY_CLCT_INTERVAL_SZ */
|
|
uint8_t fn;
|
|
/* meter type, see NW_APP_LR_METER_TYPE_XXX */
|
|
uint8_t meter_type;
|
|
/* di count */
|
|
uint8_t di_cnt;
|
|
/* di, see DL/T 645-2007 */
|
|
uint32_t di[0];
|
|
} nw_app_lc_interval_time_query_dl_sz_t;
|
|
|
|
/* shenzhen load curve interval time query ul */
|
|
typedef struct _nw_app_lc_interval_time_query_ul_sz {
|
|
/* function code, see NW_APP_LR_FN_QUERY_CLCT_INTERVAL_SZ */
|
|
uint8_t fn;
|
|
/* meter type, see NW_APP_LR_METER_TYPE_XXX */
|
|
uint8_t meter_type;
|
|
/* di count */
|
|
uint8_t di_cnt;
|
|
/* di unit */
|
|
nw_app_lc_cfg_di_unit_sz_t di_unit[0];
|
|
} nw_app_lc_interval_time_query_ul_sz_t;
|
|
|
|
/* shenzhen load curve collect data query dl and ul info */
|
|
typedef struct _nw_app_lc_data_query_info_sz {
|
|
/* di, see DL/T 645-2007 */
|
|
uint32_t di;
|
|
/* the specified time is seconds, minutes, hours,
|
|
* days and years use BCD code.
|
|
*/
|
|
uint8_t min;
|
|
uint8_t hour;
|
|
uint8_t day;
|
|
uint8_t mon;
|
|
uint8_t year;
|
|
/* curve point num to read */
|
|
uint8_t n;
|
|
/* uint8_t data[0] for ul */
|
|
} nw_app_lc_data_query_info_sz_t;
|
|
|
|
/* shenzhen load curve collect data query dl */
|
|
typedef struct _nw_app_lc_data_query_dl_sz {
|
|
/* function code, see NW_APP_LR_FN_READ_DI_DATA_SZ */
|
|
uint8_t fn;
|
|
/* meter type, see NW_APP_LR_METER_TYPE_XXX */
|
|
uint8_t meter_type;
|
|
/* di count */
|
|
uint8_t di_cnt;
|
|
/* data query info */
|
|
nw_app_lc_data_query_info_sz_t query_info[0];
|
|
} nw_app_lc_data_query_dl_sz_t;
|
|
|
|
/* shenzhen load curve collect data query ul */
|
|
typedef struct _nw_app_lc_data_query_ul_sz {
|
|
/* function code, see NW_APP_LR_FN_READ_DI_DATA_SZ */
|
|
uint8_t fn;
|
|
/* meter type, see NW_APP_LR_METER_TYPE_XXX */
|
|
uint8_t meter_type;
|
|
/* di count */
|
|
uint8_t di_cnt;
|
|
/* data, see nw_app_lr_data_query_info_ul_t */
|
|
uint8_t data[0];
|
|
} nw_app_lc_data_query_ul_sz_t;
|
|
|
|
/* NW load curve config infomation */
|
|
typedef struct _nw_app_lr_cfg_info {
|
|
/* function code, see NW_APP_LR_FN_CFG_CLCT_INTERVA */
|
|
uint8_t fn;
|
|
/* collect interval time, unit is 1min */
|
|
uint8_t interval;
|
|
} nw_app_lr_cfg_info_t;
|
|
|
|
/* NW load curve data read dl */
|
|
typedef struct _nw_app_lr_data_read_dl {
|
|
/* function code, see NW_APP_LR_FN_READ_DI_DATA */
|
|
uint8_t fn;
|
|
/* meter type, see NW_APP_LR_METER_TYPE_XXX */
|
|
uint8_t meter_type;
|
|
/* the specified time is seconds, minutes, hours,
|
|
* days and years use BCD code.
|
|
*/
|
|
uint8_t min;
|
|
uint8_t hour;
|
|
uint8_t day;
|
|
uint8_t mon;
|
|
uint8_t year;
|
|
/* curve point num to read */
|
|
uint8_t n;
|
|
/* interval time, unit is 1min */
|
|
uint8_t interval;
|
|
/* di count */
|
|
uint8_t di_cnt;
|
|
/* di */
|
|
uint32_t di[0];
|
|
} nw_app_lr_data_read_dl_t;
|
|
|
|
/* NW load curve di data ul */
|
|
typedef struct _nw_app_lr_di_data_ul {
|
|
/* di, see DL/T 645-2007 */
|
|
uint32_t di;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_lr_di_data_ul_t;
|
|
|
|
/* NW load curve data read ul */
|
|
typedef struct _nw_app_lr_data_read_ul {
|
|
/* function code, see NW_APP_LR_FN_READ_DI_DATA */
|
|
uint8_t fn;
|
|
/* meter type, see NW_APP_LR_METER_TYPE_XXX */
|
|
uint8_t meter_type;
|
|
/* the specified time is seconds, minutes, hours,
|
|
* days and years use BCD code.
|
|
*/
|
|
uint8_t min;
|
|
uint8_t hour;
|
|
uint8_t day;
|
|
uint8_t mon;
|
|
uint8_t year;
|
|
/* curve point num to read */
|
|
uint8_t n;
|
|
/* interval time, unit is 1min */
|
|
uint8_t interval;
|
|
/* di count */
|
|
uint8_t di_cnt;
|
|
/* di data, see nw_app_lr_di_data_ul_t */
|
|
uint8_t di_data[0];
|
|
} nw_app_lr_data_read_ul_t;
|
|
|
|
/* south power grid application broadcast cmd header */
|
|
typedef struct _nw_app_broadcast_cmd_hdr {
|
|
/* source address, little-endian */
|
|
uint8_t src_addr[IOT_MAC_ADDR_LEN];
|
|
/* destination address, little-endian */
|
|
uint8_t dst_addr[IOT_MAC_ADDR_LEN];
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_broadcast_cmd_hdr;
|
|
|
|
/* transfer payload from sta to sta */
|
|
typedef struct _nw_app_route_fwd {
|
|
/* source sta address, little endian */
|
|
uint8_t src_addr[IOT_MAC_ADDR_LEN];
|
|
/* destination sta address, little endian */
|
|
uint8_t dst_addr[IOT_MAC_ADDR_LEN];
|
|
/* reserved for future, default set as 0 */
|
|
uint16_t reserved;
|
|
/* data length */
|
|
uint16_t data_len;
|
|
/* data */
|
|
uint8_t data[0];
|
|
} nw_app_route_fwd_t;
|
|
|
|
/* define nw 21meter dev id len */
|
|
#define NW_APP_21METER_SERIAL_NUM_LEN (8)
|
|
#define NW_APP_21METER_YEAR_CODE_LEN (2)
|
|
#define NW_APP_21METER_VENDOR_CODE_LEN (2)
|
|
#define NW_APP_21METER_COMM_MODE_LEN (2)
|
|
#define NW_APP_21METER_DEV_TYPE_LEN (2)
|
|
#define NW_APP_21METER_CUS_CODE_LEN (2)
|
|
|
|
/* define nw 21meter device type */
|
|
#define NW_APP_21METER_DEV_TYPE_1P (1)
|
|
#define NW_APP_21METER_DEV_TYPE_3P (2)
|
|
#define NW_APP_21METER_DEV_TYPE_CCTT (3)
|
|
#define NW_APP_21METER_DEV_TYPE_CT1 (4)
|
|
#define NW_APP_21METER_DEV_TYPE_CT2 (5)
|
|
|
|
/* define nw 21meter customer code for dev id */
|
|
#define NW_APP_DEV_ID_CUS_CODE_GUANGDONG (3)
|
|
#define NW_APP_DEV_ID_CUS_CODE_GUANGXI (4)
|
|
#define NW_APP_DEV_ID_CUS_CODE_YUNNAN (5)
|
|
#define NW_APP_DEV_ID_CUS_CODE_GUIZHOU (6)
|
|
#define NW_APP_DEV_ID_CUS_CODE_HAINAN (7)
|
|
#define NW_APP_DEV_ID_CUS_CODE_GUANGZHOU (8)
|
|
#define NW_APP_DEV_ID_CUS_CODE_SHENZHEN (9)
|
|
|
|
/* define nw 21meter customer code for module mac */
|
|
#define NW_APP_MODULR_CUS_CODE_GUANGDONG (1)
|
|
#define NW_APP_MODULR_CUS_CODE_GUANGXI (2)
|
|
#define NW_APP_MODULR_CUS_CODE_YUNNAN (3)
|
|
#define NW_APP_MODULR_CUS_CODE_GUIZHOU (4)
|
|
#define NW_APP_MODULR_CUS_CODE_HAINAN (5)
|
|
#define NW_APP_MODULR_CUS_CODE_GUANGZHOU (6)
|
|
#define NW_APP_MODULR_CUS_CODE_SHENZHEN (7)
|
|
|
|
/* module dev id for nw 21meter */
|
|
typedef struct _nw_app_21meter_module_dev_id {
|
|
/* serial number */
|
|
uint8_t serial_number[NW_APP_21METER_SERIAL_NUM_LEN];
|
|
/* year code */
|
|
uint8_t year_code[NW_APP_21METER_YEAR_CODE_LEN];
|
|
/* vendor code */
|
|
uint8_t vendor_code[NW_APP_21METER_VENDOR_CODE_LEN];
|
|
/* chip vendor code */
|
|
uint8_t chip_vendor_code[NW_APP_21METER_VENDOR_CODE_LEN];
|
|
/* reserve for future */
|
|
uint8_t reserve;
|
|
/* communication mode */
|
|
uint8_t comm_mode[NW_APP_21METER_COMM_MODE_LEN];
|
|
/* device type */
|
|
uint8_t dev_type[NW_APP_21METER_DEV_TYPE_LEN];
|
|
/* code type */
|
|
uint8_t code_type;
|
|
/* prefecture customer code */
|
|
uint8_t prefecture_code[NW_APP_21METER_CUS_CODE_LEN];
|
|
/* provincial customer code */
|
|
uint8_t provincial_code[NW_APP_21METER_CUS_CODE_LEN];
|
|
} nw_app_21meter_module_dev_id_t;
|
|
|
|
/* NW 21meter module mac temp data, from serial_number to
|
|
* reserve1 is module mac valid data
|
|
*/
|
|
typedef struct _nw_app_21meter_module_mac_tmp {
|
|
/* invalid data */
|
|
uint32_t invalid_data_1 : 8,
|
|
/* serial number */
|
|
serial_number : 24;
|
|
/* year code */
|
|
uint32_t year_code : 6,
|
|
/* vendor code */
|
|
vendor_code : 7,
|
|
/* reserve for future, delaut value is 0 */
|
|
reserve : 5,
|
|
/* device type, see NW_APP_21METER_DEV_TYPE_XXX */
|
|
dev_type : 3,
|
|
/* customer code, see NW_APP_MODULR_CUS_CODE_XXX */
|
|
cus_code : 3,
|
|
/* invalid data */
|
|
invalid_data_2 : 8;
|
|
} nw_app_21meter_module_mac_tmp_t;
|
|
|
|
/* SPG product testing function set mac request emessage layout */
|
|
typedef struct _nw_app_pt_set_mac_req {
|
|
/* node address -- little endian */
|
|
uint8_t node_addr[IOT_MAC_ADDR_LEN];
|
|
/* mac address to be set -- little endian */
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
} nw_app_pt_set_mac_req_t;
|
|
|
|
/* SPG product testing function set mac request emessage layout */
|
|
typedef struct _nw_app_pt_set_mac_rsp {
|
|
/* node address -- little endian */
|
|
uint8_t node_addr[IOT_MAC_ADDR_LEN];
|
|
/* mac address -- little endian */
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
} nw_app_pt_set_mac_rsp_t;
|
|
|
|
/* SPG product testing query message layout */
|
|
typedef struct _nw_app_pt_qr {
|
|
/* node address -- little endian */
|
|
uint8_t node_addr[IOT_MAC_ADDR_LEN];
|
|
} nw_app_pt_qr_t;
|
|
|
|
/* SPG product testing read version response message layout */
|
|
typedef struct _nw_app_pt_ver_rsp {
|
|
/* node address -- little endian */
|
|
uint8_t node_addr[IOT_MAC_ADDR_LEN];
|
|
/* vendor_id */
|
|
uint16_t vendor_id;
|
|
/* chip_id */
|
|
uint16_t chip_id;
|
|
/* external software version */
|
|
uint16_t ver_ext;
|
|
uint8_t ver_ext_day;
|
|
uint8_t ver_ext_mon;
|
|
uint8_t ver_ext_year;
|
|
|
|
uint32_t ver_chip_hw;
|
|
uint8_t ver_chip_hw_day;
|
|
uint8_t ver_chip_hw_mon;
|
|
uint8_t ver_chip_hw_year;
|
|
|
|
uint32_t ver_chip_sw;
|
|
uint8_t ver_chip_sw_day;
|
|
uint8_t ver_chip_sw_mon;
|
|
uint8_t ver_chip_sw_year;
|
|
/* internal software version */
|
|
uint8_t ver_inter_day;
|
|
uint8_t ver_inter_mon;
|
|
uint8_t ver_inter_year;
|
|
uint16_t ver_inter;
|
|
} nw_app_pt_ver_rsp_t;
|
|
|
|
typedef struct _nw_app_edge_computing_conf {
|
|
/* overvoltage monitor switch, 0 - open, others - close */
|
|
uint8_t overvoltage_switch;
|
|
/* overvoltage monitor threshold, unit is volt */
|
|
uint16_t overvoltage_threshold;
|
|
/* overvoltage monitor period, unit is 1min */
|
|
uint16_t overvoltage_period;
|
|
/* overvoltage collect abnormal report round */
|
|
uint8_t overvoltage_rpt_round;
|
|
/* undervoltage monitor switch, 0 - open, others - close */
|
|
uint8_t undervoltage_switch;
|
|
/* undervoltage monitor threshold, unit is volt */
|
|
uint16_t undervoltage_threshold;
|
|
/* undervoltage monitor period, unit is 1min */
|
|
uint16_t undervoltage_period;
|
|
/* undervoltage collect abnormal report round */
|
|
uint8_t undervoltage_rpt_round;
|
|
/* clock second pulse monitor switch, 0 - open, others - close */
|
|
uint8_t pulse_switch;
|
|
/* clock second pulse monitor threshold, unit is 1ms */
|
|
uint16_t pulse_threshold;
|
|
/* power meter health status monitor switch, 0 - open, others - close */
|
|
uint8_t health_status_switch;
|
|
/* power meter used time limit threshold, unit is year */
|
|
uint8_t used_limit_threshold;
|
|
} nw_app_edge_computing_conf_t;
|
|
|
|
typedef struct _nw_app_edge_computing_dl {
|
|
/* source address, little enadian */
|
|
uint8_t src_addr[IOT_MAC_ADDR_LEN];
|
|
/* destination address, little enadian */
|
|
uint8_t dest_addr[IOT_MAC_ADDR_LEN];
|
|
/* edge computing task id */
|
|
uint8_t edge_computing_task;
|
|
/* edge computing data */
|
|
nw_app_edge_computing_conf_t edge_conf;
|
|
} nw_app_edge_computing_dl_t;
|
|
|
|
typedef struct _nw_app_edge_computing_ul {
|
|
/* source address, little enadian */
|
|
uint8_t src_addr[IOT_MAC_ADDR_LEN];
|
|
/* destination address, little enadian */
|
|
uint8_t dest_addr[IOT_MAC_ADDR_LEN];
|
|
/* edge computing task id */
|
|
uint8_t edge_computing_task;
|
|
/* edge computing configuration result, 0 - success, others - fail */
|
|
uint8_t result;
|
|
} nw_app_edge_computing_ul_t;
|
|
|
|
typedef struct _nw_app_undervoltage_monitor_rpt {
|
|
/* event type, see NW_APP_EDGE_COMP_EVT_TYPE_XXX */
|
|
uint8_t evt_type;
|
|
/* power meter mac address, little endian, BCD format */
|
|
uint8_t pm_mac[IOT_MAC_ADDR_LEN];
|
|
/* power meter type, 0x00 - single phase, 0x01 - three phase */
|
|
uint8_t pm_type;
|
|
/* phase C min voltage in monitor */
|
|
uint16_t phase_c;
|
|
/* phase B min voltage in monitor */
|
|
uint16_t phase_b;
|
|
/* phase A min voltage in monitor */
|
|
uint16_t phase_a;
|
|
/* reserved for future */
|
|
uint8_t rsvd[3];
|
|
} nw_app_undervoltage_monitor_rpt_t;
|
|
|
|
typedef struct _nw_app_overvoltage_monitor_rpt {
|
|
/* event type, see NW_APP_EDGE_COMP_EVT_TYPE_XXX */
|
|
uint8_t evt_type;
|
|
/* power meter mac address, little endian, BCD format */
|
|
uint8_t pm_mac[IOT_MAC_ADDR_LEN];
|
|
/* power meter type, 0x00 - single phase, 0x01 - three phase */
|
|
uint8_t pm_type;
|
|
/* phase C max voltage in monitor */
|
|
uint16_t phase_c;
|
|
/* phase B max voltage in monitor */
|
|
uint16_t phase_b;
|
|
/* phase A max voltage in monitor */
|
|
uint16_t phase_a;
|
|
/* reserved for future */
|
|
uint8_t rsvd[3];
|
|
} nw_app_overvoltage_monitor_rpt_t;
|
|
|
|
typedef struct _nw_app_sec_pulse_monitor_rpt {
|
|
/* event type, see NW_APP_EDGE_COMP_EVT_TYPE_XXX */
|
|
uint8_t evt_type;
|
|
/* power meter mac address, little endian, BCD format */
|
|
uint8_t pm_mac[IOT_MAC_ADDR_LEN];
|
|
/* max pulse error in monitor, unit is 1ms */
|
|
uint16_t max_pulse_error;
|
|
/* reserved for future */
|
|
uint8_t rsvd[8];
|
|
} nw_app_sec_pulse_monitor_rpt_t;
|
|
|
|
typedef struct _nw_app_health_status_rpt {
|
|
/* event type, see NW_APP_EDGE_COMP_EVT_TYPE_XXX */
|
|
uint8_t evt_type;
|
|
/* power meter mac address, little endian, BCD format */
|
|
uint8_t pm_mac[IOT_MAC_ADDR_LEN];
|
|
/* power meter health value */
|
|
uint8_t value;
|
|
/* power meter error bitmap */
|
|
uint8_t err_bitmap[4];
|
|
/* reserved for future */
|
|
uint8_t rsvd[8];
|
|
} nw_app_health_status_rpt_t;
|
|
|
|
#pragma pack(pop) /* restore the pack status */
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* PROTO_NW_APP_H */
|