2556 lines
		
	
	
		
			102 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			2556 lines
		
	
	
		
			102 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
/****************************************************************************
 | 
						|
 | 
						|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
 | 
						|
 | 
						|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
 | 
						|
be copied by any method or incorporated into another program without
 | 
						|
the express written consent of Aerospace C.Power. This Information or any portion
 | 
						|
thereof remains the property of Aerospace C.Power. The Information contained herein
 | 
						|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
 | 
						|
liability for its use in any way and conveys no license or title under
 | 
						|
any patent or copyright and makes no representation or warranty that this
 | 
						|
Information is free from patent or copyright infringement.
 | 
						|
 | 
						|
****************************************************************************/
 | 
						|
#ifndef IOT_SG_CCO_H
 | 
						|
#define IOT_SG_CCO_H
 | 
						|
 | 
						|
/* os shim includes */
 | 
						|
#include "os_types_api.h"
 | 
						|
#include "os_timer_api.h"
 | 
						|
 | 
						|
/* api includes */
 | 
						|
#include "iot_cli_sg_api.h"
 | 
						|
 | 
						|
/* utils includes */
 | 
						|
#include "iot_meter_addr_hash_table_api.h"
 | 
						|
 | 
						|
/* sg app includes */
 | 
						|
#include "iot_sg_cco_buf.h"
 | 
						|
#include "iot_sg_cco_cmd.h"
 | 
						|
#include "iot_sg_cfg.h"
 | 
						|
 | 
						|
/* sg app driver api includes */
 | 
						|
#include "iot_sg_cco_drv_api.h"
 | 
						|
#include "iot_sg_upgrade.h"
 | 
						|
 | 
						|
/* iot common header files */
 | 
						|
#include "iot_config_api.h"
 | 
						|
#include "iot_rtc_api.h"
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
/* concentrator type definition */
 | 
						|
#define SG_CONCENTRATOR_3762_2009       1   /* 376.2 2009 version */
 | 
						|
#define SG_CONCENTRATOR_3762_2013       2   /* 1376.2 2013 version */
 | 
						|
#define SG_CONCENTRATOR_NW_2016         3   /* Nan Wang 2016 version */
 | 
						|
 | 
						|
/* the station state used for sec node active register */
 | 
						|
#define SEC_NODE_REG_STATE_INIT             0
 | 
						|
#define SEC_NODE_REG_STATE_IN_QR            1
 | 
						|
#define SEC_NODE_REG_STATE_LOCKING          2
 | 
						|
#define SEC_NODE_REG_STATE_QR_NODE_PARAM    3
 | 
						|
#define SEC_NODE_REG_STATE_QR_METER_PARAM   4 /* for xi'an protocol */
 | 
						|
#define SEC_NODE_REG_STATE_DONE             5
 | 
						|
 | 
						|
/* max number of meter reading packet on power line */
 | 
						|
#define IOT_SG_CONCURRENT_MR_LIMIT          10
 | 
						|
 | 
						|
/* invalid sn */
 | 
						|
#define IOT_SG_INVALID_SN                   (0xFFFFFFFF)
 | 
						|
 | 
						|
/* internal message id */
 | 
						|
#define IOT_SG_MSG_ID_READ_POWER_METER      3
 | 
						|
#define IOT_SG_MSG_ID_ROUTER_CONTROL        4
 | 
						|
#define IOT_SG_MSG_ID_ADD_WL_ENTRY          5
 | 
						|
#define IOT_SG_MSG_ID_REMOVE_WL_ENTRY       6
 | 
						|
#define IOT_SG_MSG_ID_BROADCAST_DATA        7
 | 
						|
#define IOT_SG_MSG_ID_SET_EVT_RPT_FLAG      8
 | 
						|
#define IOT_SG_MSG_ID_COMM_TEST             9
 | 
						|
#define IOT_SG_MSG_ID_ADD_WLII_ENTRY        50
 | 
						|
#define IOT_SG_MSG_ID_REMOVE_WLII_ENTRY     51
 | 
						|
#define IOT_SG_MSG_ID_CORRECT_STA_TIME      52
 | 
						|
#define IOT_SG_MSG_ID_EXT_TASK              53
 | 
						|
#define IOT_SG_MSG_ID_CLEAR_ALL_WL_ENTRY    54
 | 
						|
#define IOT_SG_MSG_ID_CLEAR_ALL_WLII_ENTRY  55
 | 
						|
#define IOT_SG_MSG_ID_ADD_BL_ENTRY          56
 | 
						|
#define IOT_SG_MSG_ID_REMOVE_BL_ENTRY       57
 | 
						|
#define IOT_SG_MSG_ID_REMOVE_ALL_BL_ENTRY   58
 | 
						|
#define IOT_SG_MSG_ID_MR_CMD_TX_DONE        59  /* mr cmd send done */
 | 
						|
 | 
						|
/* sg upgrade related message */
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_START         11
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_STOP          12
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_SEND_BLOCK1   13
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_BCAST_ALL     14
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_RESEND        15
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_LATE_STA      16
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_QUERY_STA_1   17
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_EXECUTE       18
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_WIN_TIMEOUT   19  /* upgrade window timeout */
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_SEND_STOP_CMD 20  /* send stop commands */
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_QUERY_STA_2   21  /* query 2 state timeout */
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_CLI_MSG       22  /* cli command */
 | 
						|
#define IOT_SG_MSG_ID_UPGRADE_TX_DONE       23  /* upgrade bcast cmd send done*/
 | 
						|
 | 
						|
/* buf related message */
 | 
						|
#define IOT_SG_MSG_ID_SEND_DL_BUF_DATA      30  /* send data in dl buffer */
 | 
						|
#define IOT_SG_MSG_ID_SEND_UL_BUF_DATA      31  /* send data in ul buffer */
 | 
						|
#define IOT_SG_MSG_ID_REFRESH_BUF_ENTRY     32  /* refresh buffer entry */
 | 
						|
#define IOT_SG_MSG_ID_TSFM_DETECT_DONE      33  /* transformer detect done */
 | 
						|
#define IOT_SG_MSG_ID_LOG_TO_FLASH          34  /* print log to flash */
 | 
						|
 | 
						|
/* max power meter count in a 3762 pkt */
 | 
						|
#define IOT_SG_CCO_MAX_RPT_PM_CNT_BITMAP    (35)
 | 
						|
 | 
						|
#define IOT_SG_CCO_MAX_RPT_PM_CNT_ADDR \
 | 
						|
    ((0xFF - 1) / sizeof(gw_app_power_evt_pm_info_t))
 | 
						|
 | 
						|
/* task status */
 | 
						|
#define IOT_SG_TASK_STATUS_PENDING          0
 | 
						|
#define IOT_SG_TASK_STATUS_STARTING         1
 | 
						|
 | 
						|
/* if mr data back time is so late then improve the mr data priority,
 | 
						|
 * unit is 1s.
 | 
						|
 */
 | 
						|
#define IOT_SG_CCO_MR_DATA_RESERVE_TIME     5
 | 
						|
 | 
						|
/* if clct data back time is so late then improve the clct data priority,
 | 
						|
 * unit is 1s.
 | 
						|
 */
 | 
						|
#define IOT_SG_CCO_CLCT_DATA_RESERVE_TIME   5
 | 
						|
 | 
						|
/* transformer detect state */
 | 
						|
#define IOT_SG_CCO_TSFM_DETECT_S_CCO_CHECK  (0)
 | 
						|
#define IOT_SG_CCO_TSFM_DETECT_S_STA_CHECK  (1)
 | 
						|
#define IOT_SG_CCO_TSFM_DETECT_S_PW_CHECK   (2)
 | 
						|
 | 
						|
/* module id length, same as GW_APP_MODULE_ID_INFO_LEN */
 | 
						|
#define IOT_SG_CCO_MOD_ID_LEN               (11)
 | 
						|
 | 
						|
/* transform detect mode */
 | 
						|
#define IOT_SG_CCO_TSFM_DETECT_MODE_CENTRALIZE   (1 << 0)
 | 
						|
#define IOT_SG_CCO_TSFM_DETECT_MODE_DISTRIBUTE   (1 << 1)
 | 
						|
#define IOT_SG_CCO_TSFM_DETECT_MODE_ALL          \
 | 
						|
    (IOT_SG_CCO_TSFM_DETECT_MODE_CENTRALIZE |    \
 | 
						|
    IOT_SG_CCO_TSFM_DETECT_MODE_DISTRIBUTE)
 | 
						|
 | 
						|
/* unsame vendor max count */
 | 
						|
#define IOT_SG_CCO_UNSAME_VENDOR_MAX_COUNT  (20)
 | 
						|
 | 
						|
/* power event pm bitmap size */
 | 
						|
#define IOT_SG_CCO_POWER_EVENT_BM_SIZE              (256)
 | 
						|
 | 
						|
/* bitmap size for receiving branch detect signal */
 | 
						|
#define IOT_SG_CCO_BD_BM_SIZE                       (256)
 | 
						|
 | 
						|
#define IOT_SG_CCO_BD_RECV_UNSUPP                   (0)
 | 
						|
#define IOT_SG_CCO_BD_RECV_SUPP                     (1)
 | 
						|
#define IOT_SG_CCO_BD_RECV_UNKNOWN                  (2)
 | 
						|
 | 
						|
/* branch detect node special father index */
 | 
						|
#define IOT_SG_CCO_BD_FATHER_CCO                    (0)
 | 
						|
 | 
						|
/* branch detect device state for bcsd or smt */
 | 
						|
/* branch detect device defaule state */
 | 
						|
#define IOT_SG_CCO_BD_DEV_STATE_INIT                (0)
 | 
						|
/* smt report neighbor node info */
 | 
						|
#define IOT_SG_CCO_BD_DEV_STATE_NEI_NODE_RPT        (1)
 | 
						|
/* smt report neighbor node phase info */
 | 
						|
#define IOT_SG_CCO_BD_DEV_STATE_NEI_PHASE_RPT       (2)
 | 
						|
/* smt report meter info */
 | 
						|
#define IOT_SG_CCO_BD_DEV_STATE_METER_RPT           (3)
 | 
						|
/* smt clean history data complete */
 | 
						|
#define IOT_SG_CCO_BD_DEV_STATE_CLEAR               (4)
 | 
						|
/* smt or bcsd branch detect send start */
 | 
						|
#define IOT_SG_CCO_BD_DEV_STATE_SEND_START          (5)
 | 
						|
/* smt or bcsd query branch detect send complete */
 | 
						|
#define IOT_SG_CCO_BD_DEV_STATE_SEND_COMPLETE       (6)
 | 
						|
/* smt report branch detect info complete */
 | 
						|
#define IOT_SG_CCO_BD_DEV_STATE_RESULT              (7)
 | 
						|
/* smt set node info complete */
 | 
						|
#define IOT_SG_CCO_BD_DEV_STATE_SET_DONE            (8)
 | 
						|
 | 
						|
/* max retry count of cco send command to node when branch detect */
 | 
						|
#define IOT_SG_CCO_BD_CMD_SEND_MAX                  (11)
 | 
						|
 | 
						|
/* reserved ul buf cnt for sec node query */
 | 
						|
#define IOT_SG_CCO_RSVD_UL_BUF_CNT                  (10)
 | 
						|
 | 
						|
/* five seconds loop timeout, unit is 1s */
 | 
						|
#define IOT_SG_CCO_LOOP1_TIMEOUT                    (5)
 | 
						|
/* half hour loop timeout, unit is 1s */
 | 
						|
#define IOT_SG_CCO_LOOP2_TIMEOUT                    (30 * 60)
 | 
						|
 | 
						|
/* power meter action definition */
 | 
						|
#define IOT_SG_CCO_PM_ACTION_ADD                    (0)
 | 
						|
#define IOT_SG_CCO_PM_ACTION_DEL                    (1)
 | 
						|
 | 
						|
/* send bcast interval that query sec node reg result pkt */
 | 
						|
#define IOT_SG_CCO_SEND_BCAST_INTERVAL              (6)
 | 
						|
 | 
						|
/* max number of branch detect packet sent to power line */
 | 
						|
#define IOT_SG_CCO_INTERN_MAX_CON_CNT               (5)
 | 
						|
 | 
						|
/* define max buffer size to return the meter info list */
 | 
						|
#define SG_CCO_MAX_METER_INFO_SIZE                  (512)
 | 
						|
 | 
						|
#define IOT_SG_CCO_TEI_TO_STA_IDX(tei)              ((uint16_t)((tei) - 1))
 | 
						|
#define IOT_SG_CCO_STA_IDX_TO_TEI(idx)              (idx + 1)
 | 
						|
 | 
						|
/* give smallest number, which is -128 */
 | 
						|
#define IOT_SG_CCO_INVALID_SNR                      (-128)
 | 
						|
 | 
						|
/* function bitmap length */
 | 
						|
#define IOT_SG_CCO_FLASH_BM_LEN                     (1)
 | 
						|
 | 
						|
/* repeat meter read times */
 | 
						|
#define IOT_SG_CCO_RT_MR_RETRY_COUNT                (3)
 | 
						|
 | 
						|
#define IOT_SG_CCO_GET_CNT_MODULE_ID                (1)
 | 
						|
#define IOT_SG_CCO_GET_CNT_CLCT_DATA_PARAM          (2)
 | 
						|
#define IOT_SG_CCO_GET_CNT_CHIP_ID                  (3)
 | 
						|
#define IOT_SG_CCO_GET_CNT_LOCK_TIME                (4)
 | 
						|
#define IOT_SG_CCO_GET_CNT_MIN_CLCT                 (5)
 | 
						|
#define IOT_SG_CCO_GET_CNT_SET_EVT_STATE            (6)
 | 
						|
#define IOT_SG_CCO_GET_CNT_CLCT_TSFM_FEATURE        (7)
 | 
						|
#define IOT_SG_CCO_GET_CNT_NODE_LIST                (8)
 | 
						|
#define IOT_SG_CCO_GET_CNT_LP_INFO                  (9)
 | 
						|
#define IOT_SG_CCO_GET_CNT_LP_DEVICE                (10)
 | 
						|
#define IOT_SG_CCO_GET_CNT_LP_RSSI                  (11)
 | 
						|
#define IOT_SG_CCO_GET_CNT_NODE_NET_INFO            (12)
 | 
						|
#define IOT_SG_CCO_GET_CNT_QR_SCORE_INFO            (13)
 | 
						|
#define IOT_SG_CCO_GET_CNT_X4                       (14)
 | 
						|
#define IOT_SG_CCO_GET_CNT_CLOCK_MANAGE             (15)
 | 
						|
#define IOT_SG_CCO_GET_CNT_NLI_CFG                  (16)
 | 
						|
#define IOT_SG_CCO_GET_CNT_EDGE_SET                 (17)
 | 
						|
 | 
						|
/* jolt node bitmap count */
 | 
						|
#define IOT_SG_CCO_JOLT_BITMAP_CNT                  (IOT_SG_MAX_METER_COUNT / \
 | 
						|
                                                    8 + 1)
 | 
						|
 | 
						|
/* defines the diff data max length in white list */
 | 
						|
#define IOT_SG_CCO_WL_DIFF_DATA_MAX_LEN             (4)
 | 
						|
 | 
						|
/* update the white list to PIB intervals, uint is 1ms */
 | 
						|
#define IOT_SG_CCO_WL_UPDATE_INTERVAL               3000
 | 
						|
#define IOT_SG_CCO_WL_UPDATE_INTERVAL_LONG          (32 * 1000)
 | 
						|
 | 
						|
/* set sta collect parameter packet bcast interval */
 | 
						|
#define IOT_SG_CCO_SET_STA_CLCT_PARAM_BCAST_INTERVAL (7)
 | 
						|
 | 
						|
/* set sta collect parameter max count */
 | 
						|
#define IOT_SG_CCO_STA_CLCT_PARAM_MAX_CNT            (63)
 | 
						|
 | 
						|
/* release date len of sw/hw version */
 | 
						|
#define IOT_SG_CCO_VERSION_DATE_LEN                  (3)
 | 
						|
 | 
						|
typedef void *iot_sg_cco_mac_map_h;
 | 
						|
 | 
						|
/* pack for the structures in the whole file */
 | 
						|
#pragma pack(push)  /* save the pack status */
 | 
						|
#pragma pack(1)     /* 1 byte align */
 | 
						|
 | 
						|
/* low power meter rssi data */
 | 
						|
typedef struct _iot_sg_cco_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;
 | 
						|
} iot_sg_cco_lp_meter_rssi_info_t;
 | 
						|
 | 
						|
/* meter info for search result data */
 | 
						|
typedef struct _iot_sg_cco_search_pm_info {
 | 
						|
    /* meter mac address, little-endian */
 | 
						|
    uint8_t     mac[IOT_MAC_ADDR_LEN];
 | 
						|
    /* pm protocol type */
 | 
						|
    uint8_t     proto_type;
 | 
						|
} iot_sg_cco_search_pm_info_t;
 | 
						|
 | 
						|
/* event report filter for shanxi */
 | 
						|
typedef struct _iot_sg_cco_filter_evt_rpt {
 | 
						|
    /* event report data crc */
 | 
						|
    uint16_t    crc;
 | 
						|
    /* last same event report time, unit is 1s */
 | 
						|
    uint32_t    rpt_time;
 | 
						|
} iot_sg_cco_filter_evt_rpt;
 | 
						|
 | 
						|
