2073 lines
		
	
	
		
			67 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			2073 lines
		
	
	
		
			67 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_GW_APP_H
							 | 
						||
| 
								 | 
							
								#define PROTO_GW_APP_H
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "os_types_api.h"
							 | 
						||
| 
								 | 
							
								#include "iot_utils_api.h"
							 | 
						||
| 
								 | 
							
								#include "proto_645.h"
							 | 
						||
| 
								 | 
							
								#include "iot_config_api.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 */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang application protocol version */
							 | 
						||
| 
								 | 
							
								#define GW_APP_PROTO_VERSION        0x01
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang application protocol port definitions */
							 | 
						||
| 
								 | 
							
								#define GW_APP_PORT_OTHER           0x11
							 | 
						||
| 
								 | 
							
								#define GW_APP_PORT_UPGRADE         0x12
							 | 
						||
| 
								 | 
							
								/* guo wang application protocol port definitions for production testing */
							 | 
						||
| 
								 | 
							
								#define GW_APP_PORT_PRODUCT_TEST    0xff
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang application protocol id definitions */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_CONCENTRATOR_METER_R      0x0001
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_ROUTE_METER_R             0x0002
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_CONCENTRATOR_P_METER_R    0x0003
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_CORRECTING_TIME           0x0004
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_COMM_TEST                 0x0006
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_EVENT_REPORT              0x0008
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* sta report minute collection function in V2.8 */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_MIN_CLCT_REPORT           0x000A
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_QUERY_SEC_NODE_REG        0x0011
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_START_SEC_NODE_REG        0x0012
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_STOP_SEC_NODE_REG         0x0013
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_ACK_NACK                  0x0020
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_DATA_COLLECT              0x0021
							 | 
						||
| 
								 | 
							
								/* extend protocol of heilongjiang */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_CLOCK_MANAGER             0x0028
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_CLOCK_QUERY               0x0029
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_START_UPGRADE             0x0030
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_STOP_UPGRADE              0x0031
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_TRANSFER_FILE_DATA        0x0032
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_TRANSFER_FILE_DATA_B      0x0033
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_QUERY_UPGTADE_STATUS      0x0034
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_EXECUTE_UPGRADE           0x0035
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_QUERY_STATION_INFO        0x0036
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_QUERY_MODULE_ID_INFO_HN   0x0037
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_CTRL_PROTO                0x0040
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_CTRL_PASSTHROUGH_YN       0x0041
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_RTC_TIMER_SYNC            0x0070
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_TSFM_DETECT               0x00A1
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_QUERY_MODULE_ID_INFO      0x00A2
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_ACCURATE_CORRECT_TIME     0x00A3
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* extend protocol of xi'an */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_NLI_ABNORMAL              0x00B0
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_STA_CORRECT_TIME          0x00B1
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_SET_MODULE_CLCT_PARAM     0x00B2
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_HISTORY_DATA_READ         0x00B3
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_QUERY_METER_PARAM         0x00B4
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* extend protocol of hunan */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_STA_JOIN_CHECK             0x00C1
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* extend protocol of v2.8 */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_CLCT_TASK_CONFIG_SET       0x00E2
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_CLCT_TASK_DATA_READ        0x00E3
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* extend protocol of zhe'jiang */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_STA_NET_LOCK_TIME         0x00F0
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* extend protocol of production testing,
							 | 
						||
| 
								 | 
							
								 * only for GW_APP_PORT_PRODUCT_TEST
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_PRODUCTION_TEST           0x00ff
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* extend protocol id definitions. */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_QUERY_VENDOR_INFO         0xA001
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_CORRECT_TIME_EXT          0xA002
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang application protocol frame header */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_header {
							 | 
						||
| 
								 | 
							
								    uint8_t     port;
							 | 
						||
| 
								 | 
							
								    uint16_t    id;
							 | 
						||
| 
								 | 
							
								    uint8_t     control;
							 | 
						||
| 
								 | 
							
								} gw_app_header_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang protocol version defintion */
							 | 
						||
| 
								 | 
							
								#define GW_APP_VERSION          1
							 | 
						||
| 
								 | 
							
								#define GW_APP_CONTROL          0
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* parameter for secondary node registration */
							 | 
						||
| 
								 | 
							
								#define GW_APP_SEC_NODE_REG_NO_FORCE_ACK    0
							 | 
						||
| 
								 | 
							
								#define GW_APP_SEC_NODE_REG_FORCE_ACK       1
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang protocol data type definition */
							 | 
						||
| 
								 | 
							
								#define GW_APP_DATA_TYPE_TRANSPARENT        0
							 | 
						||
| 
								 | 
							
								#define GW_APP_DATA_TYPE_645_1997           1
							 | 
						||
| 
								 | 
							
								#define GW_APP_DATA_TYPE_645_2007           2
							 | 
						||
| 
								 | 
							
								#define GW_APP_DATA_TYPE_69845              3
							 | 
						||
| 
								 | 
							
								#define GW_APP_DATA_TYPE_SEC_AUTH           4
							 | 
						||
| 
								 | 
							
								#define GW_APP_DATA_TYPE_LP_METER_RAW       15
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* low power meter type */
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_METER_TYPE_UNKNOWN        0
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_METER_TYPE_RPT_MOD_WM     4 /* report model water meter */
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_METER_TYPE_NORMAL_WM_GM   5 /* normal model water gas meter */
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_METER_TYPE_GAS_METER      6 /* gas meter */
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_METER_TYPE_HEAT_METER     7 /* heat meter */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* low power meter frame type */
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_METER_CMD_BCAST_QR        1
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_METER_CMD_RSSI_QR         2
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_METER_CMD_MR              3
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_METER_CMD_DEV_TYPE_QR     4
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* rssi threshold value */
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_METRE_RSSI_THRESHOLD      95
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* secondary node register parameter */
							 | 
						||
| 
								 | 
							
								#define GW_APP_REG_PARAM_QUERY_RESULT       0
							 | 
						||
| 
								 | 
							
								#define GW_APP_REG_PARAM_START_REG          1
							 | 
						||
| 
								 | 
							
								#define GW_APP_REG_PARAM_LOCK               2
							 | 
						||
| 
								 | 
							
								#define GW_APP_REG_PARAM_QR_NODE_PARAM      3
							 | 
						||
| 
								 | 
							
								#define GW_APP_REG_PARAM_LP_METER           4
							 | 
						||
| 
								 | 
							
								#define GW_APP_REG_PARAM_STORAGE_DEV_TYPE   5
							 | 
						||
| 
								 | 
							
								#define GW_APP_REG_PARAM_NETWORK_LOCK       6
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* low power dev type definition */
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_DEV_TYPE_HPLC_COLLECTOR   1
							 | 
						||
| 
								 | 
							
								#define GW_APP_LP_DEV_TYPE_LP_COLLECTOR     2
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang device type definition */
							 | 
						||
| 
								 | 
							
								#define GW_APP_DEV_TYPE_POWER_METER         0
							 | 
						||
| 
								 | 
							
								#define GW_APP_DEV_TYPE_COLLECTOR_T1        1
							 | 
						||
| 
								 | 
							
								#define GW_APP_DEV_TYPE_COLLECTOR_T2        2
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang event function code definition */
							 | 
						||
| 
								 | 
							
								/* downlink function code */
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_FN_CONF_ACK            1
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_FN_ALLOW_RPT           2
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_FN_FORBID_RPT          3
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_FN_FULL_ACK            4
							 | 
						||
| 
								 | 
							
								/* uplink function code */
							 | 
						||
| 
								 | 
							
								/* event triggered by smart meter */
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_FN_METER_RPT           1
							 | 
						||
| 
								 | 
							
								/* event triggered by sta modular */
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_FN_STA_RPT             2
							 | 
						||
| 
								 | 
							
								/* event triggered by collector */
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_FN_COLLECTOR_RPT       3
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* bitmap type data */
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_TYPE_POWER_DOWN        1
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_TYPE_POWER_UP          2
							 | 
						||
| 
								 | 
							
								/* address type data */
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_TYPE_POWER_DOWN_ADDR   3
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_TYPE_POWER_UP_ADDR     4
							 | 
						||
| 
								 | 
							
								/* abnormal electric current event report for neutralwire and livewire */
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_TYPE_RPT_NLI_ABNORMAL  6
							 | 
						||
| 
								 | 
							
								/* phase type data */
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_TYPE_PHASE_SEQUENCE    0xA
							 | 
						||
| 
								 | 
							
								/* search meter result data */
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_TYPE_SEARCH_RESULT     0x32
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang frame priority definition */
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRIO_METER_READ              3
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRIO_CORRECTING_TIME         3
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRIO_EVENT_REPORT            3
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRIO_PING_TEST               3
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRIO_SEC_NODE_REG            2
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRIO_UPGRADE                 2
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRIO_COMM_TEST               2
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRIO_TSFM_DETECT             3
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRIO_SET_STA_CLCT_PARAM      3
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRIO_DEFAULT                 2
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRIO_PRIV_ACK                2
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* the max meter reading message length supported by Guowang concurrent
							 | 
						||
| 
								 | 
							
								 * meter reading, only for non-645 protocols.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define GW_APP_CON_MR_MAX_MSG_LEN           2000
							 | 
						||
| 
								 | 
							
								/* the max number of meter reading messages supported by Guowang concurrent
							 | 
						||
| 
								 | 
							
								 * meter reading, only for 645 protocols.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define GW_APP_CON_MR_MAX_MSG_CNT           13
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang upgrade block size definition */
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_BLOCK_1              100
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_BLOCK_2              200
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_BLOCK_3              300
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_BLOCK_4              400
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_BLOCK_MAX            GW_APP_UPGRADE_BLOCK_4
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang upgrade state */
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_ST_IDLE              0
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_ST_RECVING           1
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_ST_RECV_DONE         2
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_ST_EXECUTING         3
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_ST_TRAIL_RUN         4
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* OK to upgrade */
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_OK                   0
							 | 
						||
| 
								 | 
							
								/* receive request in invalid state */
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_STATE_ERR            1
							 | 
						||
| 
								 | 
							
								/* same version. don't upgrade */
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_ERR_SAME_VERSION     2
							 | 
						||
| 
								 | 
							
								/* flash operation error */
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_FLASH_ERROR          3
							 | 
						||
| 
								 | 
							
								/* don't upgrade in trail run state*/
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_TRAIL_RUN_REJ        4
							 | 
						||
