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

1498 lines
52 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_645_FJ_H
#define PROTO_645_FJ_H
/* smart grid internal header files */
#include "proto_645.h"
#ifdef __cplusplus
extern "C" {
#endif
/* transformer detect way */
#define PROTO_645_FJ_TSFM_DETECT_WAY_PERIOD (3)
/* same transformer but not in the white list */
#define PROTO_645_FJ_LIST_ERR_NOT_REG (1)
/* different transformer but in the white list */
#define PROTO_645_FJ_LIST_ERR_DIFF_TSFM (2)
/* type of error for DL/T 645-2007 */
#define PROTO_645_FJ_ERR_OK (0)
#define PROTO_645_FJ_ERR_OTHER (0x01)
#define PROTO_645_FJ_ERR_MAC_REPET (0x02)
#define PROTO_645_FJ_ERR_LEN (0x03)
#define PROTO_645_FJ_ERR_CRC (0x04)
#define PROTO_645_FJ_ERR_MAC_INVALID (0x06)
#define PROTO_645_FJ_ERR_RESP_TIMEOUT (0x0B)
#define PROTO_645_FJ_ERR_NOT_IN_NET (0x10)
/* control function code definition for fujian protocol */
#define PROTO_645_FJ_FN_ACTIVE_RPT (0x01)
/* DI: 645 protocol for fujian protocol */
/* data identification for freeze task */
#define PROTO_645_FJ_DI_FREEZE_TASK (0xEB000000u)
/* data identification for event report */
#define PROTO_645_FJ_DI_EVT_RPT (0xEB030001u)
/* data identification for power event report */
#define PROTO_645_FJ_DI_POWER_EVT_RPT (0xEB030002u)
/* data identification for tsfm detect */
#define PROTO_645_FJ_DI_TSFM_ERR_NODE_RPT (0xEB030101u)
#define PROTO_645_FJ_DI_TSFM_DETECT_START (0xEB030110u)
#define PROTO_645_FJ_DI_TSFM_RESULT_RPT (0xEB030111u)
#define PROTO_645_FJ_DI_QR_DIFF_TSFM_NODE (0xEB030112u)
/* data identification for sec node register */
#define PROTO_645_FJ_DI_QR_NOT_REG_NODE (0xEB030113u)
#define PROTO_645_FJ_DI_NODE_REG_START (0xEB030115u)
/* data identification for query chip id */
#define PROTO_645_FJ_DI_QR_CHIP_ID (0xEB030201u)
/* data identification for query module id */
#define PROTO_645_FJ_DI_QR_MOD_ID (0xEB030202u)
/* data identification for opposite phase query or report */
#define PROTO_645_FJ_DI_OPPOSITE_PHASE (0xEB030301u)
/* data identification for query module phase info */
#define PROTO_645_FJ_DI_QR_PHASE_INFO (0xEB030302u)
/* data identification for query module version info */
#define PROTO_645_FJ_DI_QR_MOD_VER (0xEB030303u)
/* data identification for query module working voltage */
#define PROTO_645_FJ_DI_QR_MOD_WORK_V (0xEB030304u)
/* data identification for read or write module time */
#define PROTO_645_FJ_DI_MOD_TM (0xEB030501u)
/* data identification for read or write correct time duration of module */
#define PROTO_645_FJ_DI_MOD_CT_DUR (0xEB030502u)
/* data identification for read the last correct time record of module */
#define PROTO_645_FJ_DI_MOD_LAST_CT_REC (0xEB030503u)
/* data identification for NTB correct time of module, only write */
#define PROTO_645_FJ_DI_MOD_CT_NTB (0xEB030505u)
/* data identification for read and write timer source of module */
#define PROTO_645_FJ_DI_MOD_TM_SOC (0xEB030510u)
/* data identification for query topo */
#define PROTO_645_FJ_DI_QR_TOPO (0xEB031001u)
/* data identification for query neighbour network information */
#define PROTO_645_FJ_DI_QR_NB_NW_INFO (0xEB031002u)
/* data identification for query frequency band */
#define PROTO_645_FJ_DI_QR_FREQ_BAND (0xEB031003u)
/* data identification for query chip id same as 10F112 */
#define PROTO_645_FJ_DI_QR_CHIP_ID_F112 (0xEB031004u)
/* data identification for operate white list */
#define PROTO_645_FJ_DI_OP_WL (0xEB031101u)
/* data identification for ctrl connect evt rpt */
#define PROTO_645_FJ_DI_CTRL_CONNECT_RPT (0xEB031201u)
/* data identification for query major node mac addr */
#define PROTO_645_FJ_DI_QR_MAJOR_NODE_MAC (0xEB032001u)
/* data identification for upgrade send file */
#define PROTO_645_FJ_DI_UPGRADE_SEND_FILE (0xEB030400u)
/* data identification for upgrade requery file bitmap */
#define PROTO_645_FJ_DI_UPGRADE_REQ_FILE (0xEB030401u)
/* data identification for event report config */
#define PROTO_645_FJ_DI_EVT_RPT_CFG (0xEB040001u)
/* data identification for query module reset count */
#define PROTO_645_FJ_DI_QR_MODULE_RESET_CNT (0xEB040201u)
/* data identification for query module power down count */
#define PROTO_645_FJ_DI_QR_PD_CNT (0xEB040202u)
/* data identification for set or query power down event valid time */
#define PROTO_645_FJ_DI_PD_EVT_VALID_TIME (0xEB040203u)
/* data identification for query module power record infomation */
#define PROTO_645_FJ_DI_QR_POWER_RECORD (0xEB040204u)
/* data identification for query power down record */
#define PROTO_645_FJ_DI_QR_POWER_RECORD_LAST1 (0xEB040301u)
#define PROTO_645_FJ_DI_QR_POWER_RECORD_LAST2 (0xEB040302u)
#define PROTO_645_FJ_DI_QR_POWER_RECORD_LAST3 (0xEB040303u)
#define PROTO_645_FJ_DI_QR_POWER_RECORD_LAST4 (0xEB040304u)
#define PROTO_645_FJ_DI_QR_POWER_RECORD_LAST5 (0xEB040305u)
#define PROTO_645_FJ_DI_QR_POWER_RECORD_LAST6 (0xEB040306u)
#define PROTO_645_FJ_DI_QR_POWER_RECORD_LAST7 (0xEB040307u)
#define PROTO_645_FJ_DI_QR_POWER_RECORD_LAST8 (0xEB040308u)
#define PROTO_645_FJ_DI_QR_POWER_RECORD_LAST9 (0xEB040309u)
#define PROTO_645_FJ_DI_QR_POWER_RECORD_LAST10 (0xEB04030Au)
/* data identification for query frozen task data
* the 1st freeze task data DI is PROTO_645_FJ_DI_QR_TASK_DATA + 1.
* ......
* the Nst freeze task data DI is PROTO_645_FJ_DI_QR_TASK_DATA + N.
*/
#define PROTO_645_FJ_DI_QR_TASK_DATA (0xEBE00000u)
/* data identification for set frozen task
* the 1st freeze task set DI is PROTO_645_FJ_DI_SET_TASK + 1.
* ......
* the Nst freeze task set DI is PROTO_645_FJ_DI_SET_TASK + N.
*/
#define PROTO_645_FJ_DI_SET_TASK (0xEBE00100u)
/* data identification for delete frozen task */
#define PROTO_645_FJ_DI_DEL_TASK (0xEBE0E000u)
/* data identification for set task record data max length */
#define PROTO_645_FJ_DI_SET_TASK_REC_MAX_LEN (0xEBE0E001u)
/* data identification for set number of reports allowed within 24 hours */
#define PROTO_645_FJ_DI_SET_RPT_MAX_CNT (0xEBE0E002u)
/* data identification for query task configuration statistics */
#define PROTO_645_FJ_DI_QR_TASK_STATE (0xEBE0E003u)
/* data identification for set duration of task suspension */
#define PROTO_645_FJ_DI_SET_TASK_STOP_DUR (0xEBE0E004u)
/* data identification for set random report time */
#define PROTO_645_FJ_DI_SET_RANDOM_RPT_TIME (0xEBE0E005u)
/* data identification for set report failed retry count */
#define PROTO_645_FJ_DI_SET_RPT_RETRY_COUNT (0xEBE0E006u)
/* data identification for meter multiple data item */
#define PROTO_645_FJ_DI_METER_MULTI_DATA_ITEM (0xEBE0E007u)
/* data identification for frozen task reset */
#define PROTO_645_FJ_DI_TAST_RESET (0xEBE0E008u)
/* data identification for report mode */
#define PROTO_645_FJ_DI_RPT_MODE (0xEBE0E009u)
/* data identification for multiple report param */
#define PROTO_645_FJ_DI_MULTI_RPT (0xEBE0E00Au)
/* data identification for report status */
#define PROTO_645_FJ_DI_RPT_STATUS (0xEBE0E00Bu)
/* data identification for multi di read */
#define PROTO_645_FJ_MULTI_DI_READ (0xEBEEEEEEu)
/* data identification for meter multi di read */
#define PROTO_645_FJ_METER_MULTI_DI_READ (0xEEEEEE00u)
/* define meter multi di read max di count */
#define PROTO_645_FJ_METER_MULTI_DI_CNT_MAX (5)
/* define the size of module id */
#define PROTO_645_FJ_MOD_ID_SIZE (32)
/* define module timer source from network */
#define PROTO_645_FJ_MOD_TM_SOC_NET (0)
/* define module timer source from power meter */
#define PROTO_645_FJ_MOD_TM_SOC_PM (1)
/* define correct time default duration of module, unit is 1min
* it is the duration of correct time when time source is network timer
* it is the duration of getting meter time when time source is meter timer
*/
#define PROTO_645_FJ_MOD_CT_DUR_DEFAULT (1400)
/* define correct time minimum duration of module, unit is 1min */
#define PROTO_645_FJ_MOD_CT_DUR_MIN (5)
/* max report node count */
#define PROTO_645_FJ_TOPO_RPT_MAX_CNT (22)
#define PROTO_645_FJ_MAX_RPT_NODE_CNT (7)
#define PROTO_645_FJ_WL_MAX_RPT_CNT (42) /* for white list */
/* max count of nodes for per request */
#define PROTO_645_FJ_REQ_NODE_MAX_CNT (30)
/* nid data length. */
#define PROTO_645_FJ_NID_LEN (3)
/* used for chip id */
#define PROTO_645_FJ_CHIP_ID_SERIAL_NUM_LEN (5)
#define PROTO_645_FJ_CHIP_ID_CRC_LEN (8)
#define PROTO_645_FJ_UPGRADE_CLEAR_FILE (0x00)
#define PROTO_645_FJ_UPGRADE_LOCAL_MODULE (0x03)
#define PROTO_645_FJ_UPGRADE_CCO_STA_MODULE (0x07)
#define PROTO_645_FJ_UPGRADE_STA_MODULE (0x08)
/* invalid segment index. In PROTO_645_FJ_DI_UPGRADE up link. */
#define PROTO_645_FJ_INVALID_SEG_INDEX (0xFFFFFFFF)
/* type of query freeze data, only for PROTO_645_FJ_DI_QR_TASK_DATA */
#define PROTO_645_FJ_TASK_QR_TYPE_WITH_TIME (0)
#define PROTO_645_FJ_TASK_QR_TYPE_NOTIME (1)
#define PROTO_645_FJ_TASK_QR_TYPE_WITH_TIME2 (2)
/* type of fujian protocol task, only for PROTO_645_FJ_DI_SET_TASK */
/* data freeze task */
#define PROTO_645_FJ_TASK_TYPE_FREEZE (1)
/* data inconsistency reporting task */
#define PROTO_645_FJ_TASK_TYPE_INCON_RPT (2)
/* data cross border reporting task */
#define PROTO_645_FJ_TASK_TYPE_CROSS_RPT (3)
/* data change out of limit task */
#define PROTO_645_FJ_TASK_TYPE_CHG_RPT (4)
/* task cycle uint type */
#define PROTO_645_FJ_TASK_CYCLE_UNIT_TYPE_SEC (0)
#define PROTO_645_FJ_TASK_CYCLE_UNIT_TYPE_MIN (1)
#define PROTO_645_FJ_TASK_CYCLE_UNIT_TYPE_HOUR (2)
#define PROTO_645_FJ_TASK_CYCLE_UNIT_TYPE_DAY (3)
/* type of freeze data format, only for PROTO_645_FJ_TASK_TYPE_FREEZE */
#define PROTO_645_FJ_FREEZE_DATA_FORMAT_NO_TS (0)
#define PROTO_645_FJ_FREEZE_DATA_FORMAT_WITH_TS (1)
#define PROTO_645_FJ_FREEZE_DATA_FORMAT_WITH_TSR (2)
/* upgrade file segment bitmap array length */
#define PROTO_645_FJ_FILE_SEGMENT_ARRAY_LEN (128)
/* define the event report mode */
#define PROTO_645_FJ_EVT_RPT_MODE_GW 0
#define PROTO_645_FJ_EVT_RPT_MODE_EXT_FJ 1
#define PROTO_645_FJ_EVT_RPT_MODE_MAX 2
/* ctrl connect state */
#define PROTO_645_FJ_CTRL_STATE_DISCONNECTED (0)
#define PROTO_645_FJ_CTRL_STATE_CONNECTED (1)
/* multi di response data max len */
#define PROTO_645_FJ_MULTI_DI_RESP_MAX_LEN 200
/* freeze task id min */
#define PROTO_FJ_FREEZE_TASK_ID_MIN (1)
/* freeze task id max */
#define PROTO_FJ_FREEZE_TASK_ID_MAX (253)
/* freeze task id min */
#define PROTO_FJ_FREEZE_645_TASK_ID_MIN (1)
/* freeze task id max */
#define PROTO_FJ_FREEZE_645_TASK_ID_MAX (126)
/* freeze task id min */
#define PROTO_FJ_FREEZE_698_TASK_ID_MIN (129)
/* freeze task id max */
#define PROTO_FJ_FREEZE_698_TASK_ID_MAX (253)
/* freeze task cfg info max lengtht */
#define PROTO_645_FJ_FREEZE_TASK_CFG_MAX_LEN (100)
/* freeze data desc max length */
#define PROTO_645_FJ_TASK_DESC_FREEZE_MAX_LEN (64)
/* freeze data desc max cnt */
#define PROTO_645_FJ_TASK_DESC_FREEZE_MAX_CNT (16)
/* cross data value max length */
#define PROTO_645_FJ_TASK_DESC_CROSS_VALUE_MAX_LEN (9)
/* change data value max length */
#define PROTO_645_FJ_TASK_DESC_CHANGE_VALUE_MAX_LEN (9)
/* cross data value cnt */
#define PROTO_645_FJ_TASK_DESC_CROSS_VALUE_MIN_CNT (2)
#define PROTO_645_FJ_TASK_DESC_CROSS_VALUE_MAX_CNT (6)
/* define delete all freeze task */
#define PROTO_645_FJ_TASK_DEL_ALL 0xff
/* define task stop max dur */
#define PROTO_645_FJ_TASK_STOP_DUR_MAX (1440)
/* node work power, BCD format, 12.0v */
#define PROTO_645_FJ_WORK_POWER (0x120)
/* upgrade tm windows unit: hour */
#define PROTO_645_FJ_UPGRADE_WINDOWS (24)
/* data cross border reporting task compare di count */
#define PROTO_645_FJ_CROSS_RPT_CMP_DI_CNT (1)
/* data change reporting task compare di count */
#define PROTO_645_FJ_CHANGE_RPT_CMP_DI_CNT (1)
/* freeze data response result */
#define PROTO_645_FJ_READ_RESP_DATA_INVALID (0)
#define PROTO_645_FJ_READ_RESP_DATA_OK (1)
#define PROTO_645_FJ_READ_RESP_DATA_OVERFLOW (2)
/* freeze data response max len */
#define PROTO_645_FJ_RESP_DATA_MAX_LEN (220)
/* multi data read di data max length */
#define PROTO_645_FJ_MULTI_DI_DATA_MAX_LEN (64)
/* multi data read di data min length */
#define PROTO_645_FJ_MULTI_DI_DATA_MIN_LEN (4)
/* multi data read di max cnt */
#define PROTO_645_FJ_MULTI_DI_MAX_CNT (16)
/* multi data read di min cnt */
#define PROTO_645_FJ_MULTI_DI_MIN_CNT (1)
/* maximum num of retrans of freeze tasks whose cycle is less than 5 min */
#define PROTO_645_FJ_FREEZE_TASK_RERPT_CNT_MAX (5)
/* default num of retrans of freeze tasks whose cycle is less than 5 min */
#define PROTO_645_FJ_FREEZE_TASK_RERPT_CNT_DEF (1)
/* maximum num of retrans of non-freeze tasks or cycle is greater than 5 min */
#define PROTO_645_FJ_NON_FREEZE_TASK_RERPT_CNT_MAX (8)
/* default num of retrans of non-freeze tasks or cycle is greater than 5 min */
#define PROTO_645_FJ_NON_FREEZE_TASK_RERPT_CNT_DEF (2)
/* maximum num of meter multiple data item flag*/
#define PROTO_645_FJ_METET_MULT_DATA_ITEM_MAX (1)
/* default num of meter multiple data item flag */
#define PROTO_645_FJ_METET_MULT_DATA_ITEM_DEF (1)
/* report mode */
#define PROTO_645_FJ_REPORT_MODE_645 (0)
#define PROTO_645_FJ_REPORT_MODE_698 (1)
/* define freeze task group */
#define PROTO_645_FJ_TASK_GROUP_UNKNOWN (0)
#define PROTO_645_FJ_TASK_GROUP_645 (1)
#define PROTO_645_FJ_TASK_GROUP_698 (2)
#pragma pack(push) /* save the pack status */
#pragma pack(1) /* 1 byte align */
typedef struct _proto_645_fj_write_data_head {
/* password */
uint8_t password[PROTO_645_2007_PASSWORD_LEN];
/* operator code */
uint8_t operator[PROTO_645_2007_OPERATOR_LEN];
/* data */
uint8_t data[0];
} proto_645_fj_write_data_head_t;
typedef struct _proto_645_fj_set_major_node_mac {
/* major node mac address, little endian */
uint8_t mac[IOT_MAC_ADDR_LEN];
} proto_645_fj_set_major_node_mac_t;
typedef struct _proto_645_fj_node_reg_enable {
/* sec node register timeout, unit is 1min */
uint16_t timeout;
} proto_645_fj_node_reg_enable_t;
typedef struct _proto_645_fj_power_evt_rpt {
/* power event type, 0 - power down, 1 - power up */
uint8_t evt_type;
/* current report count */
uint8_t rpt_cnt;
/* node mac address data */
uint8_t data[0];
} proto_645_fj_power_evt_rpt_t;
typedef struct _proto_645_fj_ctrl_connect_evt_rpt {
/* connect state, see PROTO_645_FJ_CTRL_STATE_XXX */
uint8_t state;
/* ctrl mac address, little endian */
uint8_t ctrl_mac[IOT_MAC_ADDR_LEN];
} proto_645_fj_ctrl_connect_evt_rpt_t;
typedef struct _proto_645_fj_tsfm_enable {
/* transformer detect way, see PROTO_645_FJ_TSFM_DETECT_WAY_XXX */
uint8_t tsfm_detect_way;
/* tsfm detect timeout, unit is 1min */
uint16_t timeout;
} proto_645_fj_tsfm_enable_t;
typedef struct _proto_645_fj_qr_diff_tsfm_node_dl {
/* start index, start from 1 */
uint16_t start_index;
/* request count */
uint8_t node_count;
} proto_645_fj_qr_diff_tsfm_node_dl_t;
typedef struct _proto_645_fj_qr_diff_tsfm_node_ul {
/* total different tsfm node count in network topo */
uint16_t total_count;
/* acknowledge node count */
uint8_t ack_node_count;
/* node mac address - little endian */
uint8_t mac[0][IOT_MAC_ADDR_LEN];
} proto_645_fj_qr_diff_tsfm_node_ul_t;
typedef struct _proto_645_fj_qr_not_reg_node_dl {
/* start index, start from 1 */
uint16_t start_index;
/* request count */
uint8_t node_count;
} proto_645_fj_qr_not_reg_node_dl_t;
typedef struct _proto_645_fj_qr_not_reg_node_ul {
/* total not register node count in network topo */
uint16_t total_count;
/* acknowledge node count */
uint8_t ack_node_count;
/* node mac address - little endian */
uint8_t mac[0][IOT_MAC_ADDR_LEN];
} proto_645_fj_qr_not_reg_node_ul_t;
typedef struct _proto_645_fj_list_abnormal_node_rpt {
/* report sequence */
uint8_t err_type;
/* tsfm address info, little endian */
uint8_t tsfm_addr[IOT_MAC_ADDR_LEN];
/* detect successful rate, range 0 - 100 */
uint8_t success_rate;
} proto_645_fj_list_abnormal_node_rpt_t;
typedef struct _proto_645_fj_tsfm_result_rpt {
/* tsfm detect used time, unit is 1min */
uint16_t used_time;
/* same tsfm node count */
uint16_t same_tsfm_cnt;
/* different tsfm node count */
uint16_t diff_tsfm_cnt;
} proto_645_fj_tsfm_result_rpt_t;
/* request topo info */
typedef struct _proto_645_fj_query_topo_dl {
/* start index, 0 means major node */
uint16_t start_index;
/* request count */
uint8_t node_count;
} proto_645_fj_query_topo_dl_t;
/* sec node network topo info */
typedef struct _proto_645_fj_node_info_for_topo {
/* node mac address - little endian */
uint8_t mac[IOT_MAC_ADDR_LEN];
/* node identity */
uint16_t tei;
/* proxy node identity */
uint16_t pco_tei;
/* node level */
uint8_t level : 4;
/* node role */
uint8_t role : 4;
} proto_645_fj_node_info_for_topo_t;
/* report topo info to cctt */
typedef struct _proto_645_fj_query_topo_ul {
/* total node count in network topo */
uint16_t node_count;
/* node start index in network topo */
uint16_t node_start_index;
/* acknowledge node count */
uint8_t ack_node_count;
/* network topo info list of the node */
proto_645_fj_node_info_for_topo_t node_info[0];
} proto_645_fj_query_topo_ul_t;
typedef struct _proto_645_fj_net_info {
/* network count */
uint8_t total_node_cnt;
/* local nid */
uint8_t local_nid[PROTO_645_FJ_NID_LEN]; /* 3 bytes */
/* local mac */
uint8_t local_mac[IOT_MAC_ADDR_LEN];
/* neighbor network nid */
uint8_t nb_nid[0][PROTO_645_FJ_NID_LEN];
} proto_645_fj_net_info_t;
typedef struct _proto_645_fj_query_freq_band {
/* frequency band */
uint8_t freq_band;
} proto_645_fj_query_freq_band_t;
typedef struct _proto_645_fj_set_band {
/* set frequency band, see PLC_LIB_FREQ_BAND_XXX. */
uint8_t freq_band;
} proto_645_fj_set_band_t;
typedef struct _proto_645_fj_query_chip_info_dl {
/* start index, 1 means major node */
uint16_t start_index;
/* query count */
uint8_t node_count;
} proto_645_fj_query_chip_info_dl_t;
/* chip id information */
typedef struct _proto_645_fj_chip_id {
/* check code */
uint8_t check_code[PROTO_645_FJ_CHIP_ID_CRC_LEN];
/* device serial */
uint8_t dev_code[PROTO_645_FJ_CHIP_ID_SERIAL_NUM_LEN];
/* chip mode */
uint16_t chip_mode;
/* 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;
} proto_645_fj_chip_id_t;
/* node hardware information */
typedef struct _proto_645_fj_node_hw_info {
/* mac address, little endian */
uint8_t mac[IOT_MAC_ADDR_LEN];
/* device type, see IOT_PLC_DEV_TYPE_XXX */
uint8_t dev_type;
/* chip id information */
proto_645_fj_chip_id_t chip_id;
/* software version */
uint16_t sw_version;
} proto_645_fj_node_hw_info_t;
typedef struct _proto_645_fj_query_chip_info_ul {
/* total count */
uint16_t total_node_cnt;
/* start index */
uint16_t start_index;
/* report count */
uint8_t ack_node_count;
/* node information */
proto_645_fj_node_hw_info_t node_info[0];
} proto_645_fj_query_chip_info_ul_t;
typedef struct _proto_645_fj_query_wl_info_dl {
/* start index */
uint16_t start_index;
/* query count */
uint8_t count;
} proto_645_fj_query_wl_info_dl_t;
typedef struct _proto_645_fj_wl_sec_node_info {
uint8_t sec_node_mac[IOT_MAC_ADDR_LEN];
} proto_645_fj_wl_sec_node_info_t;
typedef struct _proto_645_fj_query_wl_info_ul {
/* total count */
uint16_t total_count;
/* report count */
uint8_t count;
/* secondary nodes info */
proto_645_fj_wl_sec_node_info_t sec_node[0];
} proto_645_fj_query_wl_info_ul_t;
typedef struct _proto_645_fj_set_wl_info {
/* operator, 0 - delete, 1 - add */
uint8_t op;
/* 0 means all, others means operator count */
uint8_t count;
/* mac list */
uint8_t mac_addr[0][IOT_MAC_ADDR_LEN];
} proto_645_fj_set_wl_info_t;
typedef struct _proto_645_fj_send_file_dl {
/* see PROTO_645_FJ_UPGRADE_XXX */
uint8_t action;
/* 0x01 -end frame, 0x00 - other frame */
uint8_t is_last_seg;
/* file command, fixed value: 0x01 */
uint8_t file_cmd;
/* total segment count */
uint16_t total_seg_cnt;
/* segment index */
uint32_t seg_index;
/* current segment length */
uint16_t cur_seg_len;
/* data */
uint8_t data[0];
} proto_645_fj_send_file_dl_t;
typedef struct _proto_645_fj_send_file_ul {
/* segment index in down link proto_645_fj_send_file_dl_t */
uint32_t segment_index;
} proto_645_fj_send_file_ul_t;
typedef struct _proto_645_fj_query_file_ul {
/* array index - The upgrade file segment bitmap is divided into arrays,
* a array index has 128 bytes
*/
uint16_t array_index;
/* array bitmap */
uint8_t array_bitmap[PROTO_645_FJ_FILE_SEGMENT_ARRAY_LEN];
} proto_645_fj_query_file_ul_t;
typedef struct _proto_645_fj_task_cycle {
/* cycle value */
uint16_t value : 11,
/* cycle unit, see PROTO_645_FJ_TASK_CYCLE_UNIT_TYPE_XXX */
unit : 3,
/* reserved */
rsvd : 1,
/* correcting flag. 0 means positive correction,
* 1 means negative correction.
*/
flag : 1;
} proto_645_fj_task_cycle_t;
typedef struct _proto_645_fj_task_time_domain {
/* cycle value */
uint8_t value : 6,
/* reserved */
rsvd : 1,
/* periodic regularity unit: 0: minute; 1: hours */
unit : 1;
}proto_645_fj_task_time_domain_t;
typedef struct _proto_645_fj_task_prio_desc {
/* task priority, only for PROTO_645_FJ_TASK_TYPE_FREEZE.
* 0 mean low priority, 1 mean high priority
*/
uint8_t prio : 1,
/* task data storage mode.
* 0 means power down storage.
* 1 means power down not storage.
*/
storage_mode : 1,
/* reserved */
rsvd_1 : 1,
/* data report enable
* 0 mean data not report.
* 1 mean data report
*/
flag_rpt : 1,
/* reserved */
rsvd_2 : 4;
} proto_645_fj_task_prio_desc_t;
/* structure for PROTO_645_FJ_DI_QR_TASK_DATA */
typedef struct _proto_645_fj_task_data_query_hdr_dl {
/* type of query freeze data, PROTO_645_FJ_TASK_QR_TYPE_WITH_TIME */
uint8_t type;
/* query di cnt */
uint8_t di_cnt;
/* di list */
uint32_t di_list[0];
} proto_645_fj_task_data_query_hdr_dl_t;
/* structure for PROTO_645_FJ_DI_QR_TASK_DATA */
typedef struct _proto_645_fj_task_data_query_tail_dl {
/* query cnt */
uint8_t cnt;
/* start time, PROTO_645_FJ_TASK_QR_TYPE_WITH_TIME for BCD data */
proto_645_07_time_ymdhms_t start;
} proto_645_fj_task_data_query_tail_dl_t;
/* structure for PROTO_645_FJ_DI_QR_TASK_DATA for DL/T 698 protocol format*/
typedef struct _proto_645_fj_task_data_query_hdr2_dl {
/* type of query freeze data, PROTO_645_FJ_TASK_QR_TYPE_WITH_TIME2 */
uint8_t type;
/* flag of compress */
uint8_t flag_compress;
/* query oad cnt */
uint8_t oad_cnt;
/* oad list */
uint32_t oad_list[0];
} proto_645_fj_task_data_query_hdr2_dl_t;
/* structure for PROTO_645_FJ_DI_QR_TASK_DATA for DL/T 698 protocol format */
typedef struct _proto_645_fj_task_data_query_tail2_dl {
/* query cnt */
uint8_t cnt;
/* start time */
/* data type of data_time_s, always 0x1c */
uint8_t data_type;
/* year: big endian, BIN code */
uint8_t year[2];
/* month: BIN code */
uint8_t month;
/* day: BIN code */
uint8_t day;
/* hour: BIN code */
uint8_t hour;
/* minute: BIN code */
uint8_t minute;
/* second: BIN code */
uint8_t second;
} proto_645_fj_task_data_query_tail2_dl_t;
/* structure for PROTO_645_FJ_DI_QR_TASK_DATA */
typedef struct _proto_645_fj_task_data_query_no_time_dl {
/* type of query freeze data, always PROTO_645_FJ_TASK_QR_TYPE_NOTIME */
uint8_t type;
/* latest Nth time */
uint8_t last_num;
} proto_645_fj_task_data_query_no_time_dl_t;
/* structure for PROTO_645_FJ_DI_QR_TASK_DATA */
typedef struct _proto_645_fj_task_data_query_hdr_ul {
/* task type, see PROTO_645_FJ_TASK_TYPE_XXX */
uint8_t type;
/* query result */
uint8_t result;
/* start time, BCD data */
proto_645_07_time_ymdhms_t start;
/* storage times */
uint16_t storage_times;
/* task cycle */
proto_645_fj_task_cycle_t task_cycle;
/* frozen points cnt for the response */
uint8_t frozen_point_cnt;
/* frozen di cnt */
uint8_t di_cnt;
/* di data, see proto_645_fj_task_data_query_di_unit_t */
uint8_t di_data[0];
} proto_645_fj_task_data_query_hdr_ul_t;
/* structure for PROTO_645_FJ_DI_QR_TASK_DATA */
typedef struct _proto_645_fj_task_data_query_di_unit {
/* di */
uint32_t di;
/* frozen point unit length */
uint8_t length;
/* frozen di data */
uint8_t di_data[0];
} proto_645_fj_task_data_query_di_unit_t;
/* structure for PROTO_645_FJ_DI_SET_TASK */
typedef struct _proto_645_fj_task_set_hdr {
/* type of task, see PROTO_645_FJ_TASK_TYPE_XXX */
uint8_t type;
/* task cycle */
proto_645_fj_task_cycle_t cycle;
/* read delay, unit is 1s */
uint8_t delay;
/* data saving times */
uint16_t save_cnt;
/* receive response data total length */
uint8_t rec_total_len;
/* description of data freezing priority,
* storage mode and execution times
*/
proto_645_fj_task_prio_desc_t prio_desc;
/* task exec times, 1~65535. 0xFFFF mean infinite loop. */
uint16_t exe_cnt;
/* task info desc
* when type is PROTO_645_FJ_TASK_TYPE_FREEZE,
* see proto_645_fj_task_set_freeze_hdr_t.
* when type is PROTO_645_FJ_TASK_TYPE_INCON_RPT,
* see proto_645_fj_task_set_incon_rpt_hdr_t.
* when type is PROTO_645_FJ_TASK_TYPE_CROSS_RPT,
* see proto_645_fj_task_set_cross_rpt_t.
* when type is PROTO_645_FJ_TASK_TYPE_CHG_RPT,
* see proto_645_fj_task_set_change_rpt_hdr_t.
*/
uint8_t task_info_desc[0];
} proto_645_fj_task_set_hdr_t;
/* structure for PROTO_645_FJ_DI_SET_TASK */
typedef struct _proto_645_fj_freeze_data_desc_hdr {
/* freeze data format type, see PROTO_645_FJ_FREEZE_DATA_FORMAT_XXX */
uint8_t format_type;
/* data length */
uint8_t data_len;
/* data */
uint8_t data[0];
} proto_645_fj_freeze_data_desc_hdr_t;
typedef struct _proto_645_fj_time_ymdhm {
/* minute: BCD code */
uint8_t minute;
/* hour: BCD code */
uint8_t hour;
/* day: BCD code */
uint8_t day;
/* month: BCD code */
uint8_t month;
/* year: BCD code */
uint8_t year;
} proto_645_fj_time_ymdhm_t;
/* structure for PROTO_645_FJ_DI_SET_TASK.
* this data structure only for PROTO_645_FJ_FREEZE_DATA_FORMAT_WITH_TS
*/
typedef struct _proto_645_fj_freeze_data_desc_tail {
/* time scale */
proto_645_fj_time_ymdhm_t ts;
/* time scale correction description */
proto_645_fj_task_cycle_t ts_desc;
} proto_645_fj_freeze_data_desc_tail_t;
/* structure for PROTO_645_FJ_DI_SET_TASK */
typedef struct _proto_645_fj_task_set_freeze_hdr {
/* freeze data cnt, max is 16 */
uint8_t data_cnt;
/* data desc */
uint8_t data_desc[0];
} proto_645_fj_task_set_freeze_hdr_t;
/* structure for PROTO_645_FJ_DI_SET_TASK */
typedef struct _proto_645_fj_task_set_incon_rpt_hdr {
/* triger cnt */
uint16_t triger_cnt;
/* compare di cnt */
uint8_t di_cnt;
/* di */
uint32_t di[0];
} proto_645_fj_task_set_incon_rpt_hdr_t;
/* structure for PROTO_645_FJ_DI_SET_TASK */
typedef struct _proto_645_fj_task_set_cross_rpt_hdr {
/* triger cnt */
uint16_t triger_cnt;
/* compare di */
uint32_t di;
/* length of crossing value */
uint8_t value_len;
/* crossing value cnt */
uint8_t cnt;
/* value list */
uint8_t value_list[0];
} proto_645_fj_task_set_cross_rpt_t;
/* structure for PROTO_645_FJ_DI_SET_TASK */
typedef struct _proto_645_fj_task_set_change_rpt_hdr {
/* triger cnt */
uint16_t triger_cnt;
/* compare di */
uint32_t di;
/* length of crossing value */
uint8_t value_len;
/* value list */
uint8_t value_list[0];
} proto_645_fj_task_set_change_rpt_hdr_t;
/* structure for PROTO_645_FJ_DI_SET_TASK.
* this data structure for proto_645_fj_task_set_incon_rpt_hdr_t
* and proto_645_fj_task_set_cross_rpt_t,
* proto_645_fj_task_set_change_rpt_hdr_t
*/
typedef struct _proto_645_fj_task_set_flw_rpt_hdr {
/* follow read di cnt */
uint8_t follow_di_cnt;
/* di */
uint32_t di[0];
} proto_645_fj_task_set_flw_rpt_hdr_t;
/* structure for PROTO_645_FJ_DI_DEL_TASK */
typedef struct _proto_645_fj_task_del_dl {
/* delete task cnt */
uint8_t del_cnt;
/* task num list */
uint8_t task_num[0];
} proto_645_fj_task_del_dl_t;
/* structure for PROTO_645_FJ_DI_SET_TASK_REC_MAX_LEN */
typedef struct _proto_645_fj_task_set_rec_max {
/* max length of recive data */
uint8_t rec_max_len;
} proto_645_fj_task_set_rec_max_t;
/* structure for PROTO_645_FJ_DI_SET_RPT_MAX_CNT */
typedef struct _proto_645_fj_task_set_rpt_max {
/* rpt max cnt within 24h */
uint8_t rpt_cnt;
} proto_645_fj_task_set_rpt_max_t;
/* structure for PROTO_645_FJ_DI_SET_RANDOM_RPT_TIME */
typedef struct _proto_645_fj_task_set_random_rpt {
/* rpt random time, percentage of task cycles, uint is 1%, range 10~90 */
uint8_t time;
} proto_645_fj_task_set_random_rpt_t;
/* structure for PROTO_645_FJ_DI_METER_MULTI_DATA_ITEM */
typedef struct _proto_645_fj_task_meter_muilt_data_item {
/* meter multiple data item
* 0 meter nonsupport multiple data item
* 1 meter support multiple data item
*/
uint8_t mult_data_item;
} proto_645_fj_task_meter_muilt_data_item_t;
/* structure for PROTO_645_FJ_DI_QR_TAST_STATE */
typedef struct _proto_645_fj_task_qr_state {
/* task configured cnt */
uint8_t task_cnt;
/* task num list */
uint8_t task_num[0];
} proto_645_fj_task_qr_state_t;
/* structure for PROTO_645_FJ_DI_SET_TAST_STOP_DUR */
typedef struct _proto_645_fj_task_set_task_stop_dur {
/* task stop dur, unit is 1min. BCD code */
uint8_t stop_dur[2];
} proto_645_fj_task_set_task_stop_dur_t;
/* structre for PROTO_645_FJ_DI_SET_RPT_RETRY_COUNT */
typedef struct _proto_645_fj_rpt_retry {
/* the lower 4 bits correspond to non frozen tasks and frozen tasks with
* a task cycle greater than or equal to 5 minutes.
*/
uint8_t retry_nonfreeze : 4,
/* the top 4 bits correspond to frozen tasks whose task cycle is less than
* 5 minutes
*/
retry_freeze : 4;
} proto_645_fj_rpt_retry_t;
typedef struct _proto_645_fj_multi_di_list {
/* data len */
uint8_t len;
/* data include di and di subsequent data */
uint8_t data[0];
} proto_645_fj_multi_di_list_t;
typedef struct _proto_645_fj_multi_di_read {
/* di count */
uint8_t di_cnt;
/* di list, see proto_645_fj_multi_di_list_t */
uint8_t di_list[0];
} proto_645_fj_multi_di_read_t;
typedef struct _proto_645_fj_multi_resp_data {
/* resp data len */
uint8_t data_len;
/* resp data */
uint8_t data[0];
} proto_645_fj_multi_resp_data_t;
typedef struct _proto_645_fj_mod_ver_info {
/* manufacture code in ASCII */
uint16_t vendor_id;
/* chip code in ASCII */
uint16_t chip_code;
/* day in BCD */
uint8_t day;
/* month in BCD */
uint8_t month;
/* year in BCD */
uint8_t year;
/* version in BCD */
uint8_t version[2];
}proto_645_fj_mod_ver_info_t;
/* config the event pin change reporting */
typedef struct _proto_645_fj_evt_rpt_cfg {
/* event report mode, see PROTO_645_FJ_EVT_RPT_MODE_XXX */
uint8_t mode :2,
/* reserved for future */
rsvd :4,
/* report module event pin displacement informationm, 0 - report when an
* event occurs, 1 - event occurrence and recovery are reported
*/
rpt_pin_type :1,
/* whether to report module event pin changes, 0 - not report, 1 - report */
rpt_pin_en :1;
} proto_645_fj_evt_rpt_cfg_t;
typedef struct _proto_645_fj_evt_rpt {
/* event pin state, 0 - recover, 1 - occur */
uint8_t state :1,
/* reserved for future */
rsvd :7;
} proto_645_fj_evt_rpt_t;
typedef struct _proto_645_fj_opposite_phase {
/* flag to mark if L/N reversed in Single-phase power meter or phase
* sequence reversed in Three-phase power meter.
*/
uint8_t opposite_phase;
} proto_645_fj_opposite_phase_t;
typedef struct _proto_645_fj_phase_info {
/* physical phase of the node, see PROTO_SG_PHASE_XXX */
uint8_t phase;
} proto_645_fj_phase_info_t;
typedef struct _proto_645_fj_module_reset_cnt {
/* module reset count */
uint16_t reset_cnt;
} proto_645_fj_module_reset_cnt_t;
typedef struct _proto_645_fj_pd_cnt {
/* module power down count */
uint16_t pd_cnt;
} proto_645_fj_pd_cnt_t;
typedef struct _proto_645_fj_pd_valid_time {
/* module power down valid time, unit is 1s, default 5s. */
uint8_t pd_valid_time;
} proto_645_fj_pd_valid_time_t;
typedef struct _proto_645_fj_multi_data {
/* multi di data length */
uint8_t data_len;
/* multi di data */
uint8_t data[0];
} proto_645_fj_multi_data_t;
typedef struct _proto_645_fj_multi_di {
/* multi di count */
uint8_t di_cnt;
/* multi di data */
uint8_t data[0];
} proto_645_fj_multi_di_t;
/* module timer source structure */
typedef struct _proto_645_fj_mod_tm_soc {
/* module timer source, BCD format, see PROTO_645_FJ_MOD_TM_SOC_XXX */
uint8_t tm_soc;
} proto_645_fj_mod_tm_soc_t;
/* module correct time record structure */
typedef struct _proto_645_fj_mod_ct_rec {
/* ntb correct time - stand for the delta between the ntb of CCO sending cmd
* and the ntb of STA receive cmd, unit is 1us, BIN format
* others - stand for 0
*/
uint32_t ntb_delta;
/* BCD format */
uint8_t second;
uint8_t minute;
uint8_t hour;
uint8_t day;
uint8_t month;
uint8_t year;
} proto_645_fj_mod_ct_rec_t;
/* module correct time duration structure */
typedef struct _proto_645_fj_mod_ct_dur {
/* module correct time duration, BCD format */
uint16_t ct_dur;
} proto_645_fj_mod_ct_dur_t;
typedef struct _proto_645_fj_ntb_corr_time {
/* ntb time */
uint32_t ntb;
/* bcast correct time, second, format is BCD */
uint8_t sec;
/* bcast correct time, minute, format is BCD */
uint8_t min;
/* bcast correct time, hour, format is BCD */
uint8_t hour;
/* bcast correct time, day, format is BCD */
uint8_t day;
/* bcast correct time, month, format is BCD */
uint8_t mon;
/* bcast correct time, year, format is BCD */
uint8_t year;
} proto_645_fj_ntb_corr_time_t;
typedef struct _proto_645_fj_qr_work_power {
/* node work power, BCD format, unit is v */
uint16_t work_power;
} proto_645_fj_qr_work_power_t;
/* module power down and power on record query structure */
typedef struct _proto_645_fj_pd_rec {
/* the time of power down */
proto_645_07_time_ymdhms_t power_down_time;
/* the time of power on */
proto_645_07_time_ymdhms_t power_on_time;
} proto_645_fj_pd_rec_t;
/* set freeze task reset structure */
typedef struct _proto_645_fj_freeze_task_reset {
/* reset task cnt */
uint8_t cnt;
/* reset task id */
uint8_t task_id[0];
} proto_645_fj_freeze_task_reset_t;
/* report mode structure */
typedef struct _proto_645_fj_report_mod {
/* report mode, see PROTO_645_FJ_REPORT_MODE_XXX */
uint8_t mode;
} proto_645_fj_report_mod_t;
/* multiple report param structure */
typedef struct _proto_645_fj_multi_rpt_param {
/* task id */
uint8_t id;
/* multi report cnt */
uint8_t cnt;
} proto_645_fj_multi_rpt_param_t;
/* multiple report param structure */
typedef struct _proto_645_fj_multi_rpt {
/* task cnt */
uint8_t cnt;
/* task param */
proto_645_fj_multi_rpt_param_t task_param[0];
} proto_645_fj_multi_rpt_t;
/* task report status structure */
typedef struct _proto_645_fj_task_rpt_status {
/* task id */
uint8_t id;
/* report fail cnt */
uint16_t fail_cnt;
/* report cnt */
uint16_t rpt_cnt;
} proto_645_fj_task_rpt_status_t;
/* set multiple report param structure */
typedef struct _proto_645_fj_rpt_status {
/* task cnt */
uint8_t cnt;
/* task status */
proto_645_fj_task_rpt_status_t task_status[0];
} proto_645_fj_rpt_status_t;
#pragma pack(pop) /* restore the pack status */
/**
* @brief: create query chip id msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: data.
* @param data_len: data length.
*/
iot_pkt_t *proto_645_fj_build_query_chip_id(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create query module id msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: data.
* @param data_len: data length.
*/
iot_pkt_t *proto_645_fj_build_query_mod_id(uint8_t *addr,
uint8_t *data, uint8_t data_len);
/**
* @brief: create query module version msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: data.
* @param data_len: data length.
*/
iot_pkt_t *proto_645_fj_build_query_mod_ver(uint8_t *addr,
uint8_t *data, uint8_t data_len);
/**
* @brief: create tsfm detect respond msg for the 645 protocol.
* @param addr: address, little endian.
* @param tsfm_detect_way: tsfm detect way see PROTO_645_FJ_TSFM_DETECT_WAY_XXX.
* @param timeout: transformer detect timeout, unit is 1min.
*/
iot_pkt_t *proto_645_fj_build_tsfm_enable_resp(uint8_t *addr,
uint8_t tsfm_detect_way, uint16_t timeout);
/**
* @brief: create enable sec node register respond msg for the 645 protocol.
* @param addr: address, little endian.
* @param timeout: sec node register timeout, unit is 1min.
*/
iot_pkt_t *proto_645_fj_build_node_reg_enable_resp(uint8_t *addr,
uint16_t timeout);
/**
* @brief: create query topo msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: topo data.
* @param data_len: topo data length.
*/
iot_pkt_t *proto_645_fj_build_qr_topo_resp(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create query different tsfm node infomation msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: different tsfm node data.
* @param data_len: data length.
*/
iot_pkt_t *proto_645_fj_build_qr_diff_tsfm_node(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create query not register node infomation msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: not register node data.
* @param data_len: data length.
*/
iot_pkt_t *proto_645_fj_build_qr_not_reg_node(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create query neighbour network information msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: topo data.
* @param data_len: topo data length.
*/
iot_pkt_t *proto_645_fj_build_qr_nb_nw_info_resp(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create query frequency band msg for the 645 protocol.
* @param addr: address, little endian.
* @param freq_band: frequency band.
*/
iot_pkt_t *proto_645_fj_build_qr_freq_band_resp(uint8_t *addr,
uint8_t freq_band);
/**
* @brief: create query chip id information msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: chip id information.
* @param data_len: chip id information length.
*/
iot_pkt_t *proto_645_fj_build_qr_chip_id_f112_resp(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create query white list information msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: white list information.
* @param data_len: white list information length.
*/
iot_pkt_t *proto_645_fj_build_qr_wl_resp(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create query major node mac address msg for the 645 protocol.
* @param addr: address, little endian.
*/
iot_pkt_t *proto_645_fj_build_qr_major_node_mac(uint8_t *addr);
/**
* @brief: create send upgrade file msg for the 645 protocol.
* @param addr: address, little endian.
* @param segment_index: segment index;
*/
iot_pkt_t *proto_645_fj_build_upgrade_send_file_ack(uint8_t *addr,
uint32_t segment_index);
/**
* @brief: create query upgrade file not recv data bitmap for the 645 protocol.
* @param addr: address, little endian.
* @param array_index: file bitmap array index.
* @param bitmap: file bitmap array bitmap.
*/
iot_pkt_t *proto_645_fj_build_upgrade_query_file_ack(uint8_t *addr,
uint16_t array_index, uint8_t *bitmap);
/**
* @brief: create whilte list abnormal node report msg for the 645 protocol.
* @param addr: address, little endian.
* @param err_type: err type, see PROTO_645_FJ_LIST_ERR_XXX.
* @param tsfm_addr: tsfm address info, little endian.
*/
iot_pkt_t *proto_645_fj_build_list_abnormal_node_rpt(uint8_t *addr,
uint8_t err_type, uint8_t *tsfm_addr);
/**
* @brief: create tsfm detect result report msg for the 645 protocol.
* @param addr: address, little endian.
* @param fn: function code, see PROTO_645_2007_FN_XXX.
* @param used_time: tsfm detect used time, unit is 1min.
* @param same_tsfm_cnt: same tsfm node count.
* @param diff_tsfm_cnt: different tsfm node count.
*/
iot_pkt_t *proto_645_fj_build_tsfm_detect_result(uint8_t *addr, uint8_t fn,
uint16_t used_time, uint16_t same_tsfm_cnt, uint16_t diff_tsfm_cnt);
/**
* @brief: create multi di response msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: pointer to data field.
* @param len: length of event data field.
*/
iot_pkt_t *proto_645_fj_build_multi_di_read_resp(uint8_t *addr, uint8_t *data,
uint8_t len);
/**
* @brief: create node power event report msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: power event information.
* @param data_len: power event information length.
*/
iot_pkt_t *proto_645_fj_build_power_evt_rpt(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create node work power report msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: work power information.
* @param data_len: work power information length.
*/
iot_pkt_t *proto_645_fj_build_work_power_rpt(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create node multi di data report msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: multi di data information.
* @param data_len: multi di data information length.
*/
iot_pkt_t *proto_645_fj_build_multi_di_rpt(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create opposite phase infomation msg for the 645 protocol.
* @param addr: address, little endian.
* @param fn: function code, see PROTO_645_2007_FN_XXX.
* @param opposite: flag to mark if L/N reversed in Single-phase power meter or
* phase sequence reversed in Three-phase power meter.
*/
iot_pkt_t *proto_645_fj_build_opposite_phase_info(uint8_t *addr, uint8_t fn,
uint8_t opposite);
/**
* @brief: create query module reset count msg for the 645 protocol.
* @param addr: address, little endian.
* @param reset_cnt: module reset count.
*/
iot_pkt_t *proto_645_fj_build_module_reset_cnt(uint8_t *addr,
uint16_t reset_cnt);
/**
* @brief: create query module power down count msg for the 645 protocol.
* @param addr: address, little endian.
* @param pd_cnt: module power down count.
*/
iot_pkt_t *proto_645_fj_build_module_pd_cnt(uint8_t *addr, uint16_t pd_cnt);
/**
* @brief: create query power down event valid time msg for the 645 protocol.
* @param addr: address, little endian.
* @param valid_time: power event valid time, unit is 1s.
*/
iot_pkt_t *proto_645_fj_build_pd_valid_time(uint8_t *addr, uint8_t valid_time);
/**
* @brief: create query node phase infomation response msg for the 645 protocol.
* @param addr: address, little endian.
* @param phase: physical phase of the node.
*/
iot_pkt_t *proto_645_fj_build_qr_phase_info(uint8_t *addr, uint8_t phase);
/**
* @brief: create ctrl event report msg for the 645 protocol.
* @param addr: address, little endian.
* @param connect_state: ctrl connect state, 0 - disconnect, 1 - connect.
* @return: NULL - for failed case.
* @return: otherwise - containing the 645 protocol with ctrl event report.
*/
iot_pkt_t *proto_645_fj_build_ctrl_evt_rpt(uint8_t *addr,
uint8_t connect_state);
/**
* @brief: create query event report config msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: config data.
* @param data_len: config data structure length.
*/
iot_pkt_t *proto_645_fj_build_qr_evt_rpt_cfg(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief create event report msg for the 645 protocol.
* @param addr: address, little endian.
* @param state: event pin state.
*/
iot_pkt_t *proto_645_fj_build_event_pin_report(uint8_t *addr, uint8_t state);
/**
* @brief: create 645 meter read msg for FUJIAN protocol.
* @param addr: address, little endian.
* @param data: pointer to data field.
* @param len: length of event data field.
* @param di: data identification.
* @param fn: function code.
*/
iot_pkt_t *proto_645_fj_build_mr_msg(uint8_t *addr, uint8_t *data,
uint8_t len, uint32_t di, uint8_t fn);
/**
* @brief: create query reset count msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: reset count data.
* @param data_len: reset count data structure length.
*/
iot_pkt_t *proto_645_fj_build_qr_rst_cnt(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create query power down count msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: power down count data.
* @param data_len: power down count data structure length.
*/
iot_pkt_t *proto_645_fj_build_qr_pd_cnt(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create 645 msg for FUJIAN protocol.
* @param addr: address, little endian.
* @param data: pointer to data field.
* @param len: length of event data field.
* @param di: data identification.
* @param fn: function code.
*/
iot_pkt_t *proto_645_fj_build_msg(uint8_t *addr, uint8_t *data,
uint8_t len, uint32_t di, uint8_t fn);
/**
* @brief: create 645 muilt di mr msg for FUJIAN protocol.
* @param addr: address, little endian.
* @param di_list: pointer to di list.
* @param di_cnt: di count.
*/
iot_pkt_t *proto_645_fj_build_muilt_mr_msg(uint8_t *addr, uint32_t *di_list,
uint8_t di_cnt);
/**
* @brief: create query module timer source msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: timer source.
* @param data_len: timer source structure length.
*/
iot_pkt_t *proto_645_fj_build_qr_tm_soc(uint8_t *addr, uint8_t *data,
uint8_t data_len);
/**
* @brief: create query correct time record msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: data.
* @param data_len: data length.
*/
iot_pkt_t *proto_645_fj_build_query_ct_rec(uint8_t *addr,
uint8_t *data, uint8_t data_len);
/**
* @brief: create query correct time duration msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: data.
* @param data_len: data length.
*/
iot_pkt_t *proto_645_fj_build_query_ct_dur(uint8_t *addr,
uint8_t *data, uint8_t data_len);
/**
* @brief: create query module time msg for the 645 protocol.
* @param addr: address, little endian.
* @param data: data.
* @param data_len: data length.
*/
iot_pkt_t *proto_645_fj_build_query_mod_tm(uint8_t *addr,
uint8_t *data, uint8_t data_len);
/**
* @brief: freeze task set msg check.
* @param set: task set message.
* @param len: length of message.
* @param group: task group, see PROTO_645_FJ_TASK_GROUP_XXX.
* @return: ERR_OK - for success case.
* @return: otherwise - for failed case. seee ERR_XXX.
*/
uint32_t proto_645_fj_task_set_msg_check(proto_645_fj_task_set_hdr_t *set,
uint8_t len, uint8_t group);
/**
* @brief: freeze task cycle time to second.
* @param cycle: cycle data structure.
* @return: cycle time, , uint is 1s.
*/
uint32_t proto_645_fj_task_cycle_to_sec(proto_645_fj_task_cycle_t *cycle);
/**
* @brief: freeze task info desc check.
* @param task_type: task type id, @see PROTO_645_FJ_TASK_TYPE_XXXX
* @param desc: task info desc
* @param len: length of task_info_desc
* @param group: task group, see PROTO_645_FJ_TASK_GROUP_XXX.
* @return ERR_OK mean valid, other value mean invalid desc.
*/
uint32_t proto_645_fj_task_info_desc_check(uint8_t task_type, uint8_t* desc,
uint8_t desc_len, uint8_t group);
/**
* @brief: freeze task option: time domain time to second.
* @param domain: task time domain structure.
* @param sec: out time, unit is 1s.
* @return: ERR_FAIL : invalid time domain.
* @return: ERR_OK : valid time domain.
*/
uint32_t proto_645_fj_task_time_domain_to_sec(
proto_645_fj_task_time_domain_t* domain, uint32_t* sec);
#ifdef __cplusplus
}
#endif
#endif /* PROTO_645_FJ_H */