typedef struct _iot_sg_broadcast_data {
 | 
						|
    /* protocol type of broadcast data */
 | 
						|
    uint8_t         data_type;
 | 
						|
    /* bcast type, see IOT_SG_CCO_BCAST_TYPE_XXX */
 | 
						|
    uint8_t         bcast_type;
 | 
						|
    /* length type of broadcast data */
 | 
						|
    uint16_t        data_len;
 | 
						|
    /* ntb for recv correct time message */
 | 
						|
    uint32_t        ntb;
 | 
						|
    /* sta mac address */
 | 
						|
    uint8_t         sta_mac[IOT_MAC_ADDR_LEN];
 | 
						|
    /* broadcast data */
 | 
						|
    uint8_t         data[0];
 | 
						|
} iot_sg_broadcast_data_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_send_data_to_meter {
 | 
						|
    /* station address */
 | 
						|
    uint8_t         sta_mac[IOT_MAC_ADDR_LEN];
 | 
						|
    /* mac address of power meter */
 | 
						|
    uint8_t         meter_mac[IOT_MAC_ADDR_LEN];
 | 
						|
    /* 1 - meter reading timeout need to double, 0 - not */
 | 
						|
    uint8_t         timeout_double:6,
 | 
						|
    /* if need reply */
 | 
						|
                    need_reply    :1,
 | 
						|
    /* forward data flag, 0 - don't need, 1 - need.*/
 | 
						|
                    forward       :1;
 | 
						|
    /* protocol type of meter */
 | 
						|
    uint8_t         data_type;
 | 
						|
    /* length of meter data */
 | 
						|
    uint16_t        data_len;
 | 
						|
    /* ntb when receive this command */
 | 
						|
    uint32_t        rev_ntb;
 | 
						|
    /* the data that transmit to meter */
 | 
						|
    uint8_t         data[0];
 | 
						|
} iot_sg_send_data_to_meter_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_send_data_to_meter_wrapper {
 | 
						|
    /* GW use 2 byte for SN. Value larger than 0xFFFF is invalid. */
 | 
						|
    uint32_t                      sn;
 | 
						|
    /* retry count */
 | 
						|
    uint32_t                      retry_cnt;
 | 
						|
    /* meter reading data */
 | 
						|
    iot_sg_send_data_to_meter_t   data_to_meter;
 | 
						|
}iot_sg_send_data_to_meter_wrapper_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_wl_mac_addr_op_info {
 | 
						|
    /* count of meter mac */
 | 
						|
    uint8_t count;
 | 
						|
    /* mac addr list of node for wl operation */
 | 
						|
    uint8_t mac_addr[0][IOT_MAC_ADDR_LEN];
 | 
						|
} iot_sg_wl_mac_addr_op_info_t;
 | 
						|
 | 
						|
/* private protocol node info data */
 | 
						|
typedef struct _iot_sg_cco_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 PROTO_TYPE_XXX */
 | 
						|
    uint8_t  proto_type : 4,
 | 
						|
    /* node device type */
 | 
						|
             dev_type : 4;
 | 
						|
    /* reserve for future */
 | 
						|
    uint8_t  reserve2;
 | 
						|
} iot_sg_cco_tsfm_node_info_pw_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_clct_data_read {
 | 
						|
    /* sta collect parameter v2.8 task id */
 | 
						|
    uint8_t                     task_id;
 | 
						|
    /* power meter address, little endian */
 | 
						|
    uint8_t                     pm_mac[IOT_MAC_ADDR_LEN];
 | 
						|
    /* proto type, see PROTO_TYPE_XXX */
 | 
						|
    uint8_t                     proto_type;
 | 
						|
    /* 0 - single phase meter, 1 - three phase meter */
 | 
						|
    uint8_t                     pm_type;
 | 
						|
    /* collect read time */
 | 
						|
    iot_sg_cco_time_t           tm;
 | 
						|
} iot_sg_cco_clct_data_read_t;
 | 
						|
 | 
						|
#pragma pack(pop)   /* restore the pack status */
 | 
						|
 | 
						|
/* smart grid cco role persistent storage structure */
 | 
						|
typedef struct _iot_sg_cco_ps {
 | 
						|
    /* concentrator type connected to local device */
 | 
						|
    uint8_t     cctt_version;
 | 
						|
    /* concentrator manufacture code connected to local device*/
 | 
						|
    uint8_t     cctt_mft_code;
 | 
						|
    /* route meter */
 | 
						|
    uint8_t     rt_mr_enabled;
 | 
						|
} iot_sg_cco_ps_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_upgrade_file {
 | 
						|
    /* file identity */
 | 
						|
    uint8_t             id;
 | 
						|
    /* file size */
 | 
						|
    uint32_t            size;
 | 
						|
    /* file version */
 | 
						|
    uint32_t            version;
 | 
						|
    /* crc16 from cctt, 0: invalid , others valid */
 | 
						|
    uint16_t            crc16;
 | 
						|
    uint16_t            crc16_x25;
 | 
						|
    uint16_t            crc16_ccitt;
 | 
						|
    uint16_t            crc16_false;
 | 
						|
    uint16_t            crc16_xmodem;
 | 
						|
    /* crc32 calculated from received data when sending data to STA,
 | 
						|
     * if the cco upgrade it used to calculate the crc value of the file.
 | 
						|
     */
 | 
						|
    uint32_t            crc32;
 | 
						|
    /* file crc */
 | 
						|
    uint32_t            file_crc;
 | 
						|
    /* file type - see IOT_FILE_TYPE_XXX */
 | 
						|
    uint32_t            file_type;
 | 
						|
    /* bytes length of the cco received upgrade data that from cctt */
 | 
						|
    uint32_t            recv_byte_idx;
 | 
						|
    /* bytes written to flash */
 | 
						|
    uint32_t            write_byte_idx;
 | 
						|
    /* block count of writing flash */
 | 
						|
    uint32_t            block_index;
 | 
						|
    /* cache the whole package file for CCo/STA upgrading */
 | 
						|
    uint8_t             *file_data;
 | 
						|
    /* cache CCo upgrade file */
 | 
						|
    uint8_t             *cache_data;
 | 
						|
    /* index bitmap for CCO receive block from cctt. */
 | 
						|
    uint8_t             block_bitmap[IOT_SG_UPGRADE_BM_SIZE];
 | 
						|
}iot_sg_cco_upgrade_file_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_upgrade {
 | 
						|
    /* count of STA need to be started for upgrading. */
 | 
						|
    uint32_t                sta2start_cnt;
 | 
						|
    /* local upgrading block size */
 | 
						|
    uint32_t                block_size;
 | 
						|
    /* block size of PLC upgrading packet*/
 | 
						|
    uint16_t                plc_block_size;
 | 
						|
    /* total block count to send on plc */
 | 
						|
    uint16_t                plc_block_cnt;
 | 
						|
    /* file offset used when receive firmware data from cctt */
 | 
						|
    uint32_t                file_data_offset;
 | 
						|
    /* upgrade id */
 | 
						|
    uint32_t                upgrade_id;
 | 
						|
    /* upgrade state */
 | 
						|
    uint32_t                state;
 | 
						|
    /* count of STA that received upgrade file */
 | 
						|
    uint32_t                recv_file_sta_cnt;
 | 
						|
 | 
						|
    /* query retry cnt */
 | 
						|
    uint32_t                query_retry_cnt;
 | 
						|
    /* total cnt of start times in this upgrading round. */
 | 
						|
    uint32_t                start_cnt;
 | 
						|
    /* count of loop that no STA got start in a starting loop. */
 | 
						|
    uint32_t                start_fail_cnt;
 | 
						|
    /* start step. Start each sta one by one rapidly, then make sure each sta
 | 
						|
     * was started to receive upgrading file.
 | 
						|
     */
 | 
						|
    uint8_t                 start_step;
 | 
						|
    /* query step. Query each sta one by one rapidly, then make sure each sta
 | 
						|
     * reply its info by query ack.
 | 
						|
     */
 | 
						|
    uint8_t                 query_step;
 | 
						|
    /* send step. Send each data block one by one rapidly,
 | 
						|
     * then retry missed data block.
 | 
						|
     */
 | 
						|
    uint8_t                 send_step;
 | 
						|
    /* execute step. Send execute command by unicast to all STA rapidly,
 | 
						|
     * then retry missed STA.
 | 
						|
     */
 | 
						|
    uint8_t                 exe_step;
 | 
						|
    /* send retry count */
 | 
						|
    uint8_t                 send_retry_cnt;
 | 
						|
    /* max retry count of the whole upgrading process. */
 | 
						|
    uint8_t                 total_retry_cnt;
 | 
						|
    /* bitmap for STA receive state within a window */
 | 
						|
    uint8_t                 bitmap[IOT_SG_CCO_UPGRADE_BM_SIZE];
 | 
						|
    /* full bitmap for STA receive state. */
 | 
						|
    uint8_t                 full_bitmap[IOT_SG_CCO_UPGRADE_BM_SIZE_MAX];
 | 
						|
    /* total block count of the upgrading file */
 | 
						|
    uint16_t                block_cnt;
 | 
						|
    /* index of data block to send to STA */
 | 
						|
    uint16_t                send_index;
 | 
						|
    /* index of the STA being upgrading */
 | 
						|
    uint16_t                sta_index;
 | 
						|
    /* mac address of the STA being upgrading */
 | 
						|
    uint8_t                 sta_mac_addr[IOT_MAC_ADDR_LEN];
 | 
						|
    /* mac address of the upgrade destination devices */
 | 
						|
    uint8_t                 dest_mac_addr[IOT_MAC_ADDR_LEN];
 | 
						|
    /* upgrade file info */
 | 
						|
    iot_sg_cco_upgrade_file_t   file_info;
 | 
						|
    /* count of STAs joined the network */
 | 
						|
    uint16_t                sta_cnt;
 | 
						|
    /* count of STAS upgrade failed */
 | 
						|
    uint16_t                sta_fail_cnt;
 | 
						|
    /* stop upgrading cmd send count */
 | 
						|
    uint16_t                stop_send_cnt;
 | 
						|
    /* count of round to send execute command */
 | 
						|
    uint16_t                exe_round;
 | 
						|
    /* count for execute command to send */
 | 
						|
    uint16_t                exe_bcast_cnt;
 | 
						|
    /* if it's known upgrading file. */
 | 
						|
    uint8_t                 is_known_file;
 | 
						|
    /* cli upgrading available */
 | 
						|
    uint8_t                 cli_upgrade_available;
 | 
						|
    /* vendor id from upgrade file hdr */
 | 
						|
    uint16_t                vendor_id;
 | 
						|
    /* window time of upgrade - unit: ms */
 | 
						|
    uint32_t                window_tm;
 | 
						|
    /* upgrade type */
 | 
						|
    uint8_t                 upgrade_type;
 | 
						|
    /* CCo shall query STA's version info. */
 | 
						|
    uint8_t                 shall_qr_version;
 | 
						|
    /* index of STA entry to query vendor info. */
 | 
						|
    uint16_t                qr_index;
 | 
						|
    /* upgrade exe wait count */
 | 
						|
    uint8_t                 exe_wait_cnt;
 | 
						|
    /* bcast wait flag */
 | 
						|
    uint8_t                 bcast_wait;
 | 
						|
    /* cco/sta support max upgrade file size */
 | 
						|
    uint32_t                upgrade_file_limit;
 | 
						|
} iot_sg_cco_upgrade_t;
 | 
						|
 | 
						|
/* router meter reading controller */
 | 
						|
typedef struct _iot_sg_cco_rt_mr_ctrl {
 | 
						|
    /* the sn of cco report meter reading result */
 | 
						|
    uint8_t                 rpt_sn;
 | 
						|
    /* see IOT_SG_CALLER_TYPE_XXX. */
 | 
						|
    uint8_t                 mr_caller;
 | 
						|
    /* the count of cctt or cli no response, when cco request meter reading */
 | 
						|
    uint8_t                 no_rsp_cnt;
 | 
						|
    /* the current status of route active meter reading
 | 
						|
     * see IOT_SG_CCO_RT_AMR_STATE_XXX.
 | 
						|
     */
 | 
						|
    uint8_t                 rt_amr_status;
 | 
						|
    /* flag to mark if fujian protocol advance meter reading */
 | 
						|
    uint8_t                 is_special_amr          :1,
 | 
						|
    /* reserved */
 | 
						|
                            rsvd                    :7;
 | 
						|
    /* the index of current meter reading power meter */
 | 
						|
    uint16_t                read_pm_index;
 | 
						|
    /* repeat request meter counter */
 | 
						|
    uint16_t                meter_read_retry_count;
 | 
						|
    /* meter reading end index, IOT_SG_WL_ENTRY_END_INDEX or
 | 
						|
     * IOT_SG_CCO_WLII_ENTRY_START_INDEX
 | 
						|
     */
 | 
						|
    uint16_t                end_idx;
 | 
						|
    /* backup sn for router meter reading ack */
 | 
						|
    uint16_t                backup_ack_sn;
 | 
						|
    /* timer used by driver request */
 | 
						|
    timer_id_t              mr_timer;
 | 
						|
} iot_sg_cco_rt_mr_ctrl_t;
 | 
						|
 | 
						|
/* predict meter reading controller */
 | 
						|
typedef struct _iot_sg_cco_predict_mr_ctrl {
 | 
						|
    /* the current status of predict meter reading
 | 
						|
     * see IOT_SG_CCO_PREDICT_MR_STATE_XXX.
 | 
						|
     */
 | 
						|
    uint8_t                 pre_mr_status;
 | 
						|
    /* predict meter reading concurrence request count */
 | 
						|
    uint8_t                 con_req_cnt;
 | 
						|
    /* predict meter reading not response time, unit 1s. */
 | 
						|
    uint8_t                 no_rsp_time;
 | 
						|
    /* the index of current meter reading power meter */
 | 
						|
    uint16_t                read_pm_index;
 | 
						|
} iot_sg_cco_predict_mr_ctrl_t;
 | 
						|
 | 
						|
/* transformer detect data */
 | 
						|
typedef struct _iot_sg_cco_tsfm_feature {
 | 
						|
    /* broadcast transformer feature count, unit is 1s */
 | 
						|
    uint8_t                 bcast_tsfm_feature_cnt;
 | 
						|
    /* broadcast transformer feature state */
 | 
						|
    uint8_t                 bcast_tsfm_feature_state;
 | 
						|
    /* collect count for sta transformer feature */
 | 
						|
    uint8_t                 collect_cnt;
 | 
						|
    /* collect sequence for sta transformer feature */
 | 
						|
    uint8_t                 collect_seq;
 | 
						|
    /* start collect ntb for sta transformer feature */
 | 
						|
    uint32_t                collect_start_ntb;
 | 
						|
    /* node index of collecting transformer feature */
 | 
						|
    uint16_t                collect_tsfm_feature_node_idx;
 | 
						|
    /* transform detect mode, see IOT_SG_CCO_TSFM_DETECT_MODE_xxx */
 | 
						|
    uint8_t                 tsfm_detect_mode        :2,
 | 
						|
    /* reserved */
 | 
						|
                            rsvd                    :6;
 | 
						|
    /* broadcast transformer feature round */
 | 
						|
    uint8_t                 bcast_tsfm_feature_round;
 | 
						|
} iot_sg_cco_tsfm_feature_t;
 | 
						|
 | 
						|
/* for branch detect */
 | 
						|
typedef struct _iot_sg_cco_branch_detect {
 | 
						|
    /* branch detect enabled */
 | 
						|
    uint8_t                 enabled;
 | 
						|
    /* branch detect state, see IOT_SG_CCO_BRANCH_DETECT_XXX */
 | 
						|
    uint8_t                 state;
 | 
						|
    /* timeout timer count */
 | 
						|
    uint32_t                timeout_n;
 | 
						|
    /* father node bitmap for branch detect */
 | 
						|
    uint8_t                 father_bm[2][IOT_SG_CCO_BD_BM_SIZE];
 | 
						|
    /* branch detect send interval time, unit is 1s */
 | 
						|
    uint8_t                 send_interval;
 | 
						|
    /* divide all node into several groups according to the node serial number.
 | 
						|
     * The number of each group of node does not exceed the number of available
 | 
						|
     * codes. This variable marks the currently recognized group.
 | 
						|
     */
 | 
						|
    uint16_t                group_number    : 15,
 | 
						|
    /* flag to mark whether a node in the current group has launched */
 | 
						|
                            group_launched  : 1;
 | 
						|
    /* branch detect send index */
 | 
						|
    uint16_t                send_index;
 | 
						|
    /* send phase */
 | 
						|
    uint8_t                 send_phase;
 | 
						|
    /* branch detect execute round */
 | 
						|
    uint8_t                 execute_round;
 | 
						|
    /* branch detect launch sequence number */
 | 
						|
    uint8_t                 br_launch_sn;
 | 
						|
    /* branch detect mod, see IOT_SG_CCO_BD_MOD_XXX */
 | 
						|
    uint8_t                 bd_mod  : 4,
 | 
						|
    /* branch detect type, see IOT_SG_CCO_BD_TYPE_XXX */
 | 
						|
                            bd_type : 4;
 | 
						|
    /* branch identification disturbance control pulse ahead, unit is 1us */
 | 
						|
    uint16_t                ahead;
 | 
						|
    /* branch identification disturbance control pulse duration, unit is 1us */
 | 
						|
    uint16_t                dur;
 | 
						|
    /* branch detect start time stamp of each round, unit is 1s */
 | 
						|
    uint32_t                round_start_ts;
 | 
						|
} iot_sg_cco_branch_detect_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_pw_tsfm {
 | 
						|
    /* pw tsfm enabled */
 | 
						|
    uint8_t                 enabled;
 | 
						|
    /* branch detect state, see IOT_SG_CCO_PW_TSFM_XXX */
 | 
						|
    uint8_t                 state;
 | 
						|
    /* timeout timer count */
 | 
						|
    uint8_t                 timeout_n;
 | 
						|
    /* pw tsfm query interval time, unit is 1s */
 | 
						|
    uint8_t                 query_interval;
 | 
						|
    /* father node bitmap for pw tsfm */
 | 
						|
    uint8_t                 father_bm[2][IOT_SG_CCO_BD_BM_SIZE];
 | 
						|
    /* pw tsfm send index */
 | 
						|
    uint16_t                send_index;
 | 
						|
    /* divide all node into several groups according to the node serial number.
 | 
						|
     * The number of each group of node does not exceed the number of available
 | 
						|
     * codes. This variable marks the currently recognized group.
 | 
						|
     */
 | 
						|
    uint16_t                group_number    : 15,
 | 
						|
    /* flag to mark whether a node in the current group has launched */
 | 
						|
                            group_launched  : 1;
 | 
						|
    /* pw tsfm execute round */
 | 
						|
    uint8_t                 execute_round;
 | 
						|
    /* flag to mark if there are any node that do not know the device type */
 | 
						|
    uint8_t                 unknown_bd_recv_exist;
 | 
						|
    /* pw tsfm disturbance control pulse ahead, unit is 1us */
 | 
						|
    uint16_t                ahead;
 | 
						|
    /* pw tsfm disturbance control pulse duration, unit is 1us */
 | 
						|
    uint16_t                dur;
 | 
						|
} iot_sg_cco_pw_tsfm_t;
 | 
						|
 | 
						|