| 
								 | 
							
								/* upgrade err because no memory */
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_ERR_NO_MEM           5
							 | 
						||
| 
								 | 
							
								/* block size error */
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_ERR_BLOCK_SIZE       6
							 | 
						||
| 
								 | 
							
								/* unknown error */
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_OTHER_ERR            7
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang upgrade block query definition */
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_QUERY_ALL_BLOCK          0xFFFF
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_QUERY_TRANSFER_ONGOING   0
							 | 
						||
| 
								 | 
							
								#define GW_APP_UPGRADE_QUERY_TRANSFER_DONE      1
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* station info element ID definition */
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_ID_VENDOR_ID        0
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_ID_VERSION          1
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_ID_BOOTLOADER       2
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_ID_CRC              3
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_ID_FILE_LEN         4
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_ID_DEV_TYPE         5
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_ID_MAX              5
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_VENDOR_ID_LEN       2
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_VERSION_LEN         2
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_BOOTLOADER_LEN      1
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_CRC_LEN             4
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_FILE_SIZE_LEN       4
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_DEV_TYPE_LEN        1
							 | 
						||
| 
								 | 
							
								/* max element length */
							 | 
						||
| 
								 | 
							
								#define GW_APP_STA_INFO_MAX_LEN             4
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang power off bitmap TEI definitions */
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_TEI_FIRST              (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_TEI_LAST               (PLC_NETWORK_SCALE)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define GW_APP_EVENT_TEI_IS_VALID(__tei) \
							 | 
						||
| 
								 | 
							
								    ((__tei) >= GW_APP_EVENT_TEI_FIRST && (__tei) <= GW_APP_EVENT_TEI_LAST)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang tei to bitmap index conversion */
							 | 
						||
| 
								 | 
							
								#define GW_APP_TEI_TO_BM(tei) (tei + 1)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang bitmap index to tei conversion */
							 | 
						||
| 
								 | 
							
								#define GW_APP_BM_TO_TEI(bm)  ((uint16_t)((bm) - 1))
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang controller sub protocol Q/GDW 1376.2 */
							 | 
						||
| 
								 | 
							
								#define GW_APP_CTRL_PROTO_3762              (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang controller sub protocol passthrough */
							 | 
						||
| 
								 | 
							
								#define GW_APP_CTRL_PROTO_PASSTHROUGH       (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang controller primary request message flag */
							 | 
						||
| 
								 | 
							
								#define GW_APP_CTRL_PRM_MASTER              (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_CTRL_PRM_SLAVE               (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer detection feature type */
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_FEATURE_INVALID         (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_FEATURE_VOLTAGE         (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_FEATURE_FREQUENCY       (2)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_FEATURE_PERIOD          (3)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_FEATURE_POWER_FACTOR    (4)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_FEATURE_CURRENT         (5)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_FEATURE_SNR             (6)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer detection feature collection type */
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_START           (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_COLLECT         (2)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_REPORT          (3)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_QUERY           (4)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_RESULT          (5)
							 | 
						||
| 
								 | 
							
								/* set transformer address */
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_SET_TSFM_ADDR   (10)
							 | 
						||
| 
								 | 
							
								/* delete transformer address */
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_DEL_TSFM_ADDR   (11)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_QUERY_PW        (180)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_RESULT_PW       (181)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer detect result */
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_DETECT_RET_UNKNOWN      (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_DETECT_RET_SAME         (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_DETECT_RET_DIFFERENT    (2)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* collect type */
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_TYPE_DEFAULT    (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_TYPE_FALLING    (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_TYPE_RISING     (2)
							 | 
						||
| 
								 | 
							
								#define GW_APP_TSFM_COLLECT_TYPE_EDGE       (3)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* guo wang protocol phase definition */
							 | 
						||
| 
								 | 
							
								#define GW_APP_DATA_PHASE_DEFAULT           (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_DATA_PHASE_A                 (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_DATA_PHASE_B                 (2)
							 | 
						||
| 
								 | 
							
								#define GW_APP_DATA_PHASE_C                 (3)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* module id information length */
							 | 
						||
| 
								 | 
							
								#define GW_APP_MODULE_ID_INFO_LEN           (11)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* chip id information length */
							 | 
						||
| 
								 | 
							
								#define GW_APP_CHIP_ID_INFO_LEN             (24)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* id information type definition */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_INFO_TYPE_MOD             (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_INFO_TYPE_CHIP            (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_INFO_TYPE_MOD_EXT         (2)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* vendor information type definition */
							 | 
						||
| 
								 | 
							
								#define GW_APP_VENDOR_INFO_TYPE_VERSION     (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* device type definition */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_INFO_DEV_TYPE_METER_CONTROLLER    (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_INFO_DEV_TYPE_CONCENTRATOR        (2)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_INFO_DEV_TYPE_POWER_METER         (3)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_INFO_DEV_TYPE_REPEAT              (4)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_INFO_DEV_TYPE_COLLECTOR_2         (5)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_INFO_DEV_TYPE_COLLECTOR_1         (6)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ID_INFO_DEV_TYPE_THREE_PHASE_METER   (7)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define GW_APP_BCAST_TO_1STA_ENABLE                 (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* convert ntb to ms. in HW, the ntb clock freq is 25 mhz. */
							 | 
						||
| 
								 | 
							
								#define GW_APP_NTB_TO_MS(ntb)               ((ntb) / (25 * 1000))
							 | 
						||
| 
								 | 
							
								/* convert ms to ntb. in HW, the ntb clock freq is 25 mhz. */
							 | 
						||
| 
								 | 
							
								#define GW_APP_MS_TO_NTB(ms)                ((ms) * (25 * 1000))
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* phase sequence status is normal */
							 | 
						||
| 
								 | 
							
								#define GW_APP_PHASE_SEQ_STAUS_NORMAL         0
							 | 
						||
| 
								 | 
							
								/* phase sequence status is abnormal */
							 | 
						||
| 
								 | 
							
								#define GW_APP_PHASE_SEQ_STAUS_ABNORMAL       1
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* power meter type */
							 | 
						||
| 
								 | 
							
								#define GW_APP_PM_TYPE_SINGLE_PHASE        (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_PM_TYPE_THREE_PHASE         (1)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* zc type */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ZC_TYPE_FALLING_EDGE        (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ZC_TYPE_RISING_EDGE         (1)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* curve collect period, unit is 1min */
							 | 
						||
| 
								 | 
							
								#define GW_APP_CURVE_COLLECT_PERIOD_1MIN   (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_CURVE_COLLECT_PERIOD_5MIN   (5)
							 | 
						||
| 
								 | 
							
								#define GW_APP_CURVE_COLLECT_PERIOD_15MIN  (15)
							 | 
						||
| 
								 | 
							
								#define GW_APP_CURVE_COLLECT_PERIOD_30MIN  (30)
							 | 
						||
| 
								 | 
							
								#define GW_APP_CURVE_COLLECT_PERIOD_60MIN  (60)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* lock time function code for zhejiang protocol */
							 | 
						||
| 
								 | 
							
								#define GW_APP_LOCK_TIME_FN_INVALID        (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_LOCK_TIME_FN_SET            (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_LOCK_TIME_FN_QUERY          (2)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* secondary node network lock cmd control type */
							 | 
						||
| 
								 | 
							
								#define GW_APP_SEC_NODE_NW_LOCK_CMD_TYPE_UNLOCK     (0x00)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* clock manager cmd type */
							 | 
						||
| 
								 | 
							
								#define GW_APP_CLOCK_MANAGER_AUTO_CORR     (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_CLOCK_MANAGER_THRESHOLD     (3)
							 | 
						||
| 
								 | 
							
								#define GW_APP_CLOCK_MANAGER_CORR_TIME     (4)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* electric current length */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ELECTRIC_CURRENT_LEN        (3)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* abnormal electric current report time length for neutralwire and livewire */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ABNORMAL_TIME_DATA_LEN      (6)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* abnormal electric current command type for neutralwire and livewire */
							 | 
						||
| 
								 | 
							
								#define GW_APP_ABNORMAL_NLI_CMD_READ       (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ABNORMAL_NLI_CMD_READ_REPLY (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ABNORMAL_NLI_CMD_CFG        (2)
							 | 
						||
| 
								 | 
							
								#define GW_APP_ABNORMAL_NLI_CMD_CFG_REPLY  (3)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query module collect data respond result */
							 | 
						||
| 
								 | 
							
								#define GW_APP_QUERY_CLCT_RESULT_SUCCESS       (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_QUERY_CLCT_RESULT_TASK_NOT_EXIT (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_QUERY_CLCT_RESULT_NO_DATA       (2)
							 | 
						||
| 
								 | 
							
								#define GW_APP_QUERY_CLCT_RESULT_OTHER         (3)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* module collect parameter task number for gw v2.8 protocol */
							 | 
						||
| 
								 | 
							
								#define GW_APP_V28_CLCT_PARAM_TASK_NUM_MAX     (7)
							 | 
						||
| 
								 | 
							
								#define GW_APP_V28_CLCT_PARAM_TASK_NUM_ALL     (0xFF)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* module collect parameter config result for gw v2.8 protocol */
							 | 
						||
| 
								 | 
							
								#define GW_APP_V28_CLCT_PARAM_CFG_SUCCESS      (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_V28_CLCT_PARAM_CFG_FAIL         (1)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* sta report minute collection function code for v2.8 */
							 | 
						||
| 
								 | 
							
								#define GW_APP_MIN_CLCT_RPT_FN_CFG_SET_REQ     (1)
							 | 
						||
| 
								 | 
							
								#define GW_APP_MIN_CLCT_RPT_FN_CFG_QUERY_REQ   (2)
							 | 
						||
| 
								 | 
							
								#define GW_APP_MIN_CLCT_RPT_FN_CFG_QUERY_RESP  (3)
							 | 
						||
| 
								 | 
							
								#define GW_APP_MIN_CLCT_RPT_FN_DATA_REPORT     (4)
							 | 
						||
| 
								 | 
							
								#define GW_APP_MIN_CLCT_RPT_FN_DATA_QUERY_REQ  (5)
							 | 
						||
| 
								 | 
							
								#define GW_APP_MIN_CLCT_RPT_FN_DATA_QUERY_RESP (6)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* flag of sta report minute collection cfg for v2.8 */
							 | 
						||
| 
								 | 
							
								#define GW_APP_MIN_CLCT_RPT_CFG_FLAG_INVALID   (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_MIN_CLCT_RPT_CFG_FLAG_VALID     (1)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* respond flag of minute collection cfg */
							 | 
						||
| 
								 | 
							
								#define GW_APP_MIN_CLCT_RPT_CFG_NO_NEED_RSP    (0)
							 | 
						||
| 
								 | 
							
								#define GW_APP_MIN_CLCT_RPT_CFG_NEED_RSP       (1)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* production test cmd function code */
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRODUCT_TEST_FN_SET_MAC         (0x04)
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRODUCT_TEST_FN_QUERY_MAC       (0x05)
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRODUCT_TEST_FN_QUERY_CHIP_ID   (0x16)
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRODUCT_TEST_FN_QUERY_MOD_ID    (0x2a)
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRODUCT_TEST_FN_QUERY_VER       (0x2f)
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRODUCT_TEST_FN_QUERY_INTER     (0x3b)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* chip info data length for production test cmd */
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRODUCT_TEST_CHIP_LEN           24
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRODUCT_TEST_MODE_LEN           11
							 | 
						||
| 
								 | 
							
								#define GW_APP_PRODUCT_TEST_VER_LEN            2
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* low power meter reading extend data field */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_meter_r_lp_meter {
							 | 
						||
| 
								 | 
							
								    /* low power meter type, see GW_APP_LP_METER_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     lp_meter_type;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_meter_r_lp_meter_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* meter reading payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_meter_r_dl {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver             :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len      :6,
							 | 
						||
| 
								 | 
							
								    /* timout retry */
							 | 
						||
| 
								 | 
							
								                timeout_retry   :1,
							 | 
						||
| 
								 | 
							
								    /* nack retry */
							 | 
						||
| 
								 | 
							
								                nack_retry      :1,
							 | 
						||
| 
								 | 
							
								    /* max retry count */
							 | 
						||
| 
								 | 
							
								                max_retry       :2,
							 | 
						||
| 
								 | 
							
								    /* data type. see GW_APP_DATA_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								                data_type       :4,
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								                data_len        :12;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* communication time out used by sta while communicating with power meter
							 | 
						||
| 
								 | 
							
								     * and collector. unit is 100 ms.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint8_t     timeout;
							 | 
						||
| 
								 | 
							
								    /* options */
							 | 
						||
| 
								 | 
							
								    uint8_t     option;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_meter_r_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* meter reading payload from sta to cco */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_meter_r_ul {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* ack status */
							 | 
						||
| 
								 | 
							
								                ack_status  :4,
							 | 
						||
| 
								 | 
							
								    /* data type. see GW_APP_DATA_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								                data_type   :4,
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								                data_len    :12;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* options */
							 | 
						||
| 
								 | 
							
								    uint16_t    option;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_meter_r_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* start secondary node register payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_start_sec_node_reg {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* force ack flag */
							 | 
						||
| 
								 | 
							
								                force_ack   :1,
							 | 
						||
| 
								 | 
							
								    /* register parameter */
							 | 
						||
| 
								 | 
							
								                reg_param   :3,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :16;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								} gw_app_start_sec_node_reg_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query secondary node register payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_sec_node_reg_dl {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* force ack flag */
							 | 
						||
| 
								 | 
							
								                force_ack   :1,
							 | 
						||
| 
								 | 
							
								    /* register parameter. see GW_APP_REG_PARAM_XXX */
							 | 
						||
| 
								 | 
							
								                reg_param   :3,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :16;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								    /* source mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     source_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* destination mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     dest_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} gw_app_query_sec_node_reg_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query whether sec node supports minute collection for jiangsu */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_qr_storage_dev_type {
							 | 
						||
| 
								 | 
							
								    /* flag to mark if sec node support minute collection */
							 | 
						||
| 
								 | 
							
								    uint8_t     minute_clct :1,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :7;
							 | 
						||
| 
								 | 
							
								} gw_app_qr_storage_dev_type_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query secondary node register payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_power_meter_info {
							 | 
						||
| 
								 | 
							
								    /* power meter mac address */
							 | 
						||
| 
								 | 
							
								    uint8_t     pm_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* power meter data type. see GW_APP_DATA_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     data_type;
							 | 
						||
| 
								 | 
							
								    /* module type. see GW_APP_DEV_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     module_type :4,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :4;
							 | 
						||
| 
								 | 
							
								} gw_app_power_meter_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query secondary node parameters */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_sec_node_param {
							 | 
						||
| 
								 | 
							
								    /* physical phase of the device, bit0-2 means phaseA/B/C, set "1" to
							 | 
						||
| 
								 | 
							
								     * indicate which phase the device belongs to.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint16_t    phase           :3,
							 | 
						||
| 
								 | 
							
								    /* power meter type 0 is single phase meter 1 is three phase meter,
							 | 
						||
| 
								 | 
							
								     * this bit replaces the reserved bit.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								                meter_type      :1,
							 | 
						||
| 
								 | 
							
								    /* flag to mark if L/N reversed in Single-phase power meter or phase
							 | 
						||
| 
								 | 
							
								     * sequence reversed in Three-phase power meter.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								                opposite_phase  :1,
							 | 
						||
| 
								 | 
							
								    /* flag to mark if physical phase identification done */
							 | 
						||
| 
								 | 
							
								                detect_state    :1,
							 | 
						||
| 
								 | 
							
								    /* reserved for further */
							 | 
						||
| 
								 | 
							
								                rsvd1           :10;
							 | 
						||
| 
								 | 
							
								    /* reserved for further */
							 | 
						||
| 
								 | 
							
								    uint8_t     rsvd2;
							 | 
						||
| 
								 | 
							
								} gw_app_sec_node_param_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* secondary node network unlock cmd contol data for beijing */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_sec_node_net_unlock_data {
							 | 
						||
| 
								 | 
							
								    /* delay time, unit is 1min */
							 | 
						||
| 
								 | 
							
								    uint8_t     delay;
							 | 
						||
| 
								 | 
							
								    /* reserved for further */
							 | 
						||
| 
								 | 
							
								    uint8_t     rsvd[3];
							 | 
						||
| 
								 | 
							
								} gw_app_sec_node_net_unlock_data_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* secondary node network lock dl cmd for beijing */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_sec_node_net_lock_cmd_dl {
							 | 
						||
| 
								 | 
							
								    /* control type, see GW_APP_SEC_NODE_NW_LOCK_CMD_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     control_type;
							 | 
						||
| 
								 | 
							
								    /* control data len */
							 | 
						||
| 
								 | 
							
								    uint8_t     control_data_len;
							 | 
						||
| 
								 | 
							
								    /* reserved for further */
							 | 
						||
| 
								 | 
							
								    uint16_t    rsvd;
							 | 
						||
| 
								 | 
							
								    /* contol data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_sec_node_net_lock_cmd_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* secondary node network lock ul cmd for beijing */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_sec_node_net_lock_cmd_ul {
							 | 
						||
| 
								 | 
							
								    /* control type, see GW_APP_SEC_NODE_NW_LOCK_CMD_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     control_type;
							 | 
						||
| 
								 | 
							
								    /* control data len */
							 | 
						||
| 
								 | 
							
								    uint8_t     control_data_len;
							 | 
						||
| 
								 | 
							
								    /* reserved for further */
							 | 
						||
| 
								 | 
							
								    uint16_t    rsvd;
							 | 
						||
| 
								 | 
							
								} gw_app_sec_node_net_lock_cmd_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query secondary node register payload from sta to cco */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_sec_node_reg_ul {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver             :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len      :6,
							 | 
						||
| 
								 | 
							
								    /* status */
							 | 
						||
| 
								 | 
							
								                status          :1,
							 | 
						||
| 
								 | 
							
								    /* register parameter */
							 | 
						||
| 
								 | 
							
								                reg_param       :3,
							 | 
						||
| 
								 | 
							
								    /* power meter count */
							 | 
						||
| 
								 | 
							
								                pm_cnt          :8,
							 | 
						||
| 
								 | 
							
								    /* product type. see GW_APP_DEV_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								                product_type    :8;
							 | 
						||
| 
								 | 
							
								    /* device mac address */
							 | 
						||
| 
								 | 
							
								    uint8_t     dev_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* device ID */
							 | 
						||
| 
								 | 
							
								    uint8_t     dev_id[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								    /* if support minutes collect */
							 | 
						||
| 
								 | 
							
								    uint32_t    clct_min        :1,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved        :31;
							 | 
						||
| 
								 | 
							
								    /* source mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     source_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* destination mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     dest_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    gw_app_power_meter_info_t   pm[0];
							 | 
						||
| 
								 | 
							
								} gw_app_query_sec_node_reg_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* stop secondary node register payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_stop_sec_node_reg {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :20;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								} gw_app_stop_sec_node_reg_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* correcting time payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_correcting_time {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :8,
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								                data_len    :12;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_correcting_time_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* correcting time extend payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_correcting_time_ext {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :8,
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								                data_len    :12;
							 | 
						||
| 
								 | 
							
								    /* corresponding cco ntb of the correct time */
							 | 
						||
| 
								 | 
							
								    uint32_t    cco_ntb;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_correcting_time_ext_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* accurate correcting time payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_accurate_correct_time {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								                data_len    :12,
							 | 
						||
| 
								 | 
							
								    /* sequence */
							 | 
						||
| 
								 | 
							
								                seq         :8;
							 | 
						||
| 
								 | 
							
								    /* corresponding cco ntb of the correct time */
							 | 
						||
| 
								 | 
							
								    uint32_t    cco_ntb;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_accurate_correct_time_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* time of the clock manager */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_clock_manager_corr_time {
							 | 
						||
| 
								 | 
							
								    /* corresponding cco ntb of the correct time */
							 | 
						||
| 
								 | 
							
								    uint32_t    cco_ntb;
							 | 
						||
| 
								 | 
							
								    /* time stamp, BCD code to represent */
							 | 
						||
| 
								 | 
							
								    uint8_t     sec;
							 | 
						||
| 
								 | 
							
								    uint8_t     min;
							 | 
						||
| 
								 | 
							
								    uint8_t     hour;
							 | 
						||
| 
								 | 
							
								    uint8_t     day;
							 | 
						||
| 
								 | 
							
								    uint8_t     month;
							 | 
						||
| 
								 | 
							
								    uint8_t     year_low_byte;
							 | 
						||
| 
								 | 
							
								    uint8_t     year_high_byte;
							 | 
						||
| 
								 | 
							
								} gw_app_clock_manager_corr_time_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* clock manager payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_clock_manager {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                reserved    :4;
							 | 
						||
| 
								 | 
							
								    /* meter addr, little endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     pm_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* cmd type see GW_APP_CLOCK_MANAGER_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     cmd_type;
							 | 
						||
| 
								 | 
							
								    /* data len */
							 | 
						||
| 
								 | 
							
								    uint8_t     data_len;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_clock_manager_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* clock query payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_clock_query_dl {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                reserved1   :4;
							 | 
						||
| 
								 | 
							
								    /* meter addr, little endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     pm_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								    uint8_t     reserved2;
							 | 
						||
| 
								 | 
							
								} gw_app_clock_query_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* clock query payload from sta to cco */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_clock_query_ul {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                reserved1   :4;
							 | 
						||
| 
								 | 
							
								    /* meter addr, little endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     pm_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* switch of auto correct time */
							 | 
						||
| 
								 | 
							
								    uint8_t     auto_corr_switch;
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								    uint8_t     reserved2;
							 | 
						||
| 
								 | 
							
								    /* correct time threshold */
							 | 
						||
| 
								 | 
							
								    uint8_t     corr_threshold;
							 | 
						||
| 
								 | 
							
								} gw_app_clock_query_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* abnormal electric current enable reply for neutralwire and livewire */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_nli_abnormal_enable_cmd_read_reply {
							 | 
						||
| 
								 | 
							
								    /* enable flag, 0 - disabled, 1 - enable */
							 | 
						||
| 
								 | 
							
								    uint8_t     enable;
							 | 
						||
| 
								 | 
							
								} gw_app_nli_abnormal_enable_cmd_read_reply_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* abnormal electric current configuration for neutralwire and livewire */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_nli_abnormal_cfg_cmd {
							 | 
						||
| 
								 | 
							
								    /* configuration enable flag , 0 - disabled, 1 - enable */
							 | 
						||
| 
								 | 
							
								    uint8_t     enable;
							 | 
						||
| 
								 | 
							
								} gw_app_nli_abnormal_cfg_cmd_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* abnormal electric current configuration reply for neutralwire and livewire */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_nli_abnormal_cfg_cmd_reply {
							 | 
						||
| 
								 | 
							
								    /* configuration result , 0 - success, 1 - fail */
							 | 
						||
| 
								 | 
							
								    uint8_t     result;
							 | 
						||
| 
								 | 
							
								} gw_app_nli_abnormal_cfg_cmd_reply_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* abnormal electric current enable command for neutralwire and livewire */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_nli_abnormal_enable_cmd {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* direction flag */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* start flag */
							 | 
						||
| 
								 | 
							
								                start       :1,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        :2;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* source mac address, it's cco addr in down link,
							 | 
						||
| 
								 | 
							
								     * it's sta addr in up link, little endian.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint8_t     src_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* command type, see GW_APP_ABNORMAL_NLI_CMD_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     cmd_type;
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								    uint8_t     data_len;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_nli_abnormal_enable_cmd_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* event report payload between cco and sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_event_report {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* direction flag */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* start flag */
							 | 
						||
| 
								 | 
							
								                start       :1,
							 | 
						||
| 
								 | 
							
								    /* function code. see GW_APP_EVENT_FN_XXX */
							 | 
						||
| 
								 | 
							
								                fn          :6,
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								                data_len    :12;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* power meter mac address */
							 | 
						||
| 
								 | 
							
								    uint8_t     pm_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_event_report_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* abnormal electric current data for neutralwire and livewire */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_nli_abnormal_data {
							 | 
						||
| 
								 | 
							
								    /* power meter address, little endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     pm_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* phase electric current */
							 | 
						||
| 
								 | 
							
								    uint8_t     phase_electric[GW_APP_ELECTRIC_CURRENT_LEN];
							 | 
						||
| 
								 | 
							
								    /* neutralwire electric current */
							 | 
						||
| 
								 | 
							
								    uint8_t     neutralwire_electric[GW_APP_ELECTRIC_CURRENT_LEN];
							 | 
						||
| 
								 | 
							
								    /* electric current for neutralwire and livewire */
							 | 
						||
| 
								 | 
							
								    uint8_t     nl_electric[GW_APP_ELECTRIC_CURRENT_LEN];
							 | 
						||
| 
								 | 
							
								    /* abnormal time, bcd format */
							 | 
						||
| 
								 | 
							
								    uint8_t     time[GW_APP_ABNORMAL_TIME_DATA_LEN];
							 | 
						||
| 
								 | 
							
								} gw_app_nli_abnormal_data_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* event report abnormal electric current data for neutralwire and livewire */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_event_nli_abnormal_data {
							 | 
						||
| 
								 | 
							
								    /* report cnt */
							 | 
						||
| 
								 | 
							
								    uint16_t    rpt_cnt;
							 | 
						||
| 
								 | 
							
								    /* abnormal data for neutralwire and livewire */
							 | 
						||
| 
								 | 
							
								    gw_app_nli_abnormal_data_t   nl_data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_event_nli_abnormal_data_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* event data field */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_evt_data_field {
							 | 
						||
| 
								 | 
							
								    /* event type, see GW_APP_EVENT_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     evt_type;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_evt_data_field_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* bitmap type for event data field */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_evt_data_bitmap {
							 | 
						||
| 
								 | 
							
								    /* the tei of the start bit in the bitmap */
							 | 
						||
| 
								 | 
							
								    uint16_t    tei;
							 | 
						||
| 
								 | 
							
								    /* tei map */
							 | 
						||
| 
								 | 
							
								    uint8_t     map[0];
							 | 
						||
| 
								 | 
							
								} gw_app_evt_data_bitmap_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* power meter info for power event report */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_power_evt_pm_info {
							 | 
						||
| 
								 | 
							
								    /* power meter mac address */
							 | 
						||
| 
								 | 
							
								    uint8_t     mac[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* 0 - power off, 1- power on */
							 | 
						||
| 
								 | 
							
								    uint8_t     power_state;
							 | 
						||
| 
								 | 
							
								} gw_app_power_evt_pm_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* addr type for event data field */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_evt_data_addr {
							 | 
						||
| 
								 | 
							
								    /* power meter count */
							 | 
						||
| 
								 | 
							
								    uint16_t                   pm_count;
							 | 
						||
| 
								 | 
							
								    /* power meter info */
							 | 
						||
| 
								 | 
							
								    gw_app_power_evt_pm_info_t pm_info[0];
							 | 
						||
| 
								 | 
							
								} gw_app_evt_data_addr_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* phase sequence type for event data field */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_phase_seq_info {
							 | 
						||
| 
								 | 
							
								    /* three phase meter addr */
							 | 
						||
| 
								 | 
							
								    uint8_t     pm_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* phase sequence status, see GW_APP_PHASE_SEQUENCE_STAUS_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     phase_seq_status;
							 | 
						||
| 
								 | 
							
								} gw_app_phase_seq_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* meter info for search pm result event report */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_search_pm_info {
							 | 
						||
| 
								 | 
							
								    /* meter mac address, little-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     mac[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* pm protocol type, see PROTO_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     proto_type;
							 | 
						||
| 
								 | 
							
								} gw_app_search_pm_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* search pm result for event data field */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_evt_search_data {
							 | 
						||
| 
								 | 
							
								    /* collector or pm moudle mac, little-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     dev_mac[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* power meter count */
							 | 
						||
| 
								 | 
							
								    uint8_t     pm_count;
							 | 
						||
| 
								 | 
							
								    /* search meter result info */
							 | 
						||
| 
								 | 
							
								    gw_app_search_pm_info_t pm_info[0];
							 | 
						||
| 
								 | 
							
								} gw_app_evt_search_data_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* ping test payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_comm_test {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :4,
							 | 
						||
| 
								 | 
							
								    /* data type. see see GW_APP_DATA_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								                data_type   :4,
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								                data_len    :12;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_comm_test_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* ctrl proto payload */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_ctrl_proto {
							 | 
						||
| 
								 | 
							
								    /* protocol type, see GW_APP_CTRL_PROTO_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     proto_type;
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								    uint16_t    data_len;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_ctrl_proto_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* ctrl passthrough proto payload */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_ctrl_proto_passthrough {
							 | 
						||
| 
								 | 
							
								    /* passthrough data protocol type, see GW_APP_CTRL_PROTO_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     proto_type;
							 | 
						||
| 
								 | 
							
								    /* primary request message flag, see GW_APP_CTRL_PRM_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     prm  : 1,
							 | 
						||
| 
								 | 
							
								    /* reserve1 for future */
							 | 
						||
| 
								 | 
							
								                rsvd1: 7;
							 | 
						||
| 
								 | 
							
								    /* baudrate: small endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     baud[4];
							 | 
						||
| 
								 | 
							
								    /* reserve2 for future */
							 | 
						||
| 
								 | 
							
								    uint32_t    rsvd2;
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								    uint16_t    data_len;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_ctrl_proto_passthrough_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* ack and nack payload between cco and sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_ack_nack {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* direction flag */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* ack flag */
							 | 
						||
| 
								 | 
							
								                ack         :1,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :2;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* options */
							 | 
						||
| 
								 | 
							
								    uint16_t    option;
							 | 
						||
| 
								 | 
							
								} gw_app_ack_nack_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* start upgrade payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_start_upgrade_dl {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :20;
							 | 
						||
| 
								 | 
							
								    /* upgrade id */
							 | 
						||
| 
								 | 
							
								    uint32_t    id;
							 | 
						||
| 
								 | 
							
								    /* upgrade time window. uint is 1 minute */
							 | 
						||
| 
								 | 
							
								    uint16_t    window;
							 | 
						||
| 
								 | 
							
								    /* upgrade block size. see GW_APP_UPGRADE_BLOCK_XXX */
							 | 
						||
| 
								 | 
							
								    uint16_t    block_size;
							 | 
						||
| 
								 | 
							
								    /* upgrade file size */
							 | 
						||
| 
								 | 
							
								    uint32_t    file_size;
							 | 
						||
| 
								 | 
							
								    /* file crc */
							 | 
						||
| 
								 | 
							
								    uint32_t    file_crc;
							 | 
						||
| 
								 | 
							
								} gw_app_start_upgrade_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* start upgrade payload from sta to cco */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_start_upgrade_ul {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :12,
							 | 
						||
| 
								 | 
							
								    /* start upgrade result code. 0 for success, non zero for failure case */
							 | 
						||
| 
								 | 
							
								                result      :8;
							 | 
						||
| 
								 | 
							
								    /* upgrade id */
							 | 
						||
| 
								 | 
							
								    uint32_t    id;
							 | 
						||
| 
								 | 
							
								} gw_app_start_upgrade_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* stop upgrade payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_stop_upgrade {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :20;
							 | 
						||
| 
								 | 
							
								    /* upgrade id */
							 | 
						||
| 
								 | 
							
								    uint32_t    id;
							 | 
						||
| 
								 | 
							
								} gw_app_stop_upgrade_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transfer file payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_transfer_file {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :4;
							 | 
						||
| 
								 | 
							
								    /* block size */
							 | 
						||
| 
								 | 
							
								    uint16_t    size;
							 | 
						||
| 
								 | 
							
								    /* upgrade id */
							 | 
						||
| 
								 | 
							
								    uint32_t    id;
							 | 
						||
| 
								 | 
							
								    /* block sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_transfer_file_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query upgrade payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_upgrade_status_dl {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :4;
							 | 
						||
| 
								 | 
							
								    /* number of consecutive blocks to be queried. 0xFFFF means all blocks.
							 | 
						||
| 
								 | 
							
								     * see GW_APP_UPGRADE_QUERY_ALL_BLOCK.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint16_t    cnt;
							 | 
						||
| 
								 | 
							
								    /* sequence of first block to be queried */
							 | 
						||
| 
								 | 
							
								    uint32_t    start_seq;
							 | 
						||
| 
								 | 
							
								    /* upgrade id */
							 | 
						||
| 
								 | 
							
								    uint32_t    id;
							 | 
						||
| 
								 | 
							
								} gw_app_query_upgrade_status_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query upgrade payload from sta to cco */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_upgrade_status_ul {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* upgrade status. See GW_APP_UPGRADE_QUERY_TRANSFER_XXX  */
							 | 
						||
| 
								 | 
							
								                status      :4;
							 | 
						||
| 
								 | 
							
								    /* number of available blocks */
							 | 
						||
| 
								 | 
							
								    uint16_t    cnt;
							 | 
						||
| 
								 | 
							
								    /* sequence of first block to be queried */
							 | 
						||
| 
								 | 
							
								    uint32_t    start_seq;
							 | 
						||
| 
								 | 
							
								    /* upgrade id */
							 | 
						||
| 
								 | 
							
								    uint32_t    id;
							 | 
						||
| 
								 | 
							
								    /* bitmap to show blocks received */
							 | 
						||
| 
								 | 
							
								    uint8_t     bm[0];
							 | 
						||
| 
								 | 
							
								} gw_app_query_upgrade_status_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* execute upgrade payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_execute_upgrade {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :4;
							 | 
						||
| 
								 | 
							
								    /* wait for reset duration */
							 | 
						||
| 
								 | 
							
								    uint16_t    reset_dur;
							 | 
						||
| 
								 | 
							
								    /* upgrade id */
							 | 
						||
| 
								 | 
							
								    uint32_t    id;
							 | 
						||
| 
								 | 
							
								    /* trial run duration */
							 | 
						||
| 
								 | 
							
								    uint32_t    trial_run_dur;
							 | 
						||
| 
								 | 
							
								} gw_app_execute_upgrade_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query station payload from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_station_dl {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :12,
							 | 
						||
| 
								 | 
							
								    /* number of id in the info element id list */
							 | 
						||
| 
								 | 
							
								                cnt         :8;
							 | 
						||
| 
								 | 
							
								    /* info element id list. see GW_APP_STA_INFO_ID_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     id[0];
							 | 
						||
| 
								 | 
							
								} gw_app_query_station_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* station information element */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_sta_info_element {
							 | 
						||
| 
								 | 
							
								    /* info element id. see GW_APP_STA_INFO_ID_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     id;
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								    uint8_t     len;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_sta_info_element_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query station payload from sta to cco */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_station_ul {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :12,
							 | 
						||
| 
								 | 
							
								    /* number of element in the info element list */
							 | 
						||
| 
								 | 
							
								                cnt         :8;
							 | 
						||
| 
								 | 
							
								    /* upgrade id */
							 | 
						||
| 
								 | 
							
								    uint32_t    id;
							 | 
						||
| 
								 | 
							
								    /* info element list. see gw_app_sta_info_element_t. */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_query_station_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer detect package */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_tsfm_detect {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* direction flag, 0 - downlink, 1 - uplink */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* start flag, 0 - from slave, 1 - from master */
							 | 
						||
| 
								 | 
							
								                start       :1,
							 | 
						||
| 
								 | 
							
								    /* collect phase, see GW_APP_DATA_PHASE_XXX. */
							 | 
						||
| 
								 | 
							
								                phase       :2;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* cco mac address or sta mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* transformer feature type, see GW_APP_TSFM_FEATURE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     feature_type;
							 | 
						||
| 
								 | 
							
								    /* transformer feature collection type, see GW_APP_TSFM_COLLECT_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     collect_type;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_detect_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer feature collection snr request */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_tsfm_collect_snr_req {
							 | 
						||
| 
								 | 
							
								    /* start index */
							 | 
						||
| 
								 | 
							
								    uint16_t    index;
							 | 
						||
| 
								 | 
							
								    /* count */
							 | 
						||
| 
								 | 
							
								    uint8_t     cnt;
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_collect_snr_req_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* sta neighbor node info uint structure */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_neighbor_node_info {
							 | 
						||
| 
								 | 
							
								    /* neighbor node tei */
							 | 
						||
| 
								 | 
							
								    uint16_t    tei;
							 | 
						||
| 
								 | 
							
								    /* neighbor node mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     mac[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* snr between neighbor node and local node */
							 | 
						||
| 
								 | 
							
								    int8_t      snr;
							 | 
						||
| 
								 | 
							
								} gw_app_neighbor_node_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer feature collection snr resp */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_tsfm_collect_snr_resp {
							 | 
						||
| 
								 | 
							
								    /* NTB at the start of the first collection */
							 | 
						||
| 
								 | 
							
								    uint32_t    start_ntb;
							 | 
						||
| 
								 | 
							
								    /* neighbor node total cnt */
							 | 
						||
| 
								 | 
							
								    uint16_t    total_cnt;
							 | 
						||
| 
								 | 
							
								    /* start index */
							 | 
						||
| 
								 | 
							
								    uint16_t    index;
							 | 
						||
| 
								 | 
							
								    /* resp count */
							 | 
						||
| 
								 | 
							
								    uint8_t     resp_cnt;
							 | 
						||
| 
								 | 
							
								    /* neighbor node info */
							 | 
						||
| 
								 | 
							
								    gw_app_neighbor_node_info_t node_info[0];
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_collect_snr_resp_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer feature collection type package.
							 | 
						||
| 
								 | 
							
								 * GW_APP_TSFM_COLLECT_START package
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_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 GW_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;
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_collect_start_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer feature collection type package.
							 | 
						||
| 
								 | 
							
								 * GW_APP_TSFM_COLLECT_REPORT package
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_tsfm_collect_report {
							 | 
						||
| 
								 | 
							
								    /* tei of cco or sta */
							 | 
						||
| 
								 | 
							
								    uint16_t   tei          :12,
							 | 
						||
| 
								 | 
							
								    /* collect type, see GW_APP_TSFM_COLLECT_TYPE_XXX.
							 | 
						||
| 
								 | 
							
								     * valid only in the GW_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];
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_collect_report_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer feature collection data */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_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];
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_collect_data_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer detection feature type package.
							 | 
						||
| 
								 | 
							
								 * GW_APP_TSFM_FEATURE_VOLTAGE package
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_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];
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_collect_v_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer detection feature type package.
							 | 
						||
| 
								 | 
							
								 * GW_APP_TSFM_FEATURE_FREQUENCY package
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_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];
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_collect_freq_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer detection feature type package.
							 | 
						||
| 
								 | 
							
								 * GW_APP_TSFM_FEATURE_PERIOD package
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_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;
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_collect_period_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer detection feature type package.
							 | 
						||
| 
								 | 
							
								 * GW_APP_TSFM_FEATURE_POWER_FACTOR package
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_tsfm_collect_pf {
							 | 
						||
| 
								 | 
							
								    /* A phase power factor.use 2 bytes of BCD code to represent the power
							 | 
						||
| 
								 | 
							
								     * factor. for example, 0.999 uses 2 bytes of BCD code to represent
							 | 
						||
| 
								 | 
							
								     * the following 0x09, 0x99. */
							 | 
						||
| 
								 | 
							
								    uint8_t    bcd[PROTO_645_07_PF_LEN];
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_collect_pf_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer detection feature type package.
							 | 
						||
| 
								 | 
							
								 * GW_APP_TSFM_FEATURE_CURRENT package
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_tsfm_collect_a {
							 | 
						||
| 
								 | 
							
								    /* A phase current.use 3 bytes of BCD code to represent the current.
							 | 
						||
| 
								 | 
							
								     * for example, 123.456A uses 3 bytes of BCD code to represent
							 | 
						||
| 
								 | 
							
								     * the following 0x12, 0x34, 0x56. */
							 | 
						||
| 
								 | 
							
								    uint8_t    bcd[PROTO_645_07_A_LEN];
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_collect_a_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer detect result */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_tsfm_detect_result {
							 | 
						||
| 
								 | 
							
								    /* node tei */
							 | 
						||
| 
								 | 
							
								    uint16_t    tei;
							 | 
						||
| 
								 | 
							
								    /* 0 - transformer detect in progress, 1 - transformer detect done */
							 | 
						||
| 
								 | 
							
								    uint8_t     done;
							 | 
						||
| 
								 | 
							
								    /* see GW_APP_TSFM_DETECT_RET_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     result;
							 | 
						||
| 
								 | 
							
								    /* real transformer mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     tsfm_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_detect_result_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* private protocol transformer detect result down-link */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_tsfm_detect_result_pw_dl {
							 | 
						||
| 
								 | 
							
								    /* sn required to be reported, range of sn is 1-31 */
							 | 
						||
| 
								 | 
							
								    uint8_t     sn;
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_detect_result_pw_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* private protocol node info data */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_tsfm_node_info_pw {
							 | 
						||
| 
								 | 
							
								    /* node address, little-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t  addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* reserve for future */
							 | 
						||
| 
								 | 
							
								    uint8_t  reserve1;
							 | 
						||
| 
								 | 
							
								    /* node protocol type, see GW_APP_DATA_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t  pro_type : 4,
							 | 
						||
| 
								 | 
							
								    /* node device type, see GW_APP_ID_INFO_DEV_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								             dev_type : 4;
							 | 
						||
| 
								 | 
							
								    /* reserve for future */
							 | 
						||
| 
								 | 
							
								    uint8_t  reserve2;
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_node_info_pw_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* private protocol transformer detect result up-link */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_tsfm_detect_result_pw_ul {
							 | 
						||
| 
								 | 
							
								    /* node tei */
							 | 
						||
| 
								 | 
							
								    uint16_t    tei;
							 | 
						||
| 
								 | 
							
								    /* 0 - transformer detect in progress, 1 - transformer detect done */
							 | 
						||
| 
								 | 
							
								    uint8_t     done     : 2,
							 | 
						||
| 
								 | 
							
								    /* follow data of flag. 1 - there is follow-up data.
							 | 
						||
| 
								 | 
							
								     * 0 - there is no follow-up data.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								                flw_flag : 1,
							 | 
						||
| 
								 | 
							
								    /* rpt sn, range of sn is 1-31 */
							 | 
						||
| 
								 | 
							
								                sn       : 5;
							 | 
						||
| 
								 | 
							
								    /* see GW_APP_TSFM_DETECT_RET_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     result   : 2,
							 | 
						||
| 
								 | 
							
								    /* number of nodes of same tsfm found by the device */
							 | 
						||
| 
								 | 
							
								                node_cnt : 6;
							 | 
						||
| 
								 | 
							
								    /* 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];
							 | 
						||
| 
								 | 
							
								    /* node info data */
							 | 
						||
| 
								 | 
							
								    gw_app_tsfm_node_info_pw_t node[0];
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_detect_result_pw_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_tsfm_detect_set_tsfm_addr {
							 | 
						||
| 
								 | 
							
								    /* transformer address, big endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     tsfm_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								    uint16_t    rsvd;
							 | 
						||
| 
								 | 
							
								} gw_app_tsfm_detect_set_tsfm_addr_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query module id information from sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_module_id_dl {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* direction flag, 0 - downlink, 1 - uplink */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* id type, see GW_APP_ID_INFO_TYPE_xxx */
							 | 
						||
| 
								 | 
							
								                id_type     :3;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								} gw_app_query_module_id_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* report module id information to cco, hunan province extend protocol */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_module_id_ul_hn {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* direction flag, 0 - downlink, 1 - uplink */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* reserved for future. */
							 | 
						||
| 
								 | 
							
								                rsvd        :3;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* module id length */
							 | 
						||
| 
								 | 
							
								    uint8_t     module_id_len;
							 | 
						||
| 
								 | 
							
								    /* module id information */
							 | 
						||
| 
								 | 
							
								    uint8_t     module_info[GW_APP_MODULE_ID_INFO_LEN];
							 | 
						||
| 
								 | 
							
								} gw_app_query_module_id_ul_hn_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* report module id information to cco */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_module_id_ul {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* direction flag, 0 - downlink, 1 - uplink */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* id type, see GW_APP_ID_INFO_TYPE_xxx */
							 | 
						||
| 
								 | 
							
								                id_type     :3;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* module id length */
							 | 
						||
| 
								 | 
							
								    uint8_t     module_id_len;
							 | 
						||
| 
								 | 
							
								    /* module id information */
							 | 
						||
| 
								 | 
							
								    uint8_t     module_info[GW_APP_MODULE_ID_INFO_LEN];
							 | 
						||
| 
								 | 
							
								    /* device type, see GW_APP_ID_INFO_DEV_TYPE_xxx */
							 | 
						||
| 
								 | 
							
								    uint8_t     dev_type;
							 | 
						||
| 
								 | 
							
								} gw_app_query_module_id_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* report chip id information to cco */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_chip_id_ul {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* direction flag, 0 - downlink, 1 - uplink */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* id type, see GW_APP_ID_INFO_TYPE_xxx */
							 | 
						||
| 
								 | 
							
								                id_type     :3;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* chip id length */
							 | 
						||
| 
								 | 
							
								    uint8_t     chip_id_len;
							 | 
						||
| 
								 | 
							
								    /* chip id information */
							 | 
						||
| 
								 | 
							
								    uint8_t     chip_info[GW_APP_CHIP_ID_INFO_LEN];
							 | 
						||
| 
								 | 
							
								    /* device type, see GW_APP_ID_INFO_DEV_TYPE_xxx */
							 | 
						||
| 
								 | 
							
								    uint8_t     dev_type;
							 | 
						||
| 
								 | 
							
								} gw_app_query_chip_id_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query vendor specific information from sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_vendor_info_dl {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         : 6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  : 6,
							 | 
						||
| 
								 | 
							
								    /* direction flag, 0 - downlink, 1 - uplink */
							 | 
						||
| 
								 | 
							
								                dir         : 1,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        : 3;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* info type, see GW_APP_VENDOR_INFO_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     info_type;
							 | 
						||
| 
								 | 
							
								    /* length of data */
							 | 
						||
| 
								 | 
							
								    uint16_t    data_len;
							 | 
						||
| 
								 | 
							
								    /* data specific info to be queried. it's optional. */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_query_vendor_info_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* report queried vendor specific information to CCo. */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_vendor_info_ul {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         : 6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  : 6,
							 | 
						||
| 
								 | 
							
								    /* direction flag, 0 - downlink, 1 - uplink */
							 | 
						||
| 
								 | 
							
								                dir         : 1,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        : 3;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* info type, see GW_APP_VENDOR_INFO_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     info_type;
							 | 
						||
| 
								 | 
							
								    /* length of data */
							 | 
						||
| 
								 | 
							
								    uint16_t    data_len;
							 | 
						||
| 
								 | 
							
								    /* data with queried information */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_query_vendor_info_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* sta correct time */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_sta_correct_time {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        :4;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    rsvd1       :4,
							 | 
						||
| 
								 | 
							
								    /* data len */
							 | 
						||
| 
								 | 
							
								                data_len    :12;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_sta_correct_time_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query meter parameter from sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_meter_param_dl {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        :4;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								    /* source mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     src_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* destination mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     dest_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} gw_app_query_meter_param_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* report meter parameter to cco */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_meter_param_ul {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        :4;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								    /* source mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     src_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* destination mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     dest_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* power meter type, see GW_APP_PM_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     pm_type     :4,
							 | 
						||
| 
								 | 
							
								    /* zc type, see GW_APP_ZC_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								                zc_type     :4;
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								    uint8_t     rsvd1[4];
							 | 
						||
| 
								 | 
							
								} gw_app_query_meter_param_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* set module collect parameter */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_set_module_clct_param_dl {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        :4;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								    /* source mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     src_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* destination mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     dest_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								    uint16_t    rsvd1       :4,
							 | 
						||
| 
								 | 
							
								    /* data len */
							 | 
						||
| 
								 | 
							
								                data_len    :12;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_set_module_clct_param_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* di and result length */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_di_info {
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t            di;
							 | 
						||
| 
								 | 
							
								    /* meter reading result length */
							 | 
						||
| 
								 | 
							
								    uint8_t             di_result_len;
							 | 
						||
| 
								 | 
							
								} gw_app_di_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* set module collect parameter for v2.8 */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_set_module_clct_param_dl_v28 {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver :        6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len : 6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd :       4;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								    /* destination mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     dest_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* task number 0 ~ 7, 0xFF is all tasks.
							 | 
						||
| 
								 | 
							
								     * see GW_APP_V28_CLCT_PARAM_TASK_NUM_XXX
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint8_t     task_num;
							 | 
						||
| 
								 | 
							
								    /* 0 - disabled, 1 - enabled */
							 | 
						||
| 
								 | 
							
								    uint8_t     enabled :    1,
							 | 
						||
| 
								 | 
							
								    /* 2 - DL/T645-2007, 3 - DL/T 698.45, otherwise - reserved */
							 | 
						||
| 
								 | 
							
								                proto_type : 3,
							 | 
						||
| 
								 | 
							
								    /* 0 - single phase meter, 1 - three phase meter */
							 | 
						||
| 
								 | 
							
								                pm_type :    2,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd1 :      2;
							 | 
						||
| 
								 | 
							
								    /* unit is 1min, see GW_APP_CURVE_COLLECT_PERIOD_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     clct_period;
							 | 
						||
| 
								 | 
							
								    /* di count */
							 | 
						||
| 
								 | 
							
								    uint8_t     di_cnt;
							 | 
						||
| 
								 | 
							
								    /* di information */
							 | 
						||
| 
								 | 
							
								    gw_app_di_info_t di_info[0];
							 | 
						||
| 
								 | 
							
								} gw_app_set_module_clct_param_dl_v28_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_meter_clct_param {
							 | 
						||
| 
								 | 
							
								    /* 0 - single phase meter, 1 - three phase meter */
							 | 
						||
| 
								 | 
							
								    uint8_t             pm_type;
							 | 
						||
| 
								 | 
							
								    /* di count of single phase meter */
							 | 
						||
| 
								 | 
							
								    uint8_t             di_cnt;
							 | 
						||
| 
								 | 
							
								    /* di result total length of single phase meter */
							 | 
						||
| 
								 | 
							
								    uint8_t             di_result_len;
							 | 
						||
| 
								 | 
							
								    /* di information of single phase meter */
							 | 
						||
| 
								 | 
							
								    gw_app_di_info_t    di_info[0];
							 | 
						||
| 
								 | 
							
								} gw_app_meter_clct_param_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* sta collect parameter */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_module_clct_param {
							 | 
						||
| 
								 | 
							
								    /* 0 - disabled, 1 - enabled */
							 | 
						||
| 
								 | 
							
								    uint8_t             enabled;
							 | 
						||
| 
								 | 
							
								    /* unit is 1min, see GW_APP_CURVE_COLLECT_PERIOD_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t             clct_period;
							 | 
						||
| 
								 | 
							
								    /* 2 - DL/T645-2007, otherwise - reserved */
							 | 
						||
| 
								 | 
							
								    uint8_t             proto_type;
							 | 
						||
| 
								 | 
							
								    /* collect parameter */
							 | 
						||
| 
								 | 
							
								    //gw_app_meter_clct_param_t clct_param[0];
							 | 
						||
| 
								 | 
							
								} gw_app_module_clct_param_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* report module collect parameter config */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_set_module_clct_param_ul {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        :4;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								    /* source mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     src_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* destination mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     dest_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* 0 - success, 1 - fail */
							 | 
						||
| 
								 | 
							
								    uint8_t     result;
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								    uint16_t    rsvd1;
							 | 
						||
| 
								 | 
							
								} gw_app_set_module_clct_param_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* report module collect parameter config for v2.8 */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_set_module_clct_param_ul_v28 {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        :4;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								    /* source mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     src_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* task number 0 ~ 7, 0xFF is all tasks,
							 | 
						||
| 
								 | 
							
								     * see GW_APP_V28_CLCT_PARAM_TASK_NUM_XXX.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint8_t     task_num;
							 | 
						||
| 
								 | 
							
								    /* 0 - disabled, 1 - enabled */
							 | 
						||
| 
								 | 
							
								    uint8_t     enabled     :1,
							 | 
						||
| 
								 | 
							
								    /* configuration result , 0 - success, 1 - fail,
							 | 
						||
| 
								 | 
							
								     * see GW_APP_V28_CLCT_PARAM_CFG_XXX.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								                result      :1,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd1       :6;
							 | 
						||
| 
								 | 
							
								} gw_app_set_module_clct_param_ul_v28_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query module collect data dl for v2.8 */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_module_clct_data_dl_v28 {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* direction flag, 0 - downlink, 1 - uplink */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        :3;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								    /* 2 - DL/T645-2007, 3 - DL/T 698.45, otherwise - reserved */
							 | 
						||
| 
								 | 
							
								    uint8_t     proto_type  :4,
							 | 
						||
| 
								 | 
							
								    /* 0 - single phase meter, 1 - three phase meter */
							 | 
						||
| 
								 | 
							
								                pm_type     :1,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd1       :3;
							 | 
						||
| 
								 | 
							
								    /* destination mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     dest_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* task number 0 ~ 7, 0xFF is all tasks,
							 | 
						||
| 
								 | 
							
								     * see GW_APP_V28_CLCT_PARAM_TASK_NUM_XXX.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint8_t     task_num;
							 | 
						||
| 
								 | 
							
								    /* time stamp, BCD code to represent */
							 | 
						||
| 
								 | 
							
								    uint8_t     year;
							 | 
						||
| 
								 | 
							
								    uint8_t     month;
							 | 
						||
| 
								 | 
							
								    uint8_t     day;
							 | 
						||
| 
								 | 
							
								    uint8_t     hour;
							 | 
						||
| 
								 | 
							
								    uint8_t     min;
							 | 
						||
| 
								 | 
							
								    uint8_t     sec;
							 | 
						||
| 
								 | 
							
								} gw_app_query_module_clct_data_dl_v28_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query module collect data ul for v2.8 */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_module_clct_data_ul_v28 {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* direction flag, 0 - downlink, 1 - uplink */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        :3;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint32_t    seq;
							 | 
						||
| 
								 | 
							
								    /* 2 - DL/T645-2007, 3 - DL/T 698.45, otherwise - reserved */
							 | 
						||
| 
								 | 
							
								    uint8_t     proto_type  :4,
							 | 
						||
| 
								 | 
							
								    /* 0 - single phase meter, 1 - three phase meter */
							 | 
						||
| 
								 | 
							
								                pm_type     :1,
							 | 
						||
| 
								 | 
							
								    /* query result, see GW_APP_QUERY_CLCT_RESULT_xxx */
							 | 
						||
| 
								 | 
							
								                result      :3;
							 | 
						||
| 
								 | 
							
								    /* source mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     src_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* task number 0 ~ 7, 0xFF is all tasks,
							 | 
						||
| 
								 | 
							
								     * see GW_APP_V28_CLCT_PARAM_TASK_NUM_XXX.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint8_t     task_num;
							 | 
						||
| 
								 | 
							
								    /* time stamp, BCD code to represent */
							 | 
						||
| 
								 | 
							
								    uint8_t     year;
							 | 
						||
| 
								 | 
							
								    uint8_t     month;
							 | 
						||
| 
								 | 
							
								    uint8_t     day;
							 | 
						||
| 
								 | 
							
								    uint8_t     hour;
							 | 
						||
| 
								 | 
							
								    uint8_t     min;
							 | 
						||
| 
								 | 
							
								    uint8_t     sec;
							 | 
						||
| 
								 | 
							
								    /* respond di count */
							 | 
						||
| 
								 | 
							
								    uint8_t     di_cnt_rsp;
							 | 
						||
| 
								 | 
							
								    /* respond di data len */
							 | 
						||
| 
								 | 
							
								    uint16_t    di_data_len;
							 | 
						||
| 
								 | 
							
								    /* respond di data */
							 | 
						||
| 
								 | 
							
								    uint8_t     di_data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_query_module_clct_data_ul_v28_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query ID information request message layout */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_id_info_dl {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* direction flag, 0 - downlink, 1 - uplink */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* id type, see GW_APP_ID_INFO_TYPE_xxx */
							 | 
						||
| 
								 | 
							
								                id_type     :3;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								} gw_app_query_id_info_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* report id information message header layout */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_id_info_ul_hdr {
							 | 
						||
| 
								 | 
							
								    /* version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* dir flag, 0 - downlink, 1 - uplink */
							 | 
						||
| 
								 | 
							
								                dir         :1,
							 | 
						||
| 
								 | 
							
								    /* id type, see GW_APP_ID_INFO_TYPE_xxx */
							 | 
						||
| 
								 | 
							
								                id_type     :3;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* id info length */
							 | 
						||
| 
								 | 
							
								    uint8_t     id_len;
							 | 
						||
| 
								 | 
							
								    /* id info payload */
							 | 
						||
| 
								 | 
							
								    uint8_t     id[0];
							 | 
						||
| 
								 | 
							
								} gw_app_query_id_info_ul_hdr_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* report id information message tail layout */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_query_id_info_ul_tail {
							 | 
						||
| 
								 | 
							
								    /* device type, see PLC_DEV_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     dev_type;
							 | 
						||
| 
								 | 
							
								} gw_app_query_id_info_ul_tail_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query low power secondary node register dev type data field */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_lp_meter_query_dev_type {
							 | 
						||
| 
								 | 
							
								    /* low power dev type, see GW_APP_LP_DEV_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     dev_type    :4,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                reserved    :4;
							 | 
						||
| 
								 | 
							
								} gw_app_lp_meter_query_dev_type_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* low power meter rssi data */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_lp_meter_rssi_info {
							 | 
						||
| 
								 | 
							
								    /* low power meter mac address, little-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     pm_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* low power meter mac address high byte */
							 | 
						||
| 
								 | 
							
								    uint8_t     high_addr;
							 | 
						||
| 
								 | 
							
								    /* rssi data */
							 | 
						||
| 
								 | 
							
								    uint8_t     rssi;
							 | 
						||
| 
								 | 
							
								} gw_app_lp_meter_rssi_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query low power meter rssi info up link */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_lp_meter_query_rssi_ul {
							 | 
						||
| 
								 | 
							
								    /* total count of low power meter */
							 | 
						||
| 
								 | 
							
								    uint16_t    total_node_cnt;
							 | 
						||
| 
								 | 
							
								    /* current reported count of low power meter */
							 | 
						||
| 
								 | 
							
								    uint8_t     ack_count;
							 | 
						||
| 
								 | 
							
								    /* low power meter rssi information */
							 | 
						||
| 
								 | 
							
								    gw_app_lp_meter_rssi_info_t rssi_info[0];
							 | 
						||
| 
								 | 
							
								} gw_app_lp_meter_query_rssi_ul_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query low power meter rssi info down link */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_lp_meter_query_rssi_dl {
							 | 
						||
| 
								 | 
							
								    /* query start index */
							 | 
						||
| 
								 | 
							
								    uint16_t    start_index;
							 | 
						||
| 
								 | 
							
								    /* query count */
							 | 
						||
| 
								 | 
							
								    uint8_t     cnt;
							 | 
						||
| 
								 | 
							
								} gw_app_lp_meter_query_rssi_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query low power meter data */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_lp_meter_data {
							 | 
						||
| 
								 | 
							
								    /* query lp meter cmd type, see GW_APP_LP_METER_CMD_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     cmd_type    :4,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                reserved    :4;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_lp_meter_data_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* bcast query low power meter */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_lp_meter_bcast_qr {
							 | 
						||
| 
								 | 
							
								    /* bcast sn */
							 | 
						||
| 
								 | 
							
								    uint8_t     bcast_sn;
							 | 
						||
| 
								 | 
							
								    /* sta count */
							 | 
						||
| 
								 | 
							
								    uint16_t    sta_cnt;
							 | 
						||
| 
								 | 
							
								    /* low power meter count */
							 | 
						||
| 
								 | 
							
								    uint16_t    lp_meter_cnt;
							 | 
						||
| 
								 | 
							
								    /* rssi threshold value */
							 | 
						||
| 
								 | 
							
								    uint8_t     rssi;
							 | 
						||
| 
								 | 
							
								    /* bitmap size */
							 | 
						||
| 
								 | 
							
								    uint16_t    bm_size;
							 | 
						||
| 
								 | 
							
								    /* sec node bitmap */
							 | 
						||
| 
								 | 
							
								    uint8_t     bm[0];
							 | 
						||
| 
								 | 
							
								} gw_app_lp_meter_bcast_qr_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query low power meter info from cco to sta */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_lp_meter_query_data_dl {
							 | 
						||
| 
								 | 
							
								    /* start sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    start_seq;
							 | 
						||
| 
								 | 
							
								    /* query low power meter count */
							 | 
						||
| 
								 | 
							
								    uint8_t     count;
							 | 
						||
| 
								 | 
							
								} gw_app_lp_meter_query_data_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* low power meter report 188 proto data */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_lp_meter_mr_data {
							 | 
						||
| 
								 | 
							
								    /* low power meter mac addr, little endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     mac_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* CJ-T_188-2004 proto data length */
							 | 
						||
| 
								 | 
							
								    uint16_t    data_len;
							 | 
						||
| 
								 | 
							
								    /* CJ-T_188-2004 proto data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_lp_meter_mr_data_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_lp_meter_info_rpt {
							 | 
						||
| 
								 | 
							
								    /* low power meter total count */
							 | 
						||
| 
								 | 
							
								    uint16_t    total_cnt;
							 | 
						||
| 
								 | 
							
								    /* report low power meter count */
							 | 
						||
| 
								 | 
							
								    uint8_t     rpt_cnt;
							 | 
						||
| 
								 | 
							
								    /* gw_app_lp_meter_mr_data_t */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_lp_meter_info_rpt_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_lock_time_data {
							 | 
						||
| 
								 | 
							
								    /* net lock time, uint is 1min.
							 | 
						||
| 
								 | 
							
								     * 0 means no lock.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint16_t    net_lock_time;
							 | 
						||
| 
								 | 
							
								    /* the lock time of abnormal leave net, uint is 1min.
							 | 
						||
| 
								 | 
							
								     * 0 means no lock.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint16_t    abn_lock_time;
							 | 
						||
| 
								 | 
							
								} gw_app_lock_time_data_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_lock_time_hdr {
							 | 
						||
| 
								 | 
							
								    /* version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length, except length of fn */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								                seq         :8,
							 | 
						||
| 
								 | 
							
								    /* data lenght, include length of fn */
							 | 
						||
| 
								 | 
							
								                data_len    :12;
							 | 
						||
| 
								 | 
							
								    /* fn, see GW_APP_LOCK_TIME_FN_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     fn;
							 | 
						||
| 
								 | 
							
								    /* payload data. only fn is GW_APP_LOCK_TIME_FN_SET, data is valid */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_lock_time_hdr_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* rtc time struct */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_rtc_time {
							 | 
						||
| 
								 | 
							
								    /* time stamp, BCD code to represent */
							 | 
						||
| 
								 | 
							
								    uint8_t     sec;
							 | 
						||
| 
								 | 
							
								    uint8_t     min;
							 | 
						||
| 
								 | 
							
								    uint8_t     hour;
							 | 
						||
| 
								 | 
							
								    uint8_t     day;
							 | 
						||
| 
								 | 
							
								    uint8_t     month;
							 | 
						||
| 
								 | 
							
								    uint8_t     year;
							 | 
						||
| 
								 | 
							
								} gw_app_rtc_time_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_rtc_timer_sync_dl {
							 | 
						||
| 
								 | 
							
								    /* version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        :4;
							 | 
						||
| 
								 | 
							
								    /* rtc time, little endian */
							 | 
						||
| 
								 | 
							
								    gw_app_rtc_time_t rtc_time;
							 | 
						||
| 
								 | 
							
								    /* NTB time, unit is 1NTB */
							 | 
						||
| 
								 | 
							
								    uint32_t    ntb_time;
							 | 
						||
| 
								 | 
							
								} gw_app_rtc_timer_sync_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_sta_join_check_data {
							 | 
						||
| 
								 | 
							
								    /* sta join certification state, 0 - disabled, 1 - enable */
							 | 
						||
| 
								 | 
							
								    uint8_t    check_enable;
							 | 
						||
| 
								 | 
							
								} gw_app_sta_join_check_data_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_sta_join_check_hdr {
							 | 
						||
| 
								 | 
							
								    /* version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								                rsvd        :4;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* certification data */
							 | 
						||
| 
								 | 
							
								   uint8_t      data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_sta_join_check_hdr_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* minute collect report function header */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_min_clct_rpt_hdr {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint32_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* flag of response, 0 mean no ack, 1 mean ack/nack */
							 | 
						||
| 
								 | 
							
								                flag_resp   :4,
							 | 
						||
| 
								 | 
							
								    /* data type. see GW_APP_DATA_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								                data_type   :4,
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								                data_len    :12;
							 | 
						||
| 
								 | 
							
								    /* packet sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* funtion code, see GW_APP_MIN_CLCT_RPT_FN_XXX */
							 | 
						||
| 
								 | 
							
								    uint16_t    fn;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_min_clct_rpt_hdr;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* minute collect report function set configuration */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_min_clct_rpt_cfg_info {
							 | 
						||
| 
								 | 
							
								    /* dst address, little-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t     addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* collection interval, unit is 1 minute */
							 | 
						||
| 
								 | 
							
								    uint8_t     interval;
							 | 
						||
| 
								 | 
							
								    /* flag of cfg, see GW_APP_MIN_CLCT_RPT_CFG_FLAG_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     flag;
							 | 
						||
| 
								 | 
							
								    /* proto data type. see GW_APP_DATA_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t     data_type;
							 | 
						||
| 
								 | 
							
								    /* master di, master di is 698 protocol frozen data di */
							 | 
						||
| 
								 | 
							
								    uint32_t    m_di;
							 | 
						||
| 
								 | 
							
								    /* secondary di cnt */
							 | 
						||
| 
								 | 
							
								    uint8_t     cnt;
							 | 
						||
| 
								 | 
							
								    /* secondary di, secondary di is 698 protocol data di */
							 | 
						||
| 
								 | 
							
								    uint32_t    s_di[0];
							 | 
						||
| 
								 | 
							
								} gw_app_min_clct_rpt_cfg_info;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* minute collect report function report data structure */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_min_clct_rpt_data {
							 | 
						||
| 
								 | 
							
								    /* proto data type. GW_APP_DATA_TYPE_69845 */
							 | 
						||
| 
								 | 
							
								    uint8_t     data_type;
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								    uint8_t     rsvd;
							 | 
						||
| 
								 | 
							
								    /* length from cnt to data */
							 | 
						||
| 
								 | 
							
								    uint16_t    len;
							 | 
						||
| 
								 | 
							
								    /* report msg cnt */
							 | 
						||
| 
								 | 
							
								    uint8_t     cnt;
							 | 
						||
| 
								 | 
							
								    /* report data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_min_clct_rpt_data;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* minute collect report function query data req/resp structure */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_min_clct_rpt_query_req_resp {
							 | 
						||
| 
								 | 
							
								    /* proto data type. GW_APP_DATA_TYPE_69845 */
							 | 
						||
| 
								 | 
							
								    uint8_t     data_type;
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								    uint8_t     rsvd;
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								    uint16_t    len;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_min_clct_rpt_query_req_resp;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* production test cmd structure, for GW_APP_ID_PRODUCTION_TEST */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_production_test {
							 | 
						||
| 
								 | 
							
								    /* protocol version */
							 | 
						||
| 
								 | 
							
								    uint16_t    ver         :6,
							 | 
						||
| 
								 | 
							
								    /* header length */
							 | 
						||
| 
								 | 
							
								                header_len  :6,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                reserved    :4;
							 | 
						||
| 
								 | 
							
								    /* function code */
							 | 
						||
| 
								 | 
							
								    uint8_t     fn;
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								    uint16_t    data_len;
							 | 
						||
| 
								 | 
							
								    /* sequence */
							 | 
						||
| 
								 | 
							
								    uint16_t    seq;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t     data[0];
							 | 
						||
| 
								 | 
							
								} gw_app_production_test_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* node address and mac address structure for production test cmd */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_product_test_mac_addr {
							 | 
						||
| 
								 | 
							
								    /* node address, little-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t node_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* mac address, big-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t mac_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} gw_app_product_test_mac_addr_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* chip id info structure for production test cmd */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_product_test_chip_info {
							 | 
						||
| 
								 | 
							
								    /* node address, little-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t node_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* device type, see IOT_PLC_DEV_TYPE_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t dev_type;
							 | 
						||
| 
								 | 
							
								    /* chip info */
							 | 
						||
| 
								 | 
							
								    uint8_t info[GW_APP_PRODUCT_TEST_CHIP_LEN];
							 | 
						||
| 
								 | 
							
								    /* chip version */
							 | 
						||
| 
								 | 
							
								    uint8_t chip_ver[GW_APP_PRODUCT_TEST_VER_LEN];
							 | 
						||
| 
								 | 
							
								} gw_app_product_test_chip_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* module id info structure for production test cmd */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_product_test_mod_info {
							 | 
						||
| 
								 | 
							
								    /* node address, little-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t node_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* module info length */
							 | 
						||
| 
								 | 
							
								    uint8_t len;
							 | 
						||
| 
								 | 
							
								    /* mode info */
							 | 
						||
| 
								 | 
							
								    uint8_t info[GW_APP_PRODUCT_TEST_MODE_LEN];
							 | 
						||
| 
								 | 
							
								} gw_app_product_test_mod_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* version info structure for production test cmd */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_product_test_ver_info {
							 | 
						||
| 
								 | 
							
								    /* node address, little-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t node_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* version */
							 | 
						||
| 
								 | 
							
								    uint8_t ver[GW_APP_PRODUCT_TEST_VER_LEN];
							 | 
						||
| 
								 | 
							
								    /* version date, BCD format */
							 | 
						||
| 
								 | 
							
								    uint8_t module_ver_day;
							 | 
						||
| 
								 | 
							
								    uint8_t module_ver_month;
							 | 
						||
| 
								 | 
							
								    uint8_t module_ver_year;
							 | 
						||
| 
								 | 
							
								    /* vendor id. BCD format. */
							 | 
						||
| 
								 | 
							
								    uint16_t vendor_id;
							 | 
						||
| 
								 | 
							
								    /* chip code. BCD format. */
							 | 
						||
| 
								 | 
							
								    uint16_t chip_code;
							 | 
						||
| 
								 | 
							
								} gw_app_product_test_ver_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* internal version info structure for production test cmd */
							 | 
						||
| 
								 | 
							
								typedef struct _gw_app_product_test_inter_ver {
							 | 
						||
| 
								 | 
							
								    /* node address, little-endian */
							 | 
						||
| 
								 | 
							
								    uint8_t node_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* day of version, BCD, eg. 27 */
							 | 
						||
| 
								 | 
							
								    uint8_t day;
							 | 
						||
| 
								 | 
							
								    /* mon of version, BCD, eg. 07 */
							 | 
						||
| 
								 | 
							
								    uint8_t mon;
							 | 
						||
| 
								 | 
							
								    /* year of version, BCD, eg. 23 */
							 | 
						||
| 
								 | 
							
								    uint8_t year;
							 | 
						||
| 
								 | 
							
								    /* version, BCD, little-endian, eg. 0102 -> 02 01 */
							 | 
						||
| 
								 | 
							
								    uint16_t ver;
							 | 
						||
| 
								 | 
							
								} gw_app_product_test_inter_ver_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma pack(pop)/* restore the pack status */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* PROTO_GW_APP_H */
							 |