/* set score parameter */
 | 
						|
typedef struct _iot_sg_cco_set_score_parameter {
 | 
						|
    /* pm score state */
 | 
						|
    uint8_t                 pm_score_state;
 | 
						|
    /* pm score info query index */
 | 
						|
    uint16_t                pm_score_query_idx;
 | 
						|
    /* power meter score timeout interval, unit is 1s */
 | 
						|
    uint16_t                pm_score_timeout_interval;
 | 
						|
} iot_sg_cco_set_score_parameter_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_clct_task_parm {
 | 
						|
    /* flag to mark if received all sta init collection task */
 | 
						|
    uint8_t                 all_sta_init_clct_task :1,
 | 
						|
    /* flag to mark if start collect task bcast */
 | 
						|
                            bcast_enable           :1,
 | 
						|
    /* reserved */
 | 
						|
                            reserved               :6;
 | 
						|
    /* collect task bcast send index */
 | 
						|
    uint16_t                bcast_idx;
 | 
						|
    /* collect task bcast sn */
 | 
						|
    uint16_t                bcast_sn;
 | 
						|
    /* station init collection task index */
 | 
						|
    uint16_t                sta_init_clct_task_idx;
 | 
						|
} iot_sg_cco_clct_task_param_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_lock_time_param {
 | 
						|
    /* flag to mark if received all sta set lock time done */
 | 
						|
    uint8_t                 all_sta_set_done       :1,
 | 
						|
    /* enable set lock time when receive cctt command */
 | 
						|
                            enable_flag            :1,
 | 
						|
    /* reserved */
 | 
						|
                            reserved               :6;
 | 
						|
    /* station lock time info query index */
 | 
						|
    uint16_t                sta_lock_time_query_idx;
 | 
						|
    /* 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;
 | 
						|
} iot_sg_cco_lock_time_param_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_lp_meter_param {
 | 
						|
    /* for beijing low power meter */
 | 
						|
    uint8_t                 nw_fmt_done            :1,
 | 
						|
    /* low power meter count changed */
 | 
						|
                            cnt_chg                :1,
 | 
						|
    /* flag to mark if new collector ii join */
 | 
						|
                            new_clct_ii            :1,
 | 
						|
    /* flag to mark if low power meter read enable */
 | 
						|
                            read_enable            :1,
 | 
						|
    /* reserved */
 | 
						|
                            rsvd                   :4;
 | 
						|
    /* low power meter state */
 | 
						|
    uint8_t                 state                  :6,
 | 
						|
    /* low power meter search */
 | 
						|
                            search                 :1,
 | 
						|
    /* some node parameter config failure */
 | 
						|
                            cfg_fail_flag          :1;
 | 
						|
    /* low power meter config failure count continuously */
 | 
						|
    uint8_t                 cfg_fail_cnt;
 | 
						|
    /* low power meter count */
 | 
						|
    uint16_t                cnt;
 | 
						|
    /* low power meter config index */
 | 
						|
    uint16_t                cfg_idx;
 | 
						|
    /* low power meter info query index */
 | 
						|
    uint16_t                query_idx;
 | 
						|
    /* low power meter rssi info query index */
 | 
						|
    uint16_t                rssi_query_idx;
 | 
						|
    /* low power dev type info query index */
 | 
						|
    uint16_t                dev_type_query_idx;
 | 
						|
    /* low power meter timeout interval, unit is 1s */
 | 
						|
    uint32_t                timeout_interval;
 | 
						|
    /* low power meter bcast query interval, unit is 1s */
 | 
						|
    uint16_t                bcast_qr_interval;
 | 
						|
    /* single low power meter timeout interval, unit is 1s */
 | 
						|
    uint32_t                single_lp_meter_timeout_interval;
 | 
						|
    /* low power meter search timer */
 | 
						|
    timer_id_t              search_timer;
 | 
						|
} iot_sg_cco_lp_meter_param_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_active_qr_pm {
 | 
						|
    /* enable query pm after sta join */
 | 
						|
    uint8_t                 enable_qr_pm           :1,
 | 
						|
    /* 0 - concentrate report, 1 - sporadic report */
 | 
						|
                            rpt_mode               :1,
 | 
						|
    /* 22 clock active report state, see IOT_SG_CCO_ACTIVE_RPT_STATE_XXX */
 | 
						|
                            active_rpt_state       :2,
 | 
						|
    /* reserved */
 | 
						|
                            reserved               :4;
 | 
						|
    /* the index of query */
 | 
						|
    uint16_t                qr_idx;
 | 
						|
    /* the count of nodes that need to be report */
 | 
						|
    uint16_t                rpt_cnt;
 | 
						|
    /* report timeout, unit is 1s */
 | 
						|
    uint16_t                rpt_timeout;
 | 
						|
} iot_sg_cco_active_qr_pm_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_nw_lock_param_t {
 | 
						|
    /* bcast network lock enable */
 | 
						|
    uint8_t                 bcast_enable            :1,
 | 
						|
    /* bcast network lock count */
 | 
						|
                            bcast_cnt               :4,
 | 
						|
    /* reserved */
 | 
						|
                            rsvd                    :3;
 | 
						|
    /* network lock bcast cmd type, see IOT_SG_CCO_BCAST_NW_LOCK_CMD_XXX */
 | 
						|
    uint8_t                 cmd_type;
 | 
						|
    /* network lock bcast time, unit is 1s */
 | 
						|
    uint8_t                 bcast_time;
 | 
						|
    /* bcast task sn */
 | 
						|
    uint16_t                bcast_sn;
 | 
						|
} iot_sg_cco_nw_lock_param_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_set_tsfm_addr_param {
 | 
						|
    /* bcast tsfm addr enable */
 | 
						|
    uint8_t                 bcast_enable            :1,
 | 
						|
    /* bcast tsfm addr count */
 | 
						|
                            bcast_cnt               :4,
 | 
						|
    /* reserved */
 | 
						|
                            rsvd                    :3;
 | 
						|
    /* tsfm addr bcast cmd type, see IOT_SG_CCO_BCAST_TSFM_ADDR_CMD_XXX */
 | 
						|
    uint8_t                 cmd_type;
 | 
						|
    /* tsfm addr bcast time, unit is 1s */
 | 
						|
    uint8_t                 bcast_time;
 | 
						|
    /* bcast task sn */
 | 
						|
    uint16_t                bcast_sn;
 | 
						|
    /* tsfm addr, big endian */
 | 
						|
    uint8_t                 tsfm_addr[IOT_MAC_ADDR_LEN];
 | 
						|
} iot_sg_cco_set_tsfm_addr_param_t;
 | 
						|
 | 
						|
/* define hw tsfm send control structure */
 | 
						|
typedef struct _iot_sg_cco_hw_tsfm_ctrl {
 | 
						|
    /* hw start transformer detect send commad mode, see
 | 
						|
     * IOT_SG_CCO_HW_TSFM_START_MODE_XXX.
 | 
						|
     */
 | 
						|
    uint16_t                mode        : 2,
 | 
						|
    /* send state IOT_SG_CCO_HW_TSFM_SEND_S_XXX */
 | 
						|
                            state       : 2,
 | 
						|
    /* retry cnt for each round send */
 | 
						|
                            retry_cnt   : 3,
 | 
						|
    /* flag to mark if a new round of HW tsfm signal needs to be sent */
 | 
						|
                            send_req    : 1,
 | 
						|
    /* reason for send done, see IOT_SG_CCO_HW_TSFM_SEND_DONE_XXX */
 | 
						|
                            send_done_reason   : 2,
 | 
						|
    /* flag to mark if a new round of HW tsfm signal allow send */
 | 
						|
                            send_en     : 1,
 | 
						|
    /* plc rising edge zc send tsfm flag, it's phase negative zc flag. */
 | 
						|
                            rising_send : 1,
 | 
						|
    /* reserved for further use */
 | 
						|
                            rsvd        : 4;
 | 
						|
    /* send rounds counter */
 | 
						|
    uint8_t                 round_cnt;
 | 
						|
    /* hard ware tsfm seq */
 | 
						|
    uint8_t                 hw_tsfm_seq;
 | 
						|
    /* broadcast transformer feature count, unit is 1s */
 | 
						|
    uint8_t                 hw_tsfm_cnt;
 | 
						|
    /* broadcast transformer feature round */
 | 
						|
    uint8_t                 hw_tsfm_round;
 | 
						|
} iot_sg_cco_hw_tsfm_ctrl_t;
 | 
						|
 | 
						|
/* define unicast send event report control structure */
 | 
						|
typedef struct _iot_sg_cco_node_evt_rpt_ctrl_param {
 | 
						|
    /* unicast send event report control state, 0 - disable, 1 - enable */
 | 
						|
    uint8_t                 enable          :1,
 | 
						|
    /* retry cnt */
 | 
						|
                            retry_cnt       :3,
 | 
						|
                            rsvd            :4;
 | 
						|
    /* total node count */
 | 
						|
    uint8_t                 total_cnt;
 | 
						|
    /* current node count */
 | 
						|
    uint16_t                cur_cnt;
 | 
						|
    /* event report control data */
 | 
						|
    iot_pkt_t               *pkt;
 | 
						|
} iot_sg_cco_node_evt_rpt_ctrl_param_t;
 | 
						|
 | 
						|
/* define cco acm structure */
 | 
						|
typedef struct _iot_sg_cco_acm {
 | 
						|
    /* acm command uart handle */
 | 
						|
    iot_uart_h              acm_cmd_uart_h;
 | 
						|
    /* cctt downlink sn */
 | 
						|
    uint8_t                 acm_cmd_sn;
 | 
						|
    /* used for report data to cctt */
 | 
						|
    uint8_t                 acm_cmd_local_sn;
 | 
						|
} iot_sg_cco_acm_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_bcast_param {
 | 
						|
    /* flag to mark if bcast task enable */
 | 
						|
    uint8_t                 enable          :1,
 | 
						|
    /* bcast interval time, unit is 1s */
 | 
						|
                            bcast_interval  :7;
 | 
						|
    /* bcast time, unit is 1s */
 | 
						|
    uint16_t                time;
 | 
						|
    /* consume time from start bcast, unit is 1s */
 | 
						|
    uint16_t                consume_time;
 | 
						|
} iot_sg_cco_bcast_param_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_average_read_time_param {
 | 
						|
    /* read meter count in 10 min */
 | 
						|
    uint16_t                read_cnt;
 | 
						|
    /* read meter count in 10 min, include timeout */
 | 
						|
    uint16_t                read_timeout_cnt;
 | 
						|
    /* total read time in 10 min, unit is 1ms */
 | 
						|
    uint64_t                total_read;
 | 
						|
    /* total read time in 10 min, include timeout, unit is 1ms */
 | 
						|
    uint64_t                total_read_timeout;
 | 
						|
} iot_sg_cco_average_read_time_param_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_clock_manager_param {
 | 
						|
    /* flag to mark if clock manager enable */
 | 
						|
    uint8_t                 enable          :1,
 | 
						|
    /* clock manager state, IOT_SG_CCO_CLOCK_MANAGER_STATE_XXX */
 | 
						|
                            state           :3,
 | 
						|
    /* reserved */
 | 
						|
                            reserved        :4;
 | 
						|
    /* station chip id info query index */
 | 
						|
    uint16_t                manage_idx;
 | 
						|
} iot_sg_cco_clock_manager_param_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_nli_abnormal_cfg {
 | 
						|
    /* configure state, see IOT_SG_CCO_NLI_CFG_STATE_XXX */
 | 
						|
    uint8_t                 status          :6,
 | 
						|
    /* flag to mark if enable abnormal report for neutralwire and livewire */
 | 
						|
                            enable          :1,
 | 
						|
    /* state change flag */
 | 
						|
                            change_flag     :1;
 | 
						|
    /* bcast configuretion cnt */
 | 
						|
    uint8_t                 bcast_cnt;
 | 
						|
    /* bcast interval time */
 | 
						|
    uint8_t                 bcast_interval;
 | 
						|
    /* configuretion index */
 | 
						|
    uint16_t                cfg_index;
 | 
						|
} iot_sg_cco_nli_abnormal_cfg_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_flash_g {
 | 
						|
    /* flash data */
 | 
						|
    uint8_t                 *flash_data;
 | 
						|
    /* flash mode */
 | 
						|
    uint8_t                 flash_mode;
 | 
						|
    /* function bitmap */
 | 
						|
    uint8_t                 bitmap[IOT_SG_CCO_FLASH_BM_LEN];
 | 
						|
    /* delay commit count */
 | 
						|
    uint8_t                 commit_count;
 | 
						|
} iot_sg_cco_flash_g_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_min_clct_task_param {
 | 
						|
    /* sta collect parameter configurate task priority v2.8 */
 | 
						|
    uint8_t                 conf_prio[IOT_SG_STA_CLCT_MAX_TASK_CNT];
 | 
						|
    /* collect configurate task node complete index */
 | 
						|
    uint8_t                 node_conf_complete_index;
 | 
						|
    /* sta collect parameter task priority v2.8 */
 | 
						|
    uint8_t                 task_prio[IOT_SG_STA_CLCT_MAX_TASK_CNT];
 | 
						|
    /* collect data task index */
 | 
						|
    uint16_t                task_index[IOT_SG_STA_CLCT_MAX_TASK_CNT];
 | 
						|
    /* min clct task dl buf count */
 | 
						|
    uint8_t                 dl_buf_cnt;
 | 
						|
    /* current period task complete bitmap */
 | 
						|
    uint8_t                 cur_per_task_bm[IOT_SG_STA_CLCT_MAX_TASK_CNT];
 | 
						|
    /* flag to mark if handle current minutes */
 | 
						|
    uint8_t                 min_handle;
 | 
						|
    /* current task id time */
 | 
						|
    iot_time_tm_t           cur_task_tm;
 | 
						|
} iot_sg_cco_min_clct_task_param_t;
 | 
						|
 | 
						|
/* smart grid cco role global descriptor */
 | 
						|
typedef struct _iot_sg_cco_global {
 | 
						|
    /* cco pib _handle */
 | 
						|
    iot_sg_cco_app_pib_t    pib;
 | 
						|
    /* common long buffer, used to cache some process data, it
 | 
						|
     * size see IOT_SG_CCO_MSG_LONG_BUF_SIZE.
 | 
						|
     */
 | 
						|
    uint8_t                 *long_buff;
 | 
						|
    /* event report filter, its size see
 | 
						|
     * IOT_SG_MAX_STA_COUNT * sizeof(iot_sg_cco_filter_evt_rpt).
 | 
						|
     */
 | 
						|
    iot_sg_cco_filter_evt_rpt   *evt_filter_buff;
 | 
						|
    /* buffer refreshing timer */
 | 
						|
    timer_id_t              buf_refresh_timer;
 | 
						|
    /* down link buffer data sending timer */
 | 
						|
    timer_id_t              dl_send_timer;
 | 
						|
    /* up link buffer data sending timer */
 | 
						|
    timer_id_t              ul_send_timer;
 | 
						|
    /* number of concurrent meter reading command on power line */
 | 
						|
    uint8_t                 mr_pkt_on_line;
 | 
						|
    /* number of concurrent meter reading command on power line for bcast */
 | 
						|
    uint8_t                 con_mr_pkt_on_line_for_bcast;
 | 
						|
    /* when dl buf_pool is full, this flag is set.
 | 
						|
     * dl f1h01 is regarded as an ack of ul f1h01.
 | 
						|
     * when dl buf_pool is empty and didn't receive any f1H01 from cctt within
 | 
						|
     * certain duration, this flag is cleared.
 | 
						|
     */
 | 
						|
    uint8_t                 f1h01_as_rsp_flag;
 | 
						|
    /* flag indicate if network formation is done */
 | 
						|
    uint8_t                 nw_fmt_done          : 1,
 | 
						|
    /* flag to mark if enable whist list in tsfm */
 | 
						|
                            enable_wl_in_tsfm    : 1,
 | 
						|
    /* wait for rtc synchronization after sta join */
 | 
						|
                            rtc_sync_is_wait     : 1,
 | 
						|
    /* enable query dev whether support minute collection */
 | 
						|
                            enable_minute_clct   : 1,
 | 
						|
    /* flag to mark if white list nodes joined completed */
 | 
						|
                            wl_join_done         : 1,
 | 
						|
    /* flag to mark if power event force report */
 | 
						|
                            power_evt_force      : 1,
 | 
						|
    /* flag to mark if all sta opposite phase event report done */
 | 
						|
                            opposite_rpt_done    : 1,
 | 
						|
    /* flag to mark if enable query node tsfm feature */
 | 
						|
                            query_tsfm_feature   : 1;
 | 
						|
    /* node joined count in whitelist */
 | 
						|
    uint16_t                wl_join_cnt;
 | 
						|
    /* hw tsfm send control structure */
 | 
						|
    iot_sg_cco_hw_tsfm_ctrl_t hw_tsfm_ctrl;
 | 
						|
 | 
						|
    /* timer for clearing f1h01_as_rsp_flag if dl buf_pool is empty
 | 
						|
     * and didn't receive any f1h01 from cctt. */
 | 
						|
    timer_id_t              clear_flag_timer;
 | 
						|
    /* common timer for cco
 | 
						|
     * - to query secondary node info
 | 
						|
     * - to check event report ack state
 | 
						|
     * - to check start sec node reg ack state
 | 
						|
     */
 | 
						|
    timer_id_t              cco_timer;
 | 
						|
    /* timer to check if network formation is done */
 | 
						|
    timer_id_t              nw_fmt_timer;
 | 
						|
    /* timer to check node join after network formation is done */
 | 
						|
    timer_id_t              node_join_timer;
 | 
						|
    /* timer to update data to pib */
 | 
						|
    timer_id_t              update_pib_timer;
 | 
						|
    /* timer used by cco for upgrading window */
 | 
						|
    timer_id_t              upgrade_win_timer;
 | 
						|
    /* timer used by cco for upgrading */
 | 
						|
    timer_id_t              upgrade_timer;
 | 
						|
    /* timer used by cco for canceling upgrading */
 | 
						|
    timer_id_t              cancel_timer;
 | 
						|
    /* timer for update whitelist to PIB */
 | 
						|
    timer_id_t              wl_timer;
 | 
						|
    /* timer for remove delay delete whitelist */
 | 
						|
    timer_id_t              rm_delay_del_wl_timer;
 | 
						|
    /* timer used by driver request */
 | 
						|
    timer_id_t              driver_timer1;
 | 
						|
    /* timer used by driver request */
 | 
						|
    timer_id_t              driver_timer2;
 | 
						|
    /* timer used by driver request */
 | 
						|
    timer_id_t              driver_timer3;
 | 
						|
    /* timer used by driver request */
 | 
						|
    timer_id_t              driver_timer4;
 | 
						|
    /* timer used by driver request */
 | 
						|
    timer_id_t              driver_timer5;
 | 
						|
    /* timer used by driver request */
 | 
						|
    timer_id_t              driver_timer6;
 | 
						|
    /* sec node register result count in the ul buffer */
 | 
						|
    uint16_t                sec_node_reg_ul_cnt;
 | 
						|
    /* used for cutting short sec node register */
 | 
						|
    uint16_t                sec_node_reg_timeout_cnt;
 | 
						|
    /* left time for secondary node registration, uint is 1s */
 | 
						|
    uint32_t                sec_node_reg_time_left;
 | 
						|
    /* total time for secondary node registration, uint is 1s */
 | 
						|
    uint32_t                sec_node_reg_time;
 | 
						|
    /* flag to mark if L/N reversed in Single-phase power meter or phase
 | 
						|
     * sequence reversed in Three-phase power meter.
 | 
						|
     */
 | 
						|
    uint8_t                 opposite_phase : 1,
 | 
						|
    /* physical phase of the device, bit0-2 means phaseA/B/C, set "1" to
 | 
						|
     * indicate which phase the device belongs to.
 | 
						|
     */
 | 
						|
                            phy_phase : 3,
 | 
						|
    /* phase type of three phase meter, see IOT_SG_CCO_PHASE_SEQ_XXX */
 | 
						|
                            phase_type : 3,
 | 
						|
    /* flag to mark if the 3phase device have the zc repeat phase */
 | 
						|
                            zc_repeat_3p : 1;
 | 
						|
    /* start command of secondary node registration retry enabled */
 | 
						|
    uint8_t                 sec_node_reg_s_retry_en     :1,
 | 
						|
    /* retry for event reporting control command is onging */
 | 
						|
                            evt_rpt_ctrl_retry_on       :2,
 | 
						|
    /* whether ul buf busy, 0 - not busy, 1 - busy */
 | 
						|
                            ul_buf_send_busy            :1,
 | 
						|
    /* transformer node report in process.
 | 
						|
     * 0 - not start reporting, 1 - node report in progress.
 | 
						|
     */
 | 
						|
                            tsfm_node_rpt_in_progress   :1,
 | 
						|
    /* flag to mark if don't deal with cctt data
 | 
						|
     * 0 - deal with cctt data, 1 - don't deal with cctt data.
 | 
						|
     */
 | 
						|
                            cctt_data_disable           :1,
 | 
						|
    /* flag to mark if tsfm done by timeout */
 | 
						|
                            tsfm_detect_done_by_timeout :1,
 | 
						|
    /* flag to mark if received all sta module id info for gw,
 | 
						|
     * flag to mark if received all sta property info for nw.
 | 
						|
     */
 | 
						|
                            all_sta_mod_id_recved       :1;
 | 
						|
    /* start command of secondary node registration retry interval counter */
 | 
						|
    uint8_t                 sec_node_reg_s_retry_tcnt;
 | 
						|
    /* start command of secondary node registration retry counter */
 | 
						|
    uint8_t                 sec_node_reg_s_retry_n;
 | 
						|
    /* last query sec node register index */
 | 
						|
    uint32_t                last_qr_sec_node_reg_index;
 | 
						|
    /* round of query sec node register */
 | 
						|
    uint32_t                qr_sec_node_reg_round;
 | 
						|
    /* event reporting control command retry interval counter */
 | 
						|
    uint8_t                 evt_rpt_ctrl_retry_tcnt;
 | 
						|
    /* event reporting control command retry counter */
 | 
						|
    uint8_t                 evt_rpt_ctrl_retry_n;
 | 
						|
    /* 1 - cmd from cctt was received. 0 - no cctt cmd received yet. */
 | 
						|
    uint8_t                 cctt_cmd_recved;
 | 
						|
    /* force restart tick count. Force CCo to restart network
 | 
						|
     * if this value reach certain value.
 | 
						|
     */
 | 
						|
    uint8_t                 force_restart_tick_cnt;
 | 
						|
    /* mapping from metro mac to sta mac, with pointer array */
 | 
						|
    iot_sg_cco_mac_map_h    mac_mapping;
 | 
						|
    /* secondary node registration state.
 | 
						|
     * non-zero means sec node reg started. */
 | 
						|
    uint8_t                 sec_node_reg_state;
 | 
						|
    /* router state: paused / resumed */
 | 
						|
    uint8_t                 rt_state;
 | 
						|
    /* flag indicate if white list is enabled on mac layer */
 | 
						|
    uint8_t                 whitelist_enabled;
 | 
						|
    /* local nid */
 | 
						|
    uint32_t                nid;
 | 
						|
    /* sg upgrade info */
 | 
						|
    iot_sg_cco_upgrade_t    upgrade_info;
 | 
						|
    /* down link buffer */
 | 
						|
    iot_buf_pool_t          dl_buf;
 | 
						|
    /* down link buffer */
 | 
						|
    iot_buf_pool_t          ul_buf;
 | 
						|
    /* concurrent count - reading pkt on power line */
 | 
						|
    uint8_t                 con_count;
 | 
						|
    /* meter reading command age limit for 13H_F1 */
 | 
						|
    uint16_t                mr_max_age_for_afn13;
 | 
						|
    /* meter reading command age limit for 14H_F1 */
 | 
						|
    uint16_t                mr_max_age_for_afn14;
 | 
						|
    /* meter reading command age limit for F1H_F1 */
 | 
						|
    uint16_t                mr_max_age_for_afnf1;
 | 
						|
    /* meter reading command age limit for F1H_F1 for cli */
 | 
						|
    uint16_t                mr_max_age_for_afnf1_cli;
 | 
						|
    /* concentrator meter reading command retry cnt */
 | 
						|
    uint16_t                mr_retry_cnt_cctt;
 | 
						|
    /* max concurrency count for con meter reading */
 | 
						|
    uint16_t                con_cnt_limit;
 | 
						|
    /* max concurrency count for con meter reading for cli */
 | 
						|
    uint16_t                con_cnt_limit_cli;
 | 
						|
    /* router meter reading command retry cnt */
 | 
						|
    uint16_t                mr_retry_cnt_router;
 | 
						|
    /* concurrently meter reading command retry cnt */
 | 
						|
    uint16_t                mr_retry_cnt_con;
 | 
						|
    /* cli interface for smart grid */
 | 
						|
    iot_cli_sg_interface_t  cli_sg_interface;
 | 
						|
    /* collector count in this network */
 | 
						|
    uint16_t                collector_cnt;
 | 
						|
    /* used for report data to cctt */
 | 
						|
    uint8_t                 local_sn;
 | 
						|
    /* 1 - router learn finish, 0 - unfinished */
 | 
						|
    uint8_t                 router_learn_flag           :1,
 | 
						|
    /* 1 - learning, 0 - meter reading */
 | 
						|
                            work_mode                   :1,
 | 
						|
    /* 1 - reg allowed, 0 - not allowed */
 | 
						|
                            sec_node_reg_allowed        :1,
 | 
						|
    /* 1 - transformer detect doing, 0 - transformer detect done */
 | 
						|
                            tsfm_detect_flag            :1,
 | 
						|
    /* transformer detect switch: 0 - disable, 1 - enable */
 | 
						|
                            tsfm_detect_enabled         :1,
 | 
						|
    /* whether lock the station. 0 - unlock, 1 - lock */
 | 
						|
                            tsfm_detect_lock_sta        :1,
 | 
						|
    /* if parameter area was reset.
 | 
						|
     * it's set to 1 when reset parameter happened.
 | 
						|
     * it's cleared when white list added and updated to flash.
 | 
						|
     */
 | 
						|
                            param_reset_flag            :1,
 | 
						|
    /* flag to mark if enable auto delete white list */
 | 
						|
                            auto_del_wl_flag            :1;
 | 
						|
    /* flag indicate if CCo shall restart network. */
 | 
						|
    uint8_t                 force_restart_nw            :1,
 | 
						|
    /* flag to mark if cco is in connectionless mode */
 | 
						|
                            conn_less                   :1,
 | 
						|
    /* flag to mark if plc manager is online */
 | 
						|
                            plc_mgr_online              :1,
 | 
						|
    /* flag to mark if controller is connected to cco */
 | 
						|
                            ctrl_proto_connected        :1,
 | 
						|
    /* whether query the station side transformer detect result,
 | 
						|
     * 0 - don't query, 1 - query
 | 
						|
     */
 | 
						|
                            tsfm_detect_qr_sta          :1,
 | 
						|
    /* transformer detect state, see IOT_SG_CCO_TSFM_DETECT_STATE_XXX */
 | 
						|
                            tsfm_detect_state           :3;
 | 
						|
    /* controller transformation sequence number */
 | 
						|
    uint8_t                 ctrl_proto_sn;
 | 
						|
    /* 0 - meter reading, 1- search meter, 2 - upgrade, 3 - reserved */
 | 
						|
    uint8_t                 work_type;
 | 
						|
    /* pending event count */
 | 
						|
    uint8_t                 router_evt_count;
 | 
						|
    /* counter used for transformer detect */
 | 
						|
    uint16_t                tsfm_detect_count;
 | 
						|
    /* total node count of the topo */
 | 
						|
    uint16_t                topo_count;
 | 
						|
    /* reject node old index in reject blacklist */
 | 
						|
    uint16_t                reject_node_old_idx;
 | 
						|
    /* max sec node count of one frame data for report to cctt */
 | 
						|
    uint8_t                 max_sec_count;
 | 
						|
    /* 0 - the cco is power off, 1 - the cco is power on */
 | 
						|
    uint8_t                 power_on;
 | 
						|
    /* timestamps of starting formating - unit 1s */
 | 
						|
    uint32_t                fmt_start_ts;
 | 
						|
    /* timestamps of ending formating - unit 1s */
 | 
						|
    uint32_t                fmt_done_ts;
 | 
						|
    /* network size */
 | 
						|
    uint16_t                nw_size;
 | 
						|
    /* station transformer detect result query index */
 | 
						|
    uint16_t                sta_tsfm_detect_ret_query_idx;
 | 
						|
    /* station side transformer detect timeout, unit is 1s */
 | 
						|
    uint32_t                sta_tsfm_detect_timeout;
 | 
						|
    /* station module id info query index for gw,
 | 
						|
     * station property info query index for nw.
 | 
						|
     */
 | 
						|
    uint16_t                sta_mod_id_query_idx;
 | 
						|
    /* station chip id info query index */
 | 
						|
    uint16_t                sta_chip_id_info_query_idx;
 | 
						|
    /* station network info query index */
 | 
						|
    uint16_t                sta_net_info_query_idx;
 | 
						|
    /* meter reading timeout count */
 | 
						|
    uint32_t                mr_timeout_cnt;
 | 
						|
    /* driver for current device */
 | 
						|
    iot_sg_cco_drv_t        *dev_drv;
 | 
						|
    /* driver for cli */
 | 
						|
    iot_sg_cco_drv_t        *cli_drv;
 | 
						|
    /* event receive count */
 | 
						|
    uint32_t                evt_rcv_cnt;
 | 
						|
    /* event report count */
 | 
						|
    uint32_t                evt_rpt_cnt;
 | 
						|
    /* event report success count */
 | 
						|
    uint32_t                evt_rpt_sus_cnt;
 | 
						|
    /* sec node query cnt */
 | 
						|
    uint32_t                sec_node_query_cnt;
 | 
						|
    /* sec node report count */
 | 
						|
    uint32_t                sec_node_rpt_cnt;
 | 
						|
    /* sec node report success count */
 | 
						|
    uint32_t                sec_node_rpt_sus_cnt;
 | 
						|
    /* node index in reporting progress */
 | 
						|
    uint16_t                tsfm_node_rpt_index;
 | 
						|
    /* if the pib's esp is IOT_SG_CCO_ESP_AUTO
 | 
						|
     * then this esp is driver detecting value,
 | 
						|
     * see IOT_SG_CCO_ESP_XXX
 | 
						|
     */
 | 
						|
    uint8_t                 real_esp;
 | 
						|
    /* task status, see IOT_SG_TASK_STATUS_XXX */
 | 
						|
    uint8_t                 task_status;
 | 
						|
    /* task enable type see - IOT_SG_CALLER_TYPE_XXX */
 | 
						|
    uint8_t                 task_enable_type;
 | 
						|
    /* refresh black list count */
 | 
						|
    uint8_t                 refresh_bl_cnt;
 | 
						|
    /* see IOT_SYS_RST_REASON_XXX */
 | 
						|
    uint8_t                 boot_reason;
 | 
						|
    /* router meter reading controller */
 | 
						|
    iot_sg_cco_rt_mr_ctrl_t rt_mr_ctrl;
 | 
						|
    /* predict meter reading controller */
 | 
						|
    iot_sg_cco_predict_mr_ctrl_t pre_mr_ctrl;
 | 
						|
    /* transformer feature data */
 | 
						|
    iot_sg_cco_tsfm_feature_t tsfm_feature;
 | 
						|
    /* transformer detect duration, unit is 1s */
 | 
						|
    uint32_t                tsfm_detect_timeout;
 | 
						|
    /* transformer detect bcast time, uint is 1s*/
 | 
						|
    uint32_t                tsfm_bcast_time;
 | 
						|
    /* transformer detect used time counter, unit is 1s */
 | 
						|
    uint32_t                tsfm_detect_used_time;
 | 
						|
    /* cache unsame vendor id */
 | 
						|
    uint32_t                sta_vendor[IOT_SG_CCO_UNSAME_VENDOR_MAX_COUNT];
 | 
						|
    /* socket to communicate with cctt. */
 | 
						|
    int32_t                 socket_h;
 | 
						|
    /* flag to mark if joined sta vendor id the same,
 | 
						|
     * 1 - is the same, 0 - otherwise
 | 
						|
     */
 | 
						|
    uint8_t                 vendor_id_same;
 | 
						|
    /* delay delete whitelist count */
 | 
						|
    uint16_t                delay_del_wl_cnt;
 | 
						|
    /* branch detect */
 | 
						|
    iot_sg_cco_branch_detect_t branch_detect;
 | 
						|
    /* pw tsfm */
 | 
						|
    iot_sg_cco_pw_tsfm_t    pw_tsfm;
 | 
						|
    /* number of intern sender command on power line */
 | 
						|
    uint8_t                 intern_pkt_on_line;
 | 
						|
    /* power down report flag, 1 - need to report power down event */
 | 
						|
    uint8_t                 power_down_rpt_flag     :1,
 | 
						|
    /* power up report flag, 1 - need to report power up event */
 | 
						|
                            power_up_rpt_flag       :1,
 | 
						|
    /* flag to mark if enabled sta collect parameter config */
 | 
						|
                            sta_clct_param_cfg_enabled:1,
 | 
						|
    /* flag to mark if received all sta chip id info */
 | 
						|
                            all_sta_chip_id_info_recved:1,
 | 
						|
    /* flag to mark if received all sta network info */
 | 
						|
                            all_sta_net_info_recved :1,
 | 
						|
    /* flag to mark if need to report join info to cctt */
 | 
						|
                            sta_join_rpt_flag       :1,
 | 
						|
    /* 0 - check 645/698 pkg for mr dest mac, others - doesn't check */
 | 
						|
                            trans_mode              :1,
 | 
						|
    /* recorded power down infomation flag, 1 - need record */
 | 
						|
                            pd_info_record_flag     :1;
 | 
						|
    /* loop timeout interval, unit is 1s. */
 | 
						|
    uint16_t                loop2_timeout;
 | 
						|
    /* loop timeout interval, unit is 1s. */
 | 
						|
    uint8_t                 loop1_timeout;
 | 
						|
    /* sta join check count, unit is 30min */
 | 
						|
    uint8_t                 join_check_time_cnt     :6,
 | 
						|
    /* sta join check enable valid for hunan */
 | 
						|
                            join_check_valid        :1,
 | 
						|
    /* sta join check enable for hunan */
 | 
						|
                            sta_join_enable         :1;
 | 
						|
    /* sta join check send count in half an hour */
 | 
						|
    uint8_t                 sta_join_send_cnt       :4,
 | 
						|
    /* power down event valid time, unit is 1s */
 | 
						|
                            pd_valid_time           :4;
 | 
						|
    /* power down node collect time */
 | 
						|
    uint8_t                 power_down_clct_cnt;
 | 
						|
    /* power up node collect time */
 | 
						|
    uint8_t                 power_up_clct_cnt;
 | 
						|
    /* power down node bitmap */
 | 
						|
    uint8_t                 power_down_bm[IOT_SG_CCO_POWER_EVENT_BM_SIZE];
 | 
						|
    /* power up node bitmap */
 | 
						|
    uint8_t                 power_up_bm[IOT_SG_CCO_POWER_EVENT_BM_SIZE];
 | 
						|
    /* network route period, unit is 1s */
 | 
						|
    uint16_t                rt_period;
 | 
						|
    /* send search list time count */
 | 
						|
    uint8_t                 send_search_list_timeout;
 | 
						|
    /* query transformer detect result interval, unit is 1s */
 | 
						|
    uint8_t                 qr_tsfm_detect_ret_interval;
 | 
						|
    /* white list index for searching list */
 | 
						|
    uint16_t                wl_idx_for_search_list;
 | 
						|
    /* collector mac address login count */
 | 
						|
    uint16_t                clct_mac_login_cnt;
 | 
						|
    /* sta collect parameter config index */
 | 
						|
    uint16_t                sta_clct_param_cfg_idx;
 | 
						|
    /* the index of query dev whether support minute collection */
 | 
						|
    uint16_t                minute_clct_qr_idx;
 | 
						|
    /* send search meter max count */
 | 
						|
    uint16_t                send_search_max_cnt;
 | 
						|
    /* emergency task count */
 | 
						|
    uint16_t                emergency_task_cnt;
 | 
						|
    /* sta opposite phase event report index */
 | 
						|
    uint16_t                opposite_rpt_idx;
 | 
						|
    /* simple pair passcode value. Only same passcode CCO and STA can be
 | 
						|
     * associated, little endian.
 | 
						|
     */
 | 
						|
    uint16_t                passcode;
 | 
						|
    /* flag to mark if enable bcast correct time before networking done */
 | 
						|
    uint16_t                corr_time_enable        :1,
 | 
						|
    /* bcast correct time interval, unit is 1s */
 | 
						|
                            corr_time_interval      :9,
 | 
						|
    /* cctt node call count */
 | 
						|
                            node_call_cnt           :2,
 | 
						|
    /* flag of sec node regist need auto stop, 1 - need, 0 - not need */
 | 
						|
                            sec_node_reg_need_auto_stop:1,
 | 
						|
    /* meter reading only, no other works */
 | 
						|
                            mr_only                 :1,
 | 
						|
    /* force link type */
 | 
						|
                            force_link              :2;
 | 
						|
    /* round of join network time */
 | 
						|
    uint8_t                 join_round;
 | 
						|
    /* hplc link load, value: 0 - 100 */
 | 
						|
    uint8_t                 link_load;
 | 
						|
    /* network jolt interval count */
 | 
						|
    uint16_t                net_jolt_cnt            :5,
 | 
						|
    /* network jolt join node report count */
 | 
						|
                            net_jolt_rpt_cnt        :10,
 | 
						|
    /* network jolt valid */
 | 
						|
                            net_jolt_valid          :1;
 | 
						|
    /* network jolt calm round */
 | 
						|
    uint8_t                 net_jolt_calm_round;
 | 
						|
    /* link load limit */
 | 
						|
    uint8_t                 link_load_limit;
 | 
						|
    /* edge computing set index */
 | 
						|
    uint16_t                edge_computing_set_index    :11,
 | 
						|
    /* all sta edge computing set complete */
 | 
						|
                            all_sta_edge_complete       :1,
 | 
						|
    /* connless link type, see IOT_PLC_TX_LINK_TYPE_XXX */
 | 
						|
                            connless_link_type          :2,
 | 
						|
    /* reserved for future */
 | 
						|
                            rsvd                        :2;
 | 
						|
    /* edge computing task id */
 | 
						|
    uint8_t                 edge_computing_task;
 | 
						|
    /* power down event report count */
 | 
						|
    uint32_t                power_down_evt_cnt;
 | 
						|
    /* power up event report count */
 | 
						|
    uint32_t                power_up_evt_cnt;
 | 
						|
    /* last bcast timestamp for all nodes, uint is 1ms */
 | 
						|
    uint32_t                last_bcast_ts_all;
 | 
						|
    /* uart bps */
 | 
						|
    uint32_t                uart_bps;
 | 
						|
    /* low power meter parameter */
 | 
						|
    iot_sg_cco_lp_meter_param_t lp_meter;
 | 
						|
    /* score parameter */
 | 
						|
    iot_sg_cco_set_score_parameter_t score_param;
 | 
						|
    /* collect task parameter */
 | 
						|
    iot_sg_cco_clct_task_param_t clct_task;
 | 
						|
    /* lock time parameter */
 | 
						|
    iot_sg_cco_lock_time_param_t lock_time;
 | 
						|
    /* active query pm parameter */
 | 
						|
    iot_sg_cco_active_qr_pm_t    active_qr_pm;
 | 
						|
    /* bcast network lock command */
 | 
						|
    iot_sg_cco_nw_lock_param_t   nw_lock;
 | 
						|
    /* bcast tsfm addr parameter */
 | 
						|
    iot_sg_cco_set_tsfm_addr_param_t set_tsfm_addr;
 | 
						|
    /* bcast task parmeter */
 | 
						|
    iot_sg_cco_bcast_param_t     bcast_param;
 | 
						|
    /* unicast node event report info */
 | 
						|
    iot_sg_cco_node_evt_rpt_ctrl_param_t node_evt_ctrl;
 | 
						|
    /* average cost time parmeter */
 | 
						|
    iot_sg_cco_average_read_time_param_t aver_time;
 | 
						|
    /* clock manager parmeter */
 | 
						|
    iot_sg_cco_clock_manager_param_t clock_manager;
 | 
						|
    /* abnormal electric current configuration */
 | 
						|
    iot_sg_cco_nli_abnormal_cfg_t    nli_cfg;
 | 
						|
    /* new cco */
 | 
						|
#if IOT_SMART_GRID_CCO_ACM_ENABLE
 | 
						|
    iot_sg_cco_acm_t cco_acm;
 | 
						|
#endif
 | 
						|
    /* flash parameter */
 | 
						|
    iot_sg_cco_flash_g_t flash;
 | 
						|
    /* jolt node bitmap */
 | 
						|
    uint8_t              jolt_bitmap[IOT_SG_CCO_JOLT_BITMAP_CNT];
 | 
						|
    /* sta collect parameter task */
 | 
						|
    iot_sg_cco_min_clct_task_param_t    clct_task_param;
 | 
						|
} iot_sg_cco_global_t;
 | 
						|
 | 
						|
/* list entry within STA entry containing meter index*/
 | 
						|
typedef struct _iot_sg_meter_idx_t {
 | 
						|
    iot_list_head_t     link;
 | 
						|
    uint16_t            meter_index;    /* index of the meter */
 | 
						|
}iot_sg_meter_idx_t;
 | 
						|
 | 
						|
typedef struct _iot_ihash_entry {
 | 
						|
    iot_addr_hash_entry_t   mac_entry;
 | 
						|
    uint16_t                index;
 | 
						|
}iot_ihash_entry_t;
 | 
						|
 | 
						|
typedef struct _iot_ihash_meter_entry {
 | 
						|
    iot_meter_addr_hash_entry_t   meter_entry;
 | 
						|
    uint16_t                index;
 | 
						|
} iot_ihash_meter_entry_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_lp_meter_sta_param {
 | 
						|
    /* flag to mark if low power dev type is available */
 | 
						|
    uint8_t             dev_type_valid              :1,
 | 
						|
    /* query lp dev type count */
 | 
						|
                        dev_type_qr_cnt             :7;
 | 
						|
    /* flag to mark if low power meter rssi info is available */
 | 
						|
    uint8_t             rssi_valid                  :1,
 | 
						|
    /* query low power meter rssi info count */
 | 
						|
                        rssi_qr_cnt                 :6,
 | 
						|
    /* 0 - without low power meter, 1- with low power meter */
 | 
						|
                        with_lp_meter               :1;
 | 
						|
    /* flag to mark if low power meter info is available */
 | 
						|
    uint8_t             info_valid                  :1,
 | 
						|
    /* query low power meter same info count */
 | 
						|
                        qr_same_cnt                 :7;
 | 
						|
    /* the seq number of the send query low power meter command */
 | 
						|
    uint8_t             qr_sn;
 | 
						|
    /* query low power meter info start sequence */
 | 
						|
    uint8_t             start_seq;
 | 
						|
    /* query low power meter rssi info start sequence */
 | 
						|
    uint16_t            rssi_start_seq;
 | 
						|
} iot_sg_cco_lp_meter_sta_param_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_tsfm_sta_param_pw {
 | 
						|
    /* transformer detect packet query sn, see IOT_SG_CCO_TSFM_PKT_QR_SN_XXX */
 | 
						|
    uint8_t             tsfm_pkt_qr_sn              :5,
 | 
						|
    /* reserved */
 | 
						|
                        reserved                    :3;
 | 
						|
} iot_sg_cco_tsfm_sta_param_pw_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_sta_info_entry {
 | 
						|
    /* hash table entry with meter mac address as key */
 | 
						|
    iot_ihash_entry_t   entry;
 | 
						|
    /* a list with all meter attached to the sta */
 | 
						|
    iot_list_head_t     meter_list;
 | 
						|
    /* the seq number of the last send query sec node registration command */
 | 
						|
    uint32_t            sec_node_qr_sn;
 | 
						|
    /* query sec node registration interval counter */
 | 
						|
    uint32_t            sec_node_qr_timeout_n : 16,
 | 
						|
    /* query sec node registration counter */
 | 
						|
                        sec_node_qr_count     : 8,
 | 
						|
    /* query count for this STA. 0 means don't query the STA.  */
 | 
						|
                        ver_qr_cnt            : 8;
 | 
						|
    /* the current state of sec node reg, see SEC_NODE_REG_STATE_XXXX */
 | 
						|
    uint8_t             sec_node_reg_state;
 | 
						|
    /* type of dev the STA module attached, see IOT_PLC_DEV_TYPE_XXX */
 | 
						|
    uint8_t             dev_type;
 | 
						|
    /* max concurrent meter reading count */
 | 
						|
    uint8_t             send_count;
 | 
						|
    /* physical phase of the station */
 | 
						|
    uint8_t             phy_phase1     : 2,
 | 
						|
                        phy_phase2     : 2,
 | 
						|
                        phy_phase3     : 2,
 | 
						|
    /* flag to mark if L/N reversed in Three-phase power meter */
 | 
						|
                        opposite_3p    : 1,
 | 
						|
    /* the node base info query is complete flag */
 | 
						|
                        base_info_complete_flag  :1;
 | 
						|
    /* flag to mark if app phase info valid */
 | 
						|
    uint8_t             phase_info_valid : 1,
 | 
						|
    /* connection position of N-wire if L/N of three-phase meter is reversed.
 | 
						|
     * see IOT_PLC_PHASE_XXX.
 | 
						|
     * Note: the position refers to the physical phase terminal.
 | 
						|
     */
 | 
						|
                        opposite_3p_pos : 2,
 | 
						|
    /* flag to mark if have super capacitance */
 | 
						|
                        super_cap       : 1,
 | 
						|
    /* flag to mark if could fix position */
 | 
						|
                        fix_position    : 1,
 | 
						|
    /* flag to mark if node need to report join info to cctt */
 | 
						|
                        join_rpt_flag   : 1,
 | 
						|
    /* flag to mark if pm score info is available */
 | 
						|
                        pm_score_valid  : 1,
 | 
						|
    /* 1 - in offline state */
 | 
						|
                        is_offline_state: 1;
 | 
						|
    /* logical phase of the station */
 | 
						|
    uint8_t             logical_phase1 : 2,
 | 
						|
                        logical_phase2 : 2,
 | 
						|
                        logical_phase3 : 2,
 | 
						|
    /* 0 - power off, 1 - power on.
 | 
						|
     * Accuracy is not high, so not recommended for use.
 | 
						|
     */
 | 
						|
                        power_on       : 1,
 | 
						|
    /* 1 if STA's version was updated, 0 if not. */
 | 
						|
                        ver_updated    : 1;
 | 
						|
    /* CRC of STA's firmware */
 | 
						|
    uint32_t            sta_crc;
 | 
						|
    /* 2 bytes for vendor id */
 | 
						|
    uint16_t            vendor_id;
 | 
						|
    /* send search meter command count */
 | 
						|
    uint16_t            send_search_cnt     :13,
 | 
						|
    /* mac address type. see IOT_PLC_MAC_ADDR_TYPE_XXX */
 | 
						|
                        addr_type           :2,
 | 
						|
    /* STA upgrade bitmap need reverse flag */
 | 
						|
                        reverse             :1;
 | 
						|
    /* percentage  of the upgrade progress */
 | 
						|
    uint8_t             percent_upgrade;
 | 
						|
    /* if upgrading start ack received from this STA. */
 | 
						|
    uint8_t             upgrade_started     :1,
 | 
						|
    /* if CCo received its query status rsp. */
 | 
						|
                        query_rsp_recved    :1,
 | 
						|
    /* if STA received the 1st data block. */
 | 
						|
                        header_recved       :1,
 | 
						|
    /* if STA received all data block */
 | 
						|
                        recv_done           :1,
 | 
						|
    /* if STA received execute command */
 | 
						|
                        exe_recved          :1,
 | 
						|
    /* STA join the network when upgrading is half done. */
 | 
						|
                        late                :1,
 | 
						|
    /* shall this STA be skip for upgrading */
 | 
						|
                        skip                :1,
 | 
						|
    /* STA renew sw version when upgrading is done. */
 | 
						|
                        renew_sw            :1;
 | 
						|
    /* last boot up reason of this STA */
 | 
						|
    uint8_t             boot_reason;
 | 
						|
    /* vendor id query count */
 | 
						|
    uint8_t             vendor_id_qr_cnt;
 | 
						|
    /* station detect result, see IOT_SG_CCO_STA_TSFM_DETECT_RET_XXX */
 | 
						|
    uint16_t            sta_tsfm_detect_ret         :4,
 | 
						|
    /* station transformer detect status, 0 - doing, 1 - done */
 | 
						|
                        sta_tsfm_detect_done        :1,
 | 
						|
    /* query module id count */
 | 
						|
                        mod_id_qr_cnt               :6,
 | 
						|
    /* reserved */
 | 
						|
                        rsvd1                       :5;
 | 
						|
    /* flag to mark if sta chip id info is available */
 | 
						|
    uint8_t             chip_id_info_valid          :1,
 | 
						|
    /* query chip id info count */
 | 
						|
                        chip_id_qr_cnt              :7;
 | 
						|
    /* uplink signal quality */
 | 
						|
    uint8_t             ul_quality                  :4,
 | 
						|
    /* downlink signal quality */
 | 
						|
                        dl_quality                  :4;
 | 
						|
    /* pw transformer detect sta parameter */
 | 
						|
    iot_sg_cco_tsfm_sta_param_pw_t  tsfm_param_pw;
 | 
						|
#if IOT_SMART_GRID_LP_METER_ENABLE
 | 
						|
    /* low power meter parameter */
 | 
						|
    iot_sg_cco_lp_meter_sta_param_t lp_meter;
 | 
						|
#endif
 | 
						|
    /* chip id information of the node */
 | 
						|
    iot_plc_chip_id_t   chip_id;
 | 
						|
#if IOT_SMART_GRID_NET_INFO_ENABLE
 | 
						|
    /* flag to mark if sta network info is available */
 | 
						|
    uint8_t             net_info_valid              :1,
 | 
						|
    /* query network info count */
 | 
						|
                        net_qr_cnt                  :7;
 | 
						|
    /* network info of the node */
 | 
						|
    iot_sg_cco_net_info_t net_info;
 | 
						|
#endif
 | 
						|
    /* module id information, little - endian, for gw,
 | 
						|
     * module mac addr, big-endian, for nw.
 | 
						|
     */
 | 
						|
    uint8_t             module_id[IOT_SG_CCO_MOD_ID_LEN];
 | 
						|
    /* flag to mark if delete module collect task is available */
 | 
						|
    uint8_t             init_clct_task_valid       :1,
 | 
						|
    /* count of delete module to init collection task  */
 | 
						|
                        init_clct_task_cnt         :7;
 | 
						|
    /* flag to mark if sta lock time info is available */
 | 
						|
    uint8_t             lock_time_info_valid       :1,
 | 
						|
    /* query lock time info count */
 | 
						|
                        lock_time_qr_cnt           :7;
 | 
						|
    /* flag to mark if minute collection is available */
 | 
						|
    uint8_t             minute_clct_valid          :1,
 | 
						|
    /* query minute collection info count */
 | 
						|
                        minute_clct_qr_cnt         :7;
 | 
						|
#if IOT_SMART_GRID_ACTIVE_QR_ENABLE
 | 
						|
    /* active query power meter state, see IOT_SG_CCO_QR_PM_STATE_XXX */
 | 
						|
    uint8_t             active_qr_state            :2,
 | 
						|
    /* active query pm function query count */
 | 
						|
                        active_qr_cnt              :6;
 | 
						|
#endif
 | 
						|
#if IOT_SMART_GRID_CLCOCK_MANAGE_ENABLE
 | 
						|
    /* cctt set sta auto correction time flag */
 | 
						|
    uint8_t             auto_corr_switch           :1,
 | 
						|
    /* when the cctt cmd is received, mark this value as valid */
 | 
						|
                        auto_corr_valid            :1,
 | 
						|
    /* sta auto correct time set done */
 | 
						|
                        auto_corr_done             :1,
 | 
						|
    /* auto correct time set count */
 | 
						|
                        auto_corr_set_cnt          :4,
 | 
						|
    /* sta report auto correction time flag */
 | 
						|
                        auto_corr_switch_rpt       :1;
 | 
						|
    /* when the cctt cmd is received, mark this value as valid */
 | 
						|
    uint8_t             threshold_valid            :1,
 | 
						|
    /* sta clock manage threshold time set done */
 | 
						|
                        threshold_done             :1,
 | 
						|
    /* clock manage threshold set count */
 | 
						|
                        threshold_set_cnt          :4,
 | 
						|
    /* flag to mark if sta clock manage done */
 | 
						|
                        clock_manage_done          :1,
 | 
						|
    /* flag to mark if query sta clock manage infomation done */
 | 
						|
                        clock_info_qr_done         :1;
 | 
						|
    /* query clock manage infomation count */
 | 
						|
    uint8_t             clock_info_qr_cnt          :4,
 | 
						|
    /* reserved */
 | 
						|
                        rsvd2                      :4;
 | 
						|
    /* cctt set clock manager threshold, unit is 1min */
 | 
						|
    uint8_t             corr_threshold;
 | 
						|
    /* sta report clock manager threshold, unit is 1min */
 | 
						|
    uint8_t             corr_threshold_rpt;
 | 
						|
#endif
 | 
						|
#if IOT_SMART_GRID_NLI_CFG_ENABLE
 | 
						|
    /* unicast configure cnt */
 | 
						|
    uint8_t             nli_cfg_cnt                :4,
 | 
						|
    /* configure state, see IOT_SG_CCO_NLI_CFG_STA_XXX */
 | 
						|
                        nli_cfg_state              :4;
 | 
						|
#endif
 | 
						|
    /* external software version */
 | 
						|
    uint16_t            sw_version;
 | 
						|
    /* internal software version */
 | 
						|
    uint32_t            build_sw_ver;
 | 
						|
    /* boot version */
 | 
						|
    uint8_t             boot_ver;
 | 
						|
    /* level, warning the value may be old, is unfaithful */
 | 
						|
    uint8_t             level                      :4,
 | 
						|
    /* flag to mark if dev support minute collection */
 | 
						|
                        minute_clct                :1,
 | 
						|
    /* the type of power meter under the station,
 | 
						|
     * 0 is single phase meter, 1 is three phase meter
 | 
						|
     */
 | 
						|
                        pm_type                    :1,
 | 
						|
    /* flag to mark if sta report opposite phase event */
 | 
						|
                        opposite_evt_rpt           :1,
 | 
						|
    /* flag to mark if query sta edge info */
 | 
						|
                        query_edge                 :1;
 | 
						|
    /* software build time */
 | 
						|
    uint16_t            build_time_y               :7,
 | 
						|
                        build_time_m               :4,
 | 
						|
                        build_time_d               :5;
 | 
						|
    /* chip code */
 | 
						|
    uint16_t            chip_code;
 | 
						|
#if IOT_SMART_GRID_BASE_INFO_ENBALE
 | 
						|
    /* software module version */
 | 
						|
    uint16_t            sw_mod_version;
 | 
						|
    /* release date of sw module version */
 | 
						|
    uint8_t             sw_mod_date[IOT_SG_CCO_VERSION_DATE_LEN];
 | 
						|
    /* software chip version */
 | 
						|
    uint16_t            sw_chip_version;
 | 
						|
    /* release date of sw chip version */
 | 
						|
    uint8_t             sw_chip_date[IOT_SG_CCO_VERSION_DATE_LEN];
 | 
						|
    /* hardware module version */
 | 
						|
    uint16_t            hw_mod_version;
 | 
						|
    /* release date of hw module version */
 | 
						|
    uint8_t             hw_mod_date[IOT_SG_CCO_VERSION_DATE_LEN];
 | 
						|
    /* hardware chip version */
 | 
						|
    uint16_t            hw_chip_version;
 | 
						|
    /* release date of hw chip version */
 | 
						|
    uint8_t             hw_chip_date[IOT_SG_CCO_VERSION_DATE_LEN];
 | 
						|
    /* app version */
 | 
						|
    uint16_t            app_version;
 | 
						|
#endif
 | 
						|
#if IOT_SMART_GRID_EDGE_COMPUTING_ENABLE
 | 
						|
    /* edge computing set count */
 | 
						|
    uint8_t             edge_computing_set_cnt      :7,
 | 
						|
    /* edge computing set complete flag */
 | 
						|
                        edge_computing_set_complete :1;
 | 
						|
#endif
 | 
						|
    /* device mac address from zhejiang search pm result event, little-endian.
 | 
						|
     * if the device type is collector, the mac is the collector mac address.
 | 
						|
     */
 | 
						|
    uint8_t             dev_addr[IOT_MAC_ADDR_LEN];
 | 
						|
    /* bitmap for base info case */
 | 
						|
    uint32_t            base_info_bm;
 | 
						|
} iot_sg_sta_entry_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_score_info {
 | 
						|
    /* assessment score */
 | 
						|
    uint8_t    score;
 | 
						|
    /* trouble data item, 4 byte to 32 bit.
 | 
						|
     * each bit corresponding to trouble data item.
 | 
						|
     * example: D0 is trouble, set bit0 is 1.
 | 
						|
     */
 | 
						|
    uint32_t   err_bm;
 | 
						|
} iot_sg_score_info_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_cco_lp_meter_pm_param {
 | 
						|
    /* flag to mark if config low power meter is available */
 | 
						|
    uint8_t             cfg_valid             :1,
 | 
						|
    /* config low power meter count */
 | 
						|
                        cfg_cnt               :7;
 | 
						|
    /* low power meter rssi */
 | 
						|
    uint8_t             rssi;
 | 
						|
    /* low power meter mac address high byte */
 | 
						|
    uint8_t             high_addr;
 | 
						|
} iot_sg_cco_lp_meter_pm_param_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_meter_info_entry {
 | 
						|
    /* hash table entry with meter mac address as key */
 | 
						|
    iot_ihash_entry_t   entry;
 | 
						|
    /* proto type the meter supported */
 | 
						|
    uint8_t             proto_type;
 | 
						|
    /* 0: the node don't active register, 1: the node active register */
 | 
						|
    uint8_t             active_reg_flag       :1,
 | 
						|
    /* 0: the last event report sn is invalid,
 | 
						|
     * 1: the last event report sn is valid.
 | 
						|
     */
 | 
						|
                        last_evt_rpt_sn_valid :1,
 | 
						|
    /* 0 - power off, 1 - power on */
 | 
						|
                        power_on              :1,
 | 
						|
    /* flag to mark if score info is available */
 | 
						|
                        score_info_valid      :1,
 | 
						|
    /* flag to mark if node is active query pm */
 | 
						|
                        active_qr_flag        :1,
 | 
						|
    /* flag to mark if search result event was reported */
 | 
						|
                        search_rpt_flag       :1,
 | 
						|
    /* flag to mark if connectionless node report tsfm detect resutl */
 | 
						|
                        conn_tsfm_ret_rpt     :1,
 | 
						|
    /* 1 - module meter, 0 - collector meter */
 | 
						|
                        module_meter          :1;
 | 
						|
    /* last event report sn */
 | 
						|
    uint16_t            last_event_rpt_sn;
 | 
						|
#if IOT_SMART_GRID_LP_METER_ENABLE
 | 
						|
    /* low power meter parameter */
 | 
						|
    iot_sg_cco_lp_meter_pm_param_t lp_meter;
 | 
						|
#endif
 | 
						|
#if IOT_SMART_GRID_PM_CORE_ENABLE
 | 
						|
    /* pm score information */
 | 
						|
    iot_sg_score_info_t score_info;
 | 
						|
#endif
 | 
						|
    /* pointer to the corresponding STA info */
 | 
						|
    iot_sg_sta_entry_t* sta_info;
 | 
						|
    /* phase that device is connected to.
 | 
						|
     *  bit0 set to 1 means device is connected to phase A.
 | 
						|
     *  bit1 set to 1 means device is connected to phase B.
 | 
						|
     *  bit2 set to 1 means device is connected to phase C.
 | 
						|
     */
 | 
						|
    uint8_t             phase                      :3,
 | 
						|
    /* reserved */
 | 
						|
                        rsvd1                      :5;
 | 
						|
    /* device type, see IOT_PLC_DEV_TYPE_XXX */
 | 
						|
    uint8_t             dev_type;
 | 
						|
    /* transformer status, see IOT_SG_CCO_PM_TO_TSFM_XXX */
 | 
						|
    uint8_t             tsfm_status                :4,
 | 
						|
    /* phase type of three phase meter, see IOT_SG_CCO_PHASE_SEQ_XXX */
 | 
						|
                        phase_type                 :3,
 | 
						|
    /* flag to mark if L/N reversed in Single-phase power meter or phase
 | 
						|
     * sequence reversed in Three-phase power meter.
 | 
						|
     */
 | 
						|
                        opposite_phase             :1;
 | 
						|
    /* tsfm address info, big endian */
 | 
						|
    uint8_t             tsfm_addr[IOT_MAC_ADDR_LEN];
 | 
						|
} iot_sg_pm_entry_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_meter_mapping_entry {
 | 
						|
    /* hash table entry with meter address as key */
 | 
						|
    iot_ihash_meter_entry_t   entry;
 | 
						|
    /* node mac address : small endian */
 | 
						|
    uint8_t             mac[IOT_MAC_ADDR_LEN];
 | 
						|
} iot_sg_meter_mapping_entry_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_clct_task_x4_info {
 | 
						|
    /* flag to mark if the node complete collect task bcast divide */
 | 
						|
    uint8_t             clct_task_bcast_ack :1,
 | 
						|
    /* bcast collect task send count */
 | 
						|
                        clct_task_send_cnt  :7;
 | 
						|
    /* collect task sn */
 | 
						|
    uint16_t            app_sn;
 | 
						|
} iot_sg_clct_task_x4_info_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_clct_task_v28_info {
 | 
						|
    /* sta collect parameter task id send bitmap */
 | 
						|
    uint8_t                     clct_task_send_bm;
 | 
						|
    /* sta collect parameter task send common count */
 | 
						|
    uint8_t                     clct_task_send_cnt;
 | 
						|
    /* flag to mark if the node recv collect data in the period */
 | 
						|
    uint8_t                     clct_data_recv  : 1,
 | 
						|
    /* sta collect data query count */
 | 
						|
                                data_qry_cnt    : 3,
 | 
						|
    /*  flag to mark if task is configurated */
 | 
						|
                                task_buf_flag   : 1,
 | 
						|
    /* reserved for future */
 | 
						|
                                rsvd            : 3;
 | 
						|
} iot_sg_clct_task_v28_info_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_wl_entry {
 | 
						|
    /* hash table entry with meter mac address as key */
 | 
						|
    iot_ihash_entry_t   entry;
 | 
						|
    /* proto type the meter supported */
 | 
						|
    uint8_t             proto_type;
 | 
						|
    /* meter status, see IOT_SG_CCO_RT_MR_STATE_XXX */
 | 
						|
    uint8_t             route_mr_state      :2,
 | 
						|
    /* delay delete */
 | 
						|
                        delay_del           :1,
 | 
						|
    /* sta module configuration state, 0 fail, 1 success */
 | 
						|
                        sta_mod_cfg_state   :1,
 | 
						|
    /* 1 - in sta collect parameter config progress, 0 - not */
 | 
						|
                        sta_mod_cfg_flag    :1,
 | 
						|
    /* sta last leave reason depending on leave awareness and power up report,
 | 
						|
     * 0 - power off, 1- channel quality change.
 | 
						|
     */
 | 
						|
                        sta_leave_reason    :1,
 | 
						|
    /* reserved for future */
 | 
						|
                        rsvd                :2;
 | 
						|
    /* sta collect parameter task id v2.8 */
 | 
						|
    uint8_t             clct_task_id;
 | 
						|
    union {
 | 
						|
        uint8_t diff_max[IOT_SG_CCO_WL_DIFF_DATA_MAX_LEN];
 | 
						|
        iot_sg_clct_task_x4_info_t          clct_task_x4;
 | 
						|
        iot_sg_clct_task_v28_info_t         task_v28;
 | 
						|
    } diff;
 | 
						|
    /* time stamp of station joined, uint is 1s */
 | 
						|
    uint32_t            join_ts;
 | 
						|
    /* time stamp of station left, uint is 1s */
 | 
						|
    uint32_t            leave_ts;
 | 
						|
    /* time stamp to remove the entry from black list, unit is 1s */
 | 
						|
    uint32_t            rm_ts;
 | 
						|
    /* last bcast time, uint is 1ms */
 | 
						|
    uint32_t            last_bcast_ts;
 | 
						|
} iot_sg_wl_entry_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_wlii_entry {
 | 
						|
    /* hash table entry with meter mac address as key */
 | 
						|
    iot_ihash_entry_t   entry;
 | 
						|
    /* proto type the meter supported, see PROTO_TYPE_XXX */
 | 
						|
    uint8_t             proto_type;
 | 
						|
    /* meter status, see IOT_SG_CCO_RT_MR_STATE_XXX */
 | 
						|
    uint8_t             route_mr_state      :2,
 | 
						|
    /* communication object type, see PROTO_3762_FJ_OBJ_XXX */
 | 
						|
                        obj_type            :4,
 | 
						|
    /* repeat request meter counter */
 | 
						|
                        rt_retry_count      :2;
 | 
						|
} iot_sg_wlii_entry_t;
 | 
						|
 | 
						|
typedef struct _iot_sg_bl_entry {
 | 
						|
    /* hash table entry with meter mac address as key */
 | 
						|
    iot_ihash_entry_t   entry;
 | 
						|
    /* time stamp1 to remove the entry from black list, unit is 1s */
 | 
						|
    uint32_t            rm_ts1;
 | 
						|
    /* time stamp2 to remove the entry from black list, unit is 1s */
 | 
						|
    uint32_t            rm_ts2;
 | 
						|
} iot_sg_bl_entry_t;
 | 
						|
 | 
						|
/* receive branch information descriptor */
 | 
						|
typedef struct _iot_sg_cco_bd_recv_desc {
 | 
						|
    /* energy */
 | 
						|
    uint16_t energy;
 | 
						|
} iot_sg_cco_bd_recv_desc_t;
 | 
						|
 | 
						|
/* branch detect device entry */
 | 
						|
typedef struct _iot_sg_bd_dev_entry {
 | 
						|
    /* hash table entry with meter mac address as key */
 | 
						|
    iot_ihash_entry_t   entry;
 | 
						|
    /* rx snr of this node */
 | 
						|
    int8_t              snr;
 | 
						|
    /* device type, see IOT_PLC_DEV_TYPE_XXX */
 | 
						|
    uint8_t             dev_type;
 | 
						|
    /* branch device state, see IOT_SG_CCO_BD_DEV_STATE_XXX */
 | 
						|
    uint8_t             dev_state           :4,
 | 
						|
    /* if exists pm under the branch detect device */
 | 
						|
                        exists_pm           :1,
 | 
						|
    /* if node is connectionless link */
 | 
						|
                        is_conn_less        :1,
 | 
						|
    /* flag to mark if node allow to send branch recognition message */
 | 
						|
                        allow_send          :1,
 | 
						|
    /* follow data of flag, 0 - no data, 1 - follow-up data. */
 | 
						|
                        flw_flag            :1;
 | 
						|
    /* node first physical phase line, only valid in connectionless */
 | 
						|
    uint8_t             phase_1             :2,
 | 
						|
    /* node second physical phase line, only valid in connectionless */
 | 
						|
                        phase_2             :2,
 | 
						|
    /* node third physical phase line, only valid in connectionless */
 | 
						|
                        phase_3             :2,
 | 
						|
    /* branch detect single receive capacity, see IOT_SG_CCO_BD_RECV_XXX */
 | 
						|
                        br_ident            :2;
 | 
						|
    /* same transformer flag */
 | 
						|
    uint8_t             same_tsfm           :1,
 | 
						|
    /* retry count of cco send command to node */
 | 
						|
                        send_cnt            :7;
 | 
						|
    /* support load capacity, see IOT_PLC_HW_TSFM_LOAD_CAP_XXX */
 | 
						|
    uint8_t             load_capacity       :2,
 | 
						|
    /* reserved for future */
 | 
						|
                        rsvd                :6;
 | 
						|
    /* the count of characteristic information received */
 | 
						|
    uint16_t            received_cnt        :13,
 | 
						|
    /* launch mode acquired in send stage   see IOT_PLC_HW_TSFM_SEND_MODE_XXX */
 | 
						|
                        launch_mode         :3;
 | 
						|
    /* list of receiving branch signal */
 | 
						|
    iot_sg_cco_bd_recv_desc_t  *recv_list;
 | 
						|
    /* father node index, special index see IOT_SG_CCO_BD_FATHER_XXX */
 | 
						|
    uint32_t            father_index        :12,
 | 
						|
    /* forward node index, only valid in connectionless,
 | 
						|
     * special index see IOT_SG_CCO_BD_FATHER_XXX.
 | 
						|
     */
 | 
						|
                        fwd_node_index      :12,
 | 
						|
    /* PT ratio, uint is x1 */
 | 
						|
                        v_ratio             :8;
 | 
						|
    /* longitude */
 | 
						|
    iot_sg_cco_node_location_unit_t longitude;
 | 
						|
    /* latitude */
 | 
						|
    iot_sg_cco_node_location_unit_t latitude;
 | 
						|
    /* CT ratio, uint is x1 */
 | 
						|
    uint16_t            i_ratio;
 | 
						|
    /* branch detect device query sequence */
 | 
						|
    uint16_t            query_seq;
 | 
						|
    /* timestamp of first launch command send, unit is 1s */
 | 
						|
    uint32_t            start_time_ts;
 | 
						|
    /* timestamp of launch response, unit is 1s */
 | 
						|
    uint32_t            rsp_time_ts;
 | 
						|
} iot_sg_bd_dev_entry_t;
 | 
						|
 | 
						|
/* descriptor of sta collect parameter layout structure */
 | 
						|
typedef struct _iot_sg_cco_clct_meter_param_v28 {
 | 
						|
    /* sta collect parameter v2.8 task id */
 | 
						|
    uint8_t                 task_id;
 | 
						|
    /* 0 - disabled, 1 - enabled */
 | 
						|
    uint8_t                 enabled     : 1,
 | 
						|
    /* 2 - DL/T645-2007, 3 - DL/T698.45, other - reserve, see PROTO_TYPE_XXX */
 | 
						|
                            proto_type  : 3,
 | 
						|
    /* 0 - single phase meter, 1 - three phase meter */
 | 
						|
                            pm_type     : 2,
 | 
						|
    /* reserved */
 | 
						|
                            rsvd        : 2;
 | 
						|
    /* unit is 1min */
 | 
						|
    uint8_t                 clct_period;
 | 
						|
    /* di count of single phase meter */
 | 
						|
    uint8_t                 di_cnt;
 | 
						|
    /* di information of single phase meter */
 | 
						|
    iot_sg_cco_di_info_t    di_info[0];
 | 
						|
} iot_sg_cco_clct_meter_param_v28_t;
 | 
						|
 | 
						|
#if (PLC_SUPPORT_CCO_ROLE && IOT_SMART_GRID_ENABLE)
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief    iot_sg_cco_init() - init smart grid cco role device specific
 | 
						|
 *           operation.
 | 
						|
 * @return:  0    -   for success case
 | 
						|
 * @return:  otherwise   -   error number
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_init();
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_deinit() - deinit smart grid cco role device specific
 | 
						|
 *        operation.
 | 
						|
 */
 | 
						|
void iot_sg_cco_deinit();
 | 
						|
 | 
						|
void iot_sg_cco_init_sta_entry(iot_sg_sta_entry_t *sta_entry, uint8_t dev_type);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief   iot_sg_cco_meter_mac_to_sta_mac() - get corresponding STA mac from
 | 
						|
 *          meter mac.
 | 
						|
 * @param   meter_mac:  mac address of a meter
 | 
						|
 * @param   sta_mac:    mac address of the sta which connect to the meter.
 | 
						|
 *          it's set to bcast address if cco doesn't know which
 | 
						|
 *          sta the meter connect to.
 | 
						|
 * @return: 0     - found the sta mac for the meter
 | 
						|
 * @return: otherwise   - for failure case
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_meter_mac_to_sta_mac(uint8_t *meter_mac,
 | 
						|
    uint8_t *sta_mac);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief:  update the sta and meter mapping relationship.
 | 
						|
 *          if pm_mac or sta_mac is invalid, mapping won't be updated.
 | 
						|
 * @param mac_table:     the mapping.
 | 
						|
 * @param pm_mac:        the meter mac.
 | 
						|
 * @param sta_mac:       the station mac.
 | 
						|
 * @param pm_proto_type: the meter protocol.
 | 
						|
 * @retval: ERR_OK  - for success case.
 | 
						|
 * @retval: ERR_XXX - error code.
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_update_mac_mapping(iot_sg_cco_mac_map_h mac_table,
 | 
						|
    uint8_t *pm_mac, uint8_t *sta_mac, uint8_t pm_proto_type);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief   iot_sg_cco_get_dev_drv_headroom() - get device driver package head
 | 
						|
 *          reserved length.
 | 
						|
 * @return: package head reserved length.
 | 
						|
 */
 | 
						|
uint8_t iot_sg_cco_get_headroom_req();
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_handle_sec_node_rpt() - handled secondary node registration
 | 
						|
 *                                           report message from station.
 | 
						|
 * @param seq:       message sequence number.
 | 
						|
 * @param reg_param: register parameter, see GW_APP_REG_PARAM_XXX.
 | 
						|
 * @param dev_mac:   device mac address.
 | 
						|
 * @param sta_mac:   station mac address.
 | 
						|
 * @param pkt:    pointer to iot_pkt structure, the data payload layout of the
 | 
						|
 *                iot_pkt, see the sec_node_query_t structure.
 | 
						|
 * @param done:   if is 1, means that the corresponding station secondary node
 | 
						|
 *                registration is done.
 | 
						|
 * @param clct_min: if support minutes collect.
 | 
						|
 * @retval:   0         - for success case
 | 
						|
 * @retval:   otherwise - error code
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_handle_sec_node_rpt(uint32_t seq, uint8_t reg_param,
 | 
						|
    uint8_t *dev_mac, uint8_t *sta_mac, iot_pkt_t *pkt, uint32_t done,
 | 
						|
    uint8_t clct_min);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_event_type_power_down() - using bm rpt power down evt
 | 
						|
 * @param pm_addr:   addr of power meter, Little-Endian.
 | 
						|
 * @param bm_size:   bitmap length.
 | 
						|
 * @param tei:       the tei of the start bit in the bitmap.
 | 
						|
 * @param bm:        tei bitmap.
 | 
						|
 * @param seq:       message sequence number.
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_event_type_power_down(uint8_t *pm_addr, uint16_t bm_size,
 | 
						|
    uint16_t tei, uint8_t *bm, uint16_t seq);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_event_type_power_up() - report device power up event
 | 
						|
 * @param sta_addr:  addr of station, Big-Endian.
 | 
						|
 * @param pm_addr:   addr of power meter, Little-Endian.
 | 
						|
 * @param seq:       message sequence number.
 | 
						|
 * @retval:   ERR_OK  - for success case
 | 
						|
 * @retval:   ERR_XXX - error code
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_event_type_power_up(uint8_t *sta_addr, uint8_t *pm_addr,
 | 
						|
    uint16_t seq);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_power_down_evt_rpt_addr() - using addr rpt power down evt
 | 
						|
 * @param pm_addr:   addr of power meter, Little-Endian.
 | 
						|
 * @param pm_data:   power down meter information.
 | 
						|
 * @param data_len:  power down meter data length.
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_evt_type_power_down_addr(uint8_t *pm_addr,
 | 
						|
    iot_sg_evt_data_addr_t *pm_data, uint16_t data_len, uint16_t seq);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_evt_type_power_up_addr() - using addr rpt power down evt
 | 
						|
 * @param sta_addr:  addr of station, Big-Endian.
 | 
						|
 * @param pm_addr:   addr of power meter, Little-Endian.
 | 
						|
 * @param pm_data:   power up meter information.
 | 
						|
 * @param data_len:  power up meter data length.
 | 
						|
 * @param trigger_dev:  event trigger device type, see IOT_SG_CCO_DEV_TYPE_XXX.
 | 
						|
 * @param seq:       message sequence number.
 | 
						|
 * @retval:   ERR_OK  - for success case
 | 
						|
 * @retval:   ERR_XXX - error code
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_evt_type_power_up_addr(uint8_t *sta_addr, uint8_t *pm_addr,
 | 
						|
    iot_sg_evt_data_addr_t *pm_data, uint16_t data_len, uint8_t trigger_dev,
 | 
						|
    uint16_t seq);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_event_type_phase_sequnence() - rpt phase sequnence evt
 | 
						|
 * @param sta_addr:  addr of station, Big-Endian.
 | 
						|
 * @param pm_addr:   addr of three power meter, Little-Endian.
 | 
						|
 * @param phase_seq_status: phase sequence status,
 | 
						|
 *                          see GW_APP_PHASE_SEQUENCE_STAUS_XXX .
 | 
						|
 * @param seq:       message sequence number.
 | 
						|
 * @retval:   ERR_OK  - for success case
 | 
						|
 * @retval:   ERR_XXX - error code
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_event_type_phase_sequnence(uint8_t *sta_addr,
 | 
						|
    uint8_t *pm_addr, uint8_t phase_seq_status, uint16_t seq);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_event_type_search_result() - rpt search result evt
 | 
						|
 * @param sta_mac:  addr of station, Big-Endian.
 | 
						|
 * @param dev_mac:  collector or pm moudle mac, little-endian.
 | 
						|
 * @param pm_count: power meter count, no more than 32.
 | 
						|
 * @param pm_info:  search meter result info.
 | 
						|
 * @retval: ERR_OK  - for success case
 | 
						|
 * @retval: ERR_XX  - error code
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_event_type_search_result(uint8_t *sta_mac, uint8_t *dev_mac,
 | 
						|
    uint8_t pm_count, iot_sg_cco_search_pm_info_t *pm_info);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_evnt_type_nli_abnormal_rpt() - rpt nli abnormal evt
 | 
						|
 * @param rpt_cnt:  report count.
 | 
						|
 * @param data:     reprot abnormal data.
 | 
						|
 * @param data_len: reprot abnormal data length.
 | 
						|
 * @param sta_mac:  addr of station, Big-Endian.
 | 
						|
 * @param pm_mac:   collector or pm moudle mac, little-endian.
 | 
						|
 * @param trigger_dev: event trigger device type, see IOT_SG_CCO_DEV_TYPE_XXX.
 | 
						|
 * @param evt_type: event reprot type, see IOT_SG_CCO_EVENT_XXX.
 | 
						|
 * @param seq:      message sequence number.
 | 
						|
 * @retval: ERR_OK  - for success case
 | 
						|
 * @retval: ERR_XX  - error code
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_evnt_type_nli_abnormal_rpt(uint16_t rpt_cnt,
 | 
						|
    uint8_t *data, uint16_t data_len, uint8_t *sta_mac, uint8_t *pm_mac,
 | 
						|
    uint8_t trigger_dev, uint8_t evt_type, uint16_t seq);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief   the device type is collector or power meter.
 | 
						|
 * @param   dev_type: device type, see IOT_PLC_DEV_TYPE_XXX.
 | 
						|
 * @return: 0 - no
 | 
						|
 * @return: otherwise - yes
 | 
						|
 */
 | 
						|
uint8_t iot_sg_cco_is_collector_or_pm(uint8_t dev_type);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief   get a down link sn for app packet.
 | 
						|
 * @return: the sn for app packet. value range is in [1,0xFFFF]
 | 
						|
 */
 | 
						|
uint16_t iot_sg_cco_get_app_dl_sn();
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief handle data from controller.
 | 
						|
 * @param pkt:        iot_pkt_t containing data from controller.
 | 
						|
 * @param proto_type: proto type of the pkt, see IOT_SG_CCO_CTRL_PROTO_XXX.
 | 
						|
 * @retval:           0 - the pkt is not consumed.
 | 
						|
 *                    1 - the pkt is consumed.
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_handle_ctrl_proto(iot_pkt_t *pkt, uint8_t proto_type);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief handle passthrough data from controller.
 | 
						|
 * @param pkt:        iot_pkt_t containing data from controller.
 | 
						|
 * @param proto_type: proto type of the pkt, see IOT_SG_CCO_CTRL_PROTO_XXX.
 | 
						|
 * @retval:           0 - the pkt is not consumed.
 | 
						|
 *                    1 - the pkt is consumed.
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_handle_ctrl_proto_passthrough(iot_pkt_t *pkt,
 | 
						|
    uint8_t proto_type);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief report station side transformer detect status to framework.
 | 
						|
 * @param sta_mac:    the station mac, big-endian.
 | 
						|
 * @param done:       0 - transformer detect in progress,
 | 
						|
 *                    1 - transformer detect done
 | 
						|
 * @param result:     transformer detect result,
 | 
						|
 *                    see IOT_SG_CCO_STA_TSFM_DETECT_RET_XXX.
 | 
						|
 * @param tsfm_mac:   station real transformer mac address, big-endian.
 | 
						|
 * @param hw_tsfm_mac:hardware transformer mac address, big-endian.
 | 
						|
 */
 | 
						|
void iot_sg_cco_rpt_sta_tsfm_detect_result(uint8_t *sta_mac, uint8_t done,
 | 
						|
    uint8_t result, uint8_t *tsfm_mac, uint8_t *hw_tsfm_addr);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief update station side transformer detect status to framework.
 | 
						|
 * @param sta_mac:    the station mac, big-endian.
 | 
						|
 * @param done:       0 - transformer detect in progress,
 | 
						|
 *                    1 - transformer detect done
 | 
						|
 * @param result:     transformer detect result,
 | 
						|
 *                    see IOT_SG_CCO_STA_TSFM_DETECT_RET_XXX.
 | 
						|
 * @param tsfm_mac:   station real transformer mac address, big-endian.
 | 
						|
 * @param hw_tsfm_mac:hardware transformer mac address, big-endian.
 | 
						|
 */
 | 
						|
void iot_sg_cco_pw_tsfm_sta_staus_update(uint8_t *sta_mac, uint8_t done,
 | 
						|
    uint8_t result, uint8_t *tsfm_mac, uint8_t *hw_tsfm_mac);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief handle module id report.
 | 
						|
 * @param sta_mac:      the station mac, big-endian.
 | 
						|
 * @param module_info:  module id information
 | 
						|
 * @param len:          module id length
 | 
						|
 */
 | 
						|
void iot_sg_cco_handle_module_id_rpt(uint8_t *sta_mac, uint8_t *module_id,
 | 
						|
    uint8_t len);
 | 
						|
 | 
						|
/*
 | 
						|
 * @brief: handle version info reported from STA
 | 
						|
 * @param sta_mac: mac addr of the STA reported version info, big-endian.
 | 
						|
 * @param data: buffer contain version info
 | 
						|
 * @param len: length of version info
 | 
						|
 */
 | 
						|
void iot_sg_cco_handle_version_info_rpt(uint8_t *sta_mac, uint8_t *data,
 | 
						|
    uint16_t len);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief handle transform feature report.
 | 
						|
 * @param sta_mac: the station mac, big-endian.
 | 
						|
 */
 | 
						|
void iot_sg_cco_handle_tsfm_feature_rpt(uint8_t *sta_mac);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief process internal meter reading result
 | 
						|
 * @param cmd_entry: down link meter reading command, not consumed buf entry
 | 
						|
 * @param pkt: meter reading result data.
 | 
						|
 * @retval: 0 - the pkt is not consumed, 1 - the pkt is consumed.
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_internal_mr_data_handle(iot_buf_pool_entry_t *cmd_entry,
 | 
						|
    iot_pkt_t *pkt);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief set sta collect parameter config result
 | 
						|
 * @param sta_mac:   sta mac addr, big-endian.
 | 
						|
 * @param result:    0 - fail, 1 - success
 | 
						|
 */
 | 
						|
void iot_sg_cco_set_sta_clct_param_conf_ret(uint8_t *sta_mac, uint8_t result);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief handle meter parameter report.
 | 
						|
 * @param sta_mac:      the station mac, big-endian.
 | 
						|
 * @param pm_type:      0 - single phase meter, 1 - three phase meter
 | 
						|
 * @param zc_type:      0 - falling edge, 1 - rising edge.
 | 
						|
 */
 | 
						|
void iot_sg_cco_handle_meter_param_rpt(uint8_t *sta_mac, uint8_t pm_type,
 | 
						|
    uint8_t zc_type);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief handle secondary node chip id info report.
 | 
						|
 * @param meter_mac:    the meter mac addr, little-endian.
 | 
						|
 * @param id_len:       chip id length.
 | 
						|
 * @param chip_id_ptr:  the pointer of chip id.
 | 
						|
 * @param super_cap:    flag to mark if have super capacitance.
 | 
						|
 * @param super_cap:    flag to mark if could fix position.
 | 
						|
 */
 | 
						|
void iot_sg_cco_handle_sec_node_chip_id_info_rpt(uint8_t *meter_mac,
 | 
						|
    uint8_t id_len, uint8_t *chip_id_ptr, uint8_t super_cap,
 | 
						|
    uint8_t fix_position);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief: handle storage dev type rpt.
 | 
						|
 * @param minute_clct: dev support minute collection flag.
 | 
						|
 * @param sta_mac: mac address of the source sta, big-endian.
 | 
						|
 */
 | 
						|
void iot_sg_cco_handle_storage_dev_type_rpt(uint8_t minute_clct_flag,
 | 
						|
    uint8_t *sta_mac);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief: handle lock time report.
 | 
						|
 * @param sta_mac: mac address of the source sta, big-endian.
 | 
						|
 * @param net_lock_time: pointer, get net_lock_time from cco.
 | 
						|
 * @param abn_lock_time: pointer, get abn_lock_time from cco.
 | 
						|
 */
 | 
						|
void iot_sg_cco_handle_lock_time_rpt(uint8_t *sta_mac, uint16_t net_lock_time,
 | 
						|
    uint16_t abn_lock_time);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief: check meter change status for whitelist join cnt.
 | 
						|
 * @param pm_mac: meter address, little endian.
 | 
						|
 * @param chg_status: meter change status, see IOT_SG_CCO_WL_ACTION_XXX.
 | 
						|
 */
 | 
						|
void iot_sg_cco_check_for_pm_chg(uint8_t *pm_mac, uint8_t chg_status);
 | 
						|
 | 
						|
/*
 | 
						|
 * @brief: judge the sender intern type.
 | 
						|
 * @param sender: sender type, see IOT_SG_CCO_CMD_SENDER_XXX.
 | 
						|
 * @retval: ERR_OK - intern type. otherwise - other sender type.
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_sender_is_intern_type(uint8_t sender);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief:  check if intern type concurrent meter reading count exceed
 | 
						|
 *          max current count.
 | 
						|
 * @retval:  0           -   not exceed max current count.
 | 
						|
 * @retval:  1           -   exceed max current count.
 | 
						|
 */
 | 
						|
uint8_t iot_sg_cco_intern_exceed_con_cnt();
 | 
						|
 | 
						|
/*
 | 
						|
 * @brief: get max concurrent limit for con meter reading
 | 
						|
 *         CCo rejects con mr cmd if con mr cnt reach this value.
 | 
						|
 * @param con_mr_dur: con meter reading timeout value.
 | 
						|
 * @retval: con meter reading concurrency count limit.
 | 
						|
 */
 | 
						|
uint16_t iot_sg_cco_get_concurrency_limit(uint16_t con_mr_dur);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_add_wl_entry() - add some whitelist entry.
 | 
						|
 * @param count: the count of entry that need to add.
 | 
						|
 * @param rm_ts: time stamp to remove the entry from white list, unit is 1s.
 | 
						|
 * @param node:  the point of entry.
 | 
						|
 */
 | 
						|
void iot_sg_cco_add_wl_entry(uint8_t count, uint32_t rm_ts,
 | 
						|
    iot_sg_wl_op_entry_t *node);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_add_bl_entry() - add some blacklist entry.
 | 
						|
 * @param count: the count of entry that need to add.
 | 
						|
 * @param node:  the point of entry.
 | 
						|
 */
 | 
						|
void iot_sg_cco_add_bl_entry(uint8_t count, iot_sg_bl_op_info_t *node);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_remove_wl_entry() - remove whitelist entry.
 | 
						|
 * @param count:           remove node count;
 | 
						|
 * @param array_mac_addr:  mac address array of node
 | 
						|
 */
 | 
						|
void iot_sg_cco_remove_wl_entry(uint8_t count, uint8_t *array_mac_addr);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_set_wl_state_internal() - set plc white list state
 | 
						|
 * @param wl_state: white list state, see IOT_CLI_SG_WL_STATE_XXX
 | 
						|
 * @param force_flag: 1 - force set white list state
 | 
						|
 * @return: see ERR_XXX.
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_set_wl_state_internal(uint8_t wl_state, uint8_t force_flag);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_update_wl_state_to_pib() - update white list state to PIB
 | 
						|
 * @param wl_state: white list state, see IOT_CLI_SG_WL_STATE_XXX
 | 
						|
 */
 | 
						|
void iot_sg_cco_update_wl_state_to_pib(uint8_t wl_state);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief iot_sg_cco_get_sta_entry_by_index() - get sta_entry by index.
 | 
						|
 * @param sta_index: the index of station in map.
 | 
						|
 * @return: pointer to the corresponding STA info.
 | 
						|
 */
 | 
						|
iot_sg_sta_entry_t *iot_sg_cco_get_sta_entry_by_index(uint16_t sta_index);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief get tsfm detect timeout.
 | 
						|
 * @return: tsfm detect timeout, see IOT_SG_CCO_TSFM_DETECT_TIMEOUT_XXX.
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_get_tsfm_detect_timeout_default();
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief set event report flag.
 | 
						|
 * @param intf_type: the caller, CLI or concentrator.
 | 
						|
 * @param enable_flag: enable event report flag.
 | 
						|
 */
 | 
						|
void iot_sg_cco_set_evt_rpt_flag(uint8_t intf_type, uint8_t enable_flag);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief   get meter list entry information
 | 
						|
 * @param   start_index:    get meter entry info start from this index.
 | 
						|
 * @param   count:          max count of meter list entry to be returned.
 | 
						|
 * @return: NULL        -   for failed case.
 | 
						|
 * @return: otherwise   -   an IOT_PKT_T with an array of type
 | 
						|
 *                          iot_sg_node_info_transfer_t.
 | 
						|
 */
 | 
						|
iot_pkt_t *iot_sg_cco_get_meter_info(uint32_t start_index, uint32_t count);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief   get sta entry by meter address.
 | 
						|
 * @param   pm_addr: meter address, little endian.
 | 
						|
 * @return: pointer to the corresponding STA info.
 | 
						|
 */
 | 
						|
iot_sg_sta_entry_t *iot_sg_cco_get_sta_entry_by_pm(uint8_t *pm_addr);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief   get extension task send type by sent count.
 | 
						|
 * @param   send_cnt: the collect sent count.
 | 
						|
 * @return: send type, see IOT_PLC_MSG_TYPE_XXX.
 | 
						|
 */
 | 
						|
uint8_t iot_sg_cco_ext_task_get_send_type(uint16_t send_cnt);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief get rtc time for bcd format.
 | 
						|
 * @param tm: rtc time for byte format.
 | 
						|
 */
 | 
						|
void iot_sg_cco_get_rtc_bcd(iot_sg_cco_time_t *tm);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief pw handle transformer detect data.
 | 
						|
 * @param flw_flag: follow data of flag, 0 - no data, 1 - follow-up data.
 | 
						|
 * @param node_cnt: report node count.
 | 
						|
 * @param data: tsfm_detect node data.
 | 
						|
 * @param sta_mac: mac address of the source sta, big-endian.
 | 
						|
 * @retval: ERR_OK  - for success case
 | 
						|
 * @retval: ERR_XX  - error code
 | 
						|
 */
 | 
						|
uint32_t iog_sg_cco_handle_tsfm_detect_data_pw(uint8_t flw_flag,
 | 
						|
    uint8_t node_cnt, uint8_t *data, uint8_t *sta_mac);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief reset route meter reading state.
 | 
						|
 */
 | 
						|
void iot_sg_cco_rt_mr_reset_pm_state();
 | 
						|
 | 
						|
/* @brief: clock manage info report.
 | 
						|
 * @param sta_mac: sta address, big endian.
 | 
						|
 * @param auto_corr: node auto correct flag.
 | 
						|
 * @param threshold: node clock manager threshold.
 | 
						|
 */
 | 
						|
void iot_sg_cco_handle_clock_info_rpt(uint8_t *sta_mac, uint8_t auto_corr,
 | 
						|
    uint8_t threshold);
 | 
						|
 | 
						|
 | 
						|
/* @brief: check if the nw esp need to use mac list function.
 | 
						|
 * @retval:  0   -   don't need to use.
 | 
						|
 * @retval:  1   -   need to use.
 | 
						|
 */
 | 
						|
uint8_t iot_sg_cco_nw_mac_list_check();
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief check event report, filter duplicate event .
 | 
						|
 * @param sta_mac: sta address, big endian.
 | 
						|
 * @param data: pointer to event report data.
 | 
						|
 * @param len: length of event report data.
 | 
						|
 * @retval: ERR_OK  - for success case
 | 
						|
 * @retval: ERR_XX  - error code
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_check_evt_rpt_filter(uint8_t *sta_mac, uint8_t *data,
 | 
						|
    uint32_t len);
 | 
						|
 | 
						|
/* @brief: safe increase of launch sequence number
 | 
						|
 */
 | 
						|
void iot_sg_cco_bd_launch_sn_inc(void);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief get cco receive upgrade file flag .
 | 
						|
 * @retval: 1 - receiving, 0 - other.
 | 
						|
 */
 | 
						|
uint8_t iot_sg_cco_get_receiving_upgrade_file_flag(void);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief handle msdu msg.
 | 
						|
 * @param pkt: need to handle msdu data pointer.
 | 
						|
 * @param msdu: msdu data pointer.
 | 
						|
 * @retval: 0 - don't consumed pkt, others - consumed pkt
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_handle_msdu_msg(iot_pkt_t *pkt,
 | 
						|
    iot_plc_msdu_recv_t *msdu);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief check 3phase device.
 | 
						|
 * @param dev_type: see IOT_PLC_DEV_TYPE_XXX.
 | 
						|
 * @return: non 0 is 3phase device.
 | 
						|
 */
 | 
						|
uint8_t iot_sg_cco_is_3phase_dev(uint8_t dev_type);
 | 
						|
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief get collect di by index.
 | 
						|
 * @param idx: di index.
 | 
						|
 * @param proto_type: proto type, see PROTO_TYPE_XXX.
 | 
						|
 * @return: collect di.
 | 
						|
 */
 | 
						|
uint32_t iot_sg_cco_get_clct_di_by_idx(uint32_t idx, uint8_t proto_type);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief reset white list timer.
 | 
						|
 * @param interval: reset time interval.
 | 
						|
 */
 | 
						|
void iot_sg_cco_restart_wl_timer(uint32_t interval);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief update sta collect parameter to pib
 | 
						|
 * @param meter:        data point
 | 
						|
 * @param data_len:     data length
 | 
						|
 * @param crc:          data crc
 | 
						|
 * @param clct_period:  collect period
 | 
						|
 * @param enabled:      parameter enabled
 | 
						|
 * @param proto_type:   proto type, see PROTO_TYPE_XXX
 | 
						|
 * @param type:         sta collect parameter type,
 | 
						|
 *                      see IOT_SG_CCO_CURVE_COLLET_TYPE_XXX
 | 
						|
 * @param task_id:      collect task id
 | 
						|
 */
 | 
						|
void iot_sg_cco_update_sta_clct_param_to_pib(
 | 
						|
    iot_sg_cco_meter_clct_param_t *meter, uint16_t data_len, uint32_t crc,
 | 
						|
    uint8_t clct_period, uint8_t enabled, uint8_t proto_type, uint8_t type,
 | 
						|
    uint8_t task_id);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief set base info bitmap.
 | 
						|
 * @param sta_entry: need set sta.
 | 
						|
 * @param element: need set element bit.
 | 
						|
 */
 | 
						|
void iot_sg_cco_set_base_info_bitmap(iot_sg_sta_entry_t *sta_entry,
 | 
						|
    uint8_t element);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief get base info bitmap.
 | 
						|
 * @param sta_entry: need get sta.
 | 
						|
 * @param element: need get element bit.
 | 
						|
 * @return: element bit result.
 | 
						|
 */
 | 
						|
uint8_t iot_sg_cco_get_base_info_bitmap(iot_sg_sta_entry_t *sta_entry,
 | 
						|
    uint8_t element);
 | 
						|
 | 
						|
#else /* PLC_SUPPORT_CCO_ROLE && IOT_SMART_GRID_ENABLE */
 | 
						|
 | 
						|
void iot_sg_cco_handle_clock_info_rpt(uint8_t *sta_mac, uint8_t auto_corr,
 | 
						|
    uint8_t threshold);
 | 
						|
 | 
						|
uint32_t iot_sg_cco_handle_msdu_msg(iot_pkt_t *pkt, iot_plc_msdu_recv_t *msdu);
 | 
						|
 | 
						|
#define iot_sg_cco_init()   (ERR_NOSUPP)
 | 
						|
 | 
						|
#define iot_sg_cco_deinit()
 | 
						|
 | 
						|
#define iot_sg_cco_meter_mac_to_sta_mac(meter_mac, sta_mac) (ERR_FAIL)
 | 
						|
 | 
						|
#define iot_sg_cco_update_mac_mapping(mac_table, pm_mac, sta_mac, \
 | 
						|
    pm_proto_type) (ERR_FAIL)
 | 
						|
 | 
						|
#define iot_sg_cco_handle_sec_node_rpt(seq, snq_p, done, clct_min) (ERR_NOSUPP)
 | 
						|
 | 
						|
#define iot_sg_cco_get_dev_drv_headroom() (0)
 | 
						|
 | 
						|
#define iot_sg_cco_event_type_power_down(sta_addr, pm_addr, data_len, \
 | 
						|
    tei, bm, seq)  (ERR_NOSUPP)
 | 
						|
 | 
						|
#define iot_sg_cco_event_type_power_up(sta_addr, pm_addr, seq)  (ERR_NOSUPP)
 | 
						|
 | 
						|
#define iot_sg_cco_evt_type_power_down_addr(sta_addr, pm_addr, pm_data, \
 | 
						|
    data_len, seq)  (ERR_NOSUPP)
 | 
						|
 | 
						|
#define iot_sg_cco_evt_type_power_up_addr(sta_addr, pm_addr, pm_data, \
 | 
						|
    data_len, trigger_dev, seq)  (ERR_NOSUPP)
 | 
						|
 | 
						|
#define iot_sg_cco_event_type_phase_sequnence(sta_addr, pm_addr, \
 | 
						|
    phase_seq_status, seq)  (ERR_NOSUPP)
 | 
						|
 | 
						|
#define iot_sg_cco_event_type_search_result(sta_mac, dev_mac, pm_count,  \
 | 
						|
    pm_info) (0)
 | 
						|
 | 
						|
#define  iot_sg_cco_evnt_type_nli_abnormal_rpt(rpt_cnt, data, data_len, \
 | 
						|
    sta_mac, pm_mac, trigger_dev, evt_type, seq) (ERR_FAIL)
 | 
						|
 | 
						|
#define iot_sg_cco_is_collector_or_pm(dev_type) (0)
 | 
						|
 | 
						|
#define iot_sg_cco_get_app_dl_sn() (0)
 | 
						|
 | 
						|
#define iot_sg_cco_handle_ctrl_proto(pkt, proto_type) (0)
 | 
						|
 | 
						|
#define iot_sg_cco_handle_ctrl_proto_passthrough(pkt, proto_type) (0)
 | 
						|
 | 
						|
#define iot_sg_cco_rpt_sta_tsfm_detect_result(sta_mac, done, result, tsfm_mac, \
 | 
						|
    hw_tsfm_mac)
 | 
						|
 | 
						|
#define iot_sg_cco_pw_tsfm_sta_staus_update(sta_mac, done, result, tsfm_mac, \
 | 
						|
    hw_tsfm_mac)
 | 
						|
 | 
						|
#define iot_sg_cco_handle_module_id_rpt(sta_mac, module_id, len)
 | 
						|
 | 
						|
#define iot_sg_cco_handle_version_info_rpt(sta_mac, data, len)
 | 
						|
 | 
						|
#define iot_sg_cco_handle_tsfm_feature_rpt(sta_mac)
 | 
						|
 | 
						|
#define iot_sg_cco_internal_mr_data_handle(cmd_entry, pkt) (ERR_FAIL)
 | 
						|
 | 
						|
#define iot_sg_cco_set_sta_clct_param_conf_ret(sta_mac, result)
 | 
						|
 | 
						|
#define iot_sg_cco_handle_meter_param_rpt(sta_mac, pm_type, zc_type)
 | 
						|
 | 
						|
#define iot_sg_cco_handle_sec_node_chip_id_info_rpt(meter_mac, id_len, \
 | 
						|
    chip_id_ptr, super_cap, fix_position)
 | 
						|
 | 
						|
#define iot_sg_cco_handle_storage_dev_type_rpt(minute_clct_flag, sta_mac)
 | 
						|
 | 
						|
#define iot_sg_cco_handle_lock_time_rpt(sta_mac, net_lock_time, abn_lock_time)
 | 
						|
 | 
						|
#define iot_sg_cco_check_for_pm_chg(pm_mac, chg_status)
 | 
						|
 | 
						|
#define iot_sg_cco_sender_is_intern_type(sender) (ERR_FAIL)
 | 
						|
 | 
						|
#define iot_sg_cco_intern_exceed_con_cnt() (1)
 | 
						|
 | 
						|
#define iot_sg_cco_get_concurrency_limit(con_mr_dur) (0)
 | 
						|
 | 
						|
#define iot_sg_cco_add_wl_entry(count, rm_ts, node)
 | 
						|
 | 
						|
#define iot_sg_cco_add_bl_entry(count, node)
 | 
						|
 | 
						|
#define iot_sg_cco_remove_wl_entry(count, array_mac_addr)
 | 
						|
 | 
						|
#define iot_sg_cco_set_wl_state_internal(wl_state, force_flag) (0)
 | 
						|
 | 
						|
#define iot_sg_cco_update_wl_state_to_pib(wl_state)
 | 
						|
 | 
						|
#define iot_sg_cco_get_sta_entry_by_index(sta_index) (NULL)
 | 
						|
 | 
						|
#define iot_sg_cco_get_tsfm_detect_timeout_default() (0)
 | 
						|
 | 
						|
#define iot_sg_cco_set_evt_rpt_flag(intf_type, enable_flag)
 | 
						|
 | 
						|
#define iot_sg_cco_get_meter_info(start_index, count) (NULL)
 | 
						|
 | 
						|
#define iot_sg_cco_get_sta_entry_by_pm(pm_addr) (NULL)
 | 
						|
 | 
						|
#define iot_sg_cco_ext_task_get_send_type(send_cnt) (0)
 | 
						|
 | 
						|
#define iot_sg_cco_get_rtc_bcd(tm)
 | 
						|
 | 
						|
#define iog_sg_cco_handle_tsfm_detect_data_pw(flw_flag, node_cnt, data, \
 | 
						|
    sta_mac) (ERR_FAIL)
 | 
						|
 | 
						|
#define iot_sg_cco_rt_mr_reset_pm_state()
 | 
						|
 | 
						|
#define iot_sg_cco_nw_mac_list_check() (0)
 | 
						|
 | 
						|
#define iot_sg_cco_check_evt_rpt_filter(sta_mac, data, len) (ERR_FAIL)
 | 
						|
 | 
						|
#define iot_sg_cco_bd_launch_sn_inc()
 | 
						|
#define iot_sg_cco_get_receiving_upgrade_file_flag() (1)
 | 
						|
 | 
						|
#define iot_sg_cco_is_3phase_dev(dev_type) (0)
 | 
						|
 | 
						|
#define iot_sg_cco_get_clct_di_by_idx(idx, proto_type) (0)
 | 
						|
 | 
						|
#define iot_sg_cco_restart_wl_timer(interval)
 | 
						|
 | 
						|
#define iot_sg_cco_update_sta_clct_param_to_pib(meter, data_len, crc, \
 | 
						|
    clct_period,  enabled,  proto_type, type, task_id)
 | 
						|
 | 
						|
#define iot_sg_cco_set_base_info_bitmap(sta_entry, element)
 | 
						|
 | 
						|
#define iot_sg_cco_get_base_info_bitmap(sta_entry, element) (0)
 | 
						|
 | 
						|
#endif /* PLC_SUPPORT_CCO_ROLE && IOT_SMART_GRID_ENABLE */
 | 
						|
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif  /* IOT_SG_CCO_H */
 |