559 lines
		
	
	
		
			21 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			559 lines
		
	
	
		
			21 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
|  | /****************************************************************************
 | ||
|  | 
 | ||
|  | Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. | ||
|  | 
 | ||
|  | This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT | ||
|  | be copied by any method or incorporated into another program without | ||
|  | the express written consent of Aerospace C.Power. This Information or any portion | ||
|  | thereof remains the property of Aerospace C.Power. The Information contained herein | ||
|  | is believed to be accurate and Aerospace C.Power assumes no responsibility or | ||
|  | liability for its use in any way and conveys no license or title under | ||
|  | any patent or copyright and makes no representation or warranty that this | ||
|  | Information is free from patent or copyright infringement. | ||
|  | 
 | ||
|  | ****************************************************************************/ | ||
|  | #ifndef IOT_SG_CFG_H
 | ||
|  | #define IOT_SG_CFG_H
 | ||
|  | 
 | ||
|  | /* iot includes */ | ||
|  | #include "iot_pib_api.h"
 | ||
|  | #include "iot_utils_api.h"
 | ||
|  | 
 | ||
|  | /* os shim includes */ | ||
|  | #include "os_types_api.h"
 | ||
|  | 
 | ||
|  | /* smart grid internal header files */ | ||
|  | #include "iot_sg_fr.h"
 | ||
|  | 
 | ||
|  | #ifdef __cplusplus
 | ||
|  | extern "C" { | ||
|  | #endif
 | ||
|  | 
 | ||
|  | /* pack for the structures in the whole file */ | ||
|  | #pragma pack(push)  // save the pack status
 | ||
|  | #pragma pack(1)     // 1 byte align
 | ||
|  | 
 | ||
|  | /* WT-SG-11.0.0.0-CCO-xxxxxxxx  xxxxxxxx = brief fw feature list*/ | ||
|  | #define IOT_SGAPP_FW_VER_STR_LEN            (32)
 | ||
|  | 
 | ||
|  | #if RUN_IN_PSRAM
 | ||
|  | /* defines the sg app supported max number of whitelist */ | ||
|  | #define IOT_SG_APP_WL_MAX_NUM               (2039)
 | ||
|  | /* sta collect parameter v2.8 max task id */ | ||
|  | #define IOT_SG_STA_CLCT_MAX_TASK_CNT        (8)
 | ||
|  | /* defines the diff data max length in pib */ | ||
|  | #define IOT_SG_PIB_DIFF_DATA_MAX_LEN        (3255)
 | ||
|  | #else
 | ||
|  | #define IOT_SG_APP_WL_MAX_NUM               (1)
 | ||
|  | #define IOT_SG_STA_CLCT_MAX_TASK_CNT        (1)
 | ||
|  | #define IOT_SG_PIB_DIFF_DATA_MAX_LEN        (153)
 | ||
|  | #endif
 | ||
|  | 
 | ||
|  | /* define hardware tsfm detecting mode */ | ||
|  | #define IOT_SG_STA_HW_TSFM_MODE_PLC         1 /* info get from PLCLib */
 | ||
|  | #define IOT_SG_STA_HW_TSFM_MODE_IC          2 /* info get from external IC */
 | ||
|  | 
 | ||
|  | /* sta collect di count */ | ||
|  | #define IOT_SG_STA_CLCT_DI_CNT_SINGLE_645   7
 | ||
|  | #define IOT_SG_STA_CLCT_DI_CNT_THREE_645    17
 | ||
|  | /* 698 sta collect di count */ | ||
|  | #define IOT_SG_STA_CLCT_DI_CNT_SINGLE_698   6
 | ||
|  | #define IOT_SG_STA_CLCT_DI_CNT_THREE_698    11
 | ||
|  | 
 | ||
|  | /* save bcast collcet max count */ | ||
|  | #define IOT_SG_BCAST_CLCT_MAX_CNT           (16)
 | ||
|  | 
 | ||
|  | /* save bcast info max length */ | ||
|  | #define IOT_SG_CLCT_DATA_MAX_LENGTH         (35)
 | ||
|  | 
 | ||
|  | /* define parent address type */ | ||
|  | #define IOT_SG_STA_PA_ADDR_TYPE_INVALID     0
 | ||
|  | #define IOT_SG_STA_PA_ADDR_TYPE_PO          1
 | ||
|  | #define IOT_SG_STA_PA_ADDR_TYPE_TSFM        2
 | ||
|  | 
 | ||
|  | /* vendor device sn max length */ | ||
|  | #define IOT_SG_VENDOR_DEVICE_SN_LEN         64
 | ||
|  | 
 | ||
|  | /* descriptor of white list layout structure in PIB */ | ||
|  | typedef struct _iot_sg_wl_pib_entry { | ||
|  |     /* mac address of secondary node */ | ||
|  |     uint8_t             mac[IOT_MAC_ADDR_LEN]; | ||
|  |     /* protocol the node supports */ | ||
|  |     uint8_t             proto_type  :4, | ||
|  |     /* auto remove white list entry */ | ||
|  |                         auto_rm     :1, | ||
|  |     /* reserved for further use */ | ||
|  |                         reserved    :3; | ||
|  | } iot_sg_wl_pib_entry_t; | ||
|  | 
 | ||
|  | /* di and result length */ | ||
|  | typedef struct _iot_sg_di_info_pib { | ||
|  |     /* di index */ | ||
|  |     uint8_t             di_index; | ||
|  |     /* meter reading result length */ | ||
|  |     uint8_t             di_result_len; | ||
|  | } iot_sg_di_info_pib_t; | ||
|  | 
 | ||
|  | /* descriptor of 645 protocol sta collect parameter layout structure in PIB */ | ||
|  | typedef struct _iot_sg_645_clct_param_pib { | ||
|  |     /* 0 - disabled, 1 - enabled */ | ||
|  |     uint8_t             enabled     :1, | ||
|  |     /* if sta clct param is valid, 0 invalid, 1 valid */ | ||
|  |                         valid       :1, | ||
|  |     /* three phase meter value */ | ||
|  |                         three_value :1, | ||
|  |                         rsvd        :5; | ||
|  |     /* unit is 1min */ | ||
|  |     uint8_t             clct_period; | ||
|  |     /* di count of single phase meter */ | ||
|  |     uint8_t             di_cnt_single; | ||
|  |     /* di result total length of single phase meter */ | ||
|  |     uint8_t             di_result_len_single; | ||
|  |     /* di information of single phase meter */ | ||
|  |     iot_sg_di_info_pib_t di_single[IOT_SG_STA_CLCT_DI_CNT_SINGLE_645]; | ||
|  |     /* di count of three phase meter */ | ||
|  |     uint8_t             di_cnt_three; | ||
|  |     /* di result total length of three phase meter */ | ||
|  |     uint8_t             di_result_len_three; | ||
|  |     /* di information of three phase meter */ | ||
|  |     iot_sg_di_info_pib_t di_three[IOT_SG_STA_CLCT_DI_CNT_THREE_645]; | ||
|  |     /* the crc of collect parameter,
 | ||
|  |      * for verifying whether local parameter and cctt's parameter are the same. | ||
|  |      */ | ||
|  |     uint32_t            crc; | ||
|  | } iot_sg_645_clct_param_pib_t; | ||
|  | 
 | ||
|  | /* descriptor of 698 protocol sta collect parameter layout structure in PIB */ | ||
|  | typedef struct _iot_sg_698_clct_param_pib { | ||
|  |     /* 0 - disabled, 1 - enabled */ | ||
|  |     uint8_t             enabled     :1, | ||
|  |     /* if sta clct param is valid, 0 invalid, 1 valid */ | ||
|  |                         valid       :1, | ||
|  |     /* three phase meter value */ | ||
|  |                         three_value :1, | ||
|  |                         rsvd        :5; | ||
|  |     /* unit is 1min */ | ||
|  |     uint8_t             clct_period; | ||
|  |     /* di count of single phase meter */ | ||
|  |     uint8_t             di_cnt_single; | ||
|  |     /* di result total length of single phase meter */ | ||
|  |     uint8_t             di_result_len_single; | ||
|  |     /* di information of single phase meter */ | ||
|  |     iot_sg_di_info_pib_t di_single[IOT_SG_STA_CLCT_DI_CNT_SINGLE_698]; | ||
|  |     /* di count of three phase meter */ | ||
|  |     uint8_t             di_cnt_three; | ||
|  |     /* di result total length of three phase meter */ | ||
|  |     uint8_t             di_result_len_three; | ||
|  |     /* di information of three phase meter */ | ||
|  |     iot_sg_di_info_pib_t di_three[IOT_SG_STA_CLCT_DI_CNT_THREE_698]; | ||
|  |     /* reserved */ | ||
|  |     uint8_t             reserved[50]; | ||
|  |     /* the crc of collect parameter,
 | ||
|  |      * for verifying whether local parameter and cctt's parameter are the same. | ||
|  |      */ | ||
|  |     uint32_t            crc; | ||
|  | } iot_sg_698_clct_param_pib_t; | ||
|  | 
 | ||
|  | /* descriptor of sta collect parameter layout head structure v2.8 in PIB */ | ||
|  | typedef struct _iot_sg_clct_param_v28_hdr_pib { | ||
|  |     /* 645 protocol sta collect parameter */ | ||
|  |     iot_sg_645_clct_param_pib_t         clct_param_645; | ||
|  |     /* 698 protocol sta collect parameter */ | ||
|  |     iot_sg_698_clct_param_pib_t         clct_param_698; | ||
|  | } iot_sg_clct_param_v28_hdr_pib_t; | ||
|  | 
 | ||
|  | /* set score parameter */ | ||
|  | typedef struct _iot_sg_cco_score_parameter { | ||
|  |     /* flag to mark if score report enable */ | ||
|  |     uint8_t                 score_enable_flag; | ||
|  |     /* score report threshold value */ | ||
|  |     uint8_t                 score_threshold; | ||
|  |     /* if 0 - every day start, others - every month start. BIN format */ | ||
|  |     uint8_t                 day; | ||
|  |     /* BIN format */ | ||
|  |     uint8_t                 hour; | ||
|  |     /* BIN format */ | ||
|  |     uint8_t                 minute; | ||
|  | } iot_sg_score_parameter_t; | ||
|  | 
 | ||
|  | typedef struct _iot_sg_uart_config_param_pib { | ||
|  |     /* uart baud rate type, see IOT_SG_CCO_BAUD_IDX_XXX */ | ||
|  |     uint8_t                 baud_rate       :4, | ||
|  |                             rsvd1           :3, | ||
|  |     /* if uart baud rate type is vaild */ | ||
|  |                             baud_rate_vaild :1; | ||
|  |     /* uart baud rate recover time, unit is 1min */ | ||
|  |     uint16_t                rec_time; | ||
|  |     /* hardware reset cnt for error baud rate */ | ||
|  |     uint8_t                 reset_cnt; | ||
|  |     /* uart max baud rate type, see IOT_SG_CCO_BAUD_XXX */ | ||
|  |     uint8_t                 max_baud_rate   :4, | ||
|  |                             rsvd2           :3, | ||
|  |     /* if uart max baud rate type is vaild */ | ||
|  |                             max_baud_vaild  :1; | ||
|  |     uint8_t                 rsvd3[4]; | ||
|  | } iot_sg_uart_config_param_pib_t; | ||
|  | 
 | ||
|  | typedef struct _iot_sg_module_reset_info { | ||
|  |     /* power down event valid time, unit is 1s, default 5s. */ | ||
|  |     uint8_t                 pd_valid_time; | ||
|  |     /* module power down count */ | ||
|  |     uint16_t                pd_cnt; | ||
|  | } iot_sg_module_reset_info_t; | ||
|  | 
 | ||
|  | typedef struct _iot_sg_vendor_device_sn_info { | ||
|  |     /* vendor device sn length */ | ||
|  |     uint8_t vendor_device_sn_len; | ||
|  |     /* vendor device sn info */ | ||
|  |     uint8_t vendor_device_sn_info[IOT_SG_VENDOR_DEVICE_SN_LEN]; | ||
|  | } iot_sg_vendor_device_sn_info_t; | ||
|  | 
 | ||
|  | typedef struct _iot_sg_bcast_collect_task_t { | ||
|  |     /* save task bitmap */ | ||
|  |     uint8_t task_bitmap[2]; | ||
|  |     /* save collect task info */ | ||
|  |     uint8_t task_info[IOT_SG_BCAST_CLCT_MAX_CNT][IOT_SG_CLCT_DATA_MAX_LENGTH]; | ||
|  | } iot_sg_bcast_collect_task_t; | ||
|  | 
 | ||
|  | typedef struct _iot_sg_cco_feature { | ||
|  |     /* white list state, see IOT_CLI_SG_WL_STATE_XXX */ | ||
|  |     uint32_t    whitelist_state             :2, | ||
|  |     /* support protocol version id, see IOT_SG_CCO_CCTT_PROTO_XXX */ | ||
|  |                 cctt_proto                  :3, | ||
|  |     /* national standard 14H_F01 enable, 09 standard normally use this */ | ||
|  |                 en_cco_active_read_meter    :1, | ||
|  |     /* save white list in flash */ | ||
|  |                 en_save_whitelist           :1, | ||
|  |     /* event report disabled flag: 1 - disabled, 0 - allowed */ | ||
|  |                 evt_rpt_disabled            :1, | ||
|  |     /* south china certification mode */ | ||
|  |                 en_sp_cert_mode             :1, | ||
|  |     /* module on line with module addr only, not use meter address */ | ||
|  |                 en_use_module_addr_only     :1, | ||
|  |     /* secondary node monitor timeout limit in second */ | ||
|  |                 sec_node_monitor_timeout    :16, | ||
|  |     /* whether enable transformer detect */ | ||
|  |                 tsfm_detect_enable          :1, | ||
|  |     /* used for esp code */ | ||
|  |                 month_flag                  :1, | ||
|  |     /* see IOT_SG_CCO_ESP_XXX */ | ||
|  |                 esp_code                    :4; | ||
|  |     /* bcast interval table */ | ||
|  |     uint8_t     bcast_interval_table        :2, | ||
|  |     /* meter reading only, no other works */ | ||
|  |                 mr_only_enable              :1, | ||
|  |     /* link load level */ | ||
|  |                 link_load_level             :2, | ||
|  |     /* timer restart network */ | ||
|  |                 timer_restart_nw            :1, | ||
|  |     /* force cco for single mode type */ | ||
|  |                 force_single_type           :1, | ||
|  |     /* rsvd */ | ||
|  |                 rsvd                        :1; | ||
|  | } iot_sg_cco_feature_t; | ||
|  | 
 | ||
|  | typedef struct _iot_sg_sta_feature { | ||
|  |     /* 13 new standard */ | ||
|  |     uint32_t    en_np_13_3762               :1, | ||
|  |     /* 09 old standard */ | ||
|  |                 en_np_09_3762               :1, | ||
|  |     /* 2016 south standard */ | ||
|  |                 en_sp_2016                  :1, | ||
|  |     /* national certification mode */ | ||
|  |                 en_np_cert_mode             :1, | ||
|  |     /* south china certification mode */ | ||
|  |                 en_sp_cert_mode             :1, | ||
|  |     /* module on line with module addr only, not use meter address */ | ||
|  |                 en_use_module_addr_only     :1, | ||
|  |     /* pm driver detect mode select, if set, the pm driver will check whether it
 | ||
|  |      * is a type I collector. | ||
|  |      */ | ||
|  |                 pm_detect_mpde_sel          :1, | ||
|  |     /* only for type II collector, whether enable meter search for 97 protocols.
 | ||
|  |      * 1-enable. | ||
|  |      */ | ||
|  |                 ct2_sm97_en                 :1, | ||
|  | 
 | ||
|  |     /* if set, if detect done multiple times without meter detected, allow use
 | ||
|  |      * module address to  join the network first. | ||
|  |      */ | ||
|  |                 allow_use_module_addr       :1, | ||
|  |     /* reserved for future use */ | ||
|  |                 rsvd0                       :4, | ||
|  |     /* only for type II collector. if set, if detect done one time without meter
 | ||
|  |      * detected, not allow use virtual meter address to join the network first. | ||
|  |      */ | ||
|  |                 ct2_virtual_disable         :1, | ||
|  |     /* only for meter. if set, meter extended function enable.
 | ||
|  |      */ | ||
|  |                 en_ext_func                 :1, | ||
|  |     /* hardware tsfm detecting mode, see IOT_SG_STA_HW_TSFM_MODE_XXX */ | ||
|  |                 hw_tsfm_mode                :2, | ||
|  |     /* reserved for future use */ | ||
|  |                 rsvd1                       :4, | ||
|  |     /* only for type II collector. if set, if detect done one time without meter
 | ||
|  |      * detected, allow use collector address to join the network first. Its | ||
|  |      * priority is higher than ct2_virtual mode. | ||
|  |      */ | ||
|  |                 ct2_collector_addr_en       :1, | ||
|  |     /* reserved for future use */ | ||
|  |                 reserve                     :10; | ||
|  | } iot_sg_sta_feature_t; | ||
|  | 
 | ||
|  | /* cco role common configuration definition */ | ||
|  | typedef struct _iot_sg_cco_cmn_cfg { | ||
|  |     /* enabled features */ | ||
|  |     iot_sg_cco_feature_t    fr; | ||
|  | } iot_sg_cco_cmn_cfg_t; | ||
|  | 
 | ||
|  | /* app layer CCO role read-only section layout in PIB */ | ||
|  | typedef struct _iot_sg_cco_app_pib_ro { | ||
|  |     /* common configuration */ | ||
|  |     iot_sg_cco_cmn_cfg_t    cfg; | ||
|  | } iot_sg_cco_app_pib_ro_t; | ||
|  | 
 | ||
|  | /* sta collect parameter data v2.8 in PIB */ | ||
|  | typedef struct _iot_sg_clct_param_v28_info { | ||
|  |     /* sta collect parameter data v2.8 */ | ||
|  |     iot_sg_clct_param_v28_hdr_pib_t clct_param_v28[IOT_SG_STA_CLCT_MAX_TASK_CNT]; | ||
|  |     /* sta collect parameter task id bitmap v2.8, correspond to white list */ | ||
|  |     uint8_t     clct_task_id_bitmap[IOT_SG_APP_WL_MAX_NUM]; | ||
|  | } iot_sg_clct_param_v28_info_t; | ||
|  | 
 | ||
|  | typedef struct _iot_sg_edge_computing_pib { | ||
|  |     /* flag to mark if edge computing set enable */ | ||
|  |     uint8_t      edge_computing_enable          : 1, | ||
|  |     /* overvoltage monitor switch, 0 - open, others - close */ | ||
|  |                  overvoltage_switch             : 1, | ||
|  |     /* undervoltage monitor switch, 0 - open, others - close */ | ||
|  |                  undervoltage_switch            : 1, | ||
|  |     /* clock second pulse monitor switch, 0 - open, others - close */ | ||
|  |                  pulse_switch                   : 1, | ||
|  |     /* power meter health status monitor switch,  0 - open, others - close */ | ||
|  |                  health_status_switch           : 1, | ||
|  |    /* reserved for future */ | ||
|  |                  rsvd                           : 3; | ||
|  |     /* overvoltage monitor threshold, unit is volt */ | ||
|  |     uint16_t     overvoltage_threshold; | ||
|  |     /* overvoltage monitor period, unit is 1min */ | ||
|  |     uint16_t     overvoltage_period; | ||
|  |     /* overvoltage collect abnormal report round */ | ||
|  |     uint8_t      overvoltage_rpt_round; | ||
|  |     /* undervoltage monitor threshold, unit is volt */ | ||
|  |     uint16_t     undervoltage_threshold; | ||
|  |     /* undervoltage monitor period, unit is 1min */ | ||
|  |     uint16_t     undervoltage_period; | ||
|  |     /* undervoltage collect abnormal report round */ | ||
|  |     uint8_t      undervoltage_rpt_round; | ||
|  |     /* clock second pulse monitor threshold, unit is 1ms */ | ||
|  |     uint16_t     pulse_threshold; | ||
|  |     /* power meter used time limit threshold, unit is year */ | ||
|  |     uint8_t      used_limit_threshold; | ||
|  | } iot_sg_edge_computing_pib_t; | ||
|  | 
 | ||
|  | /* app layer CCO role writable section layout in PIB */ | ||
|  | typedef struct _iot_sg_cco_app_pib_rw { | ||
|  |     /* white list info */ | ||
|  |     iot_sg_wl_pib_entry_t   white_list[IOT_SG_APP_WL_MAX_NUM]; | ||
|  |     /* secondary node monitor timeout limit in second, set by cctt */ | ||
|  |     uint32_t    sec_node_monitor_timeout   :16, | ||
|  |     /* event report disabled flag: 1 - disabled, 0 - allowed. */ | ||
|  |                 evt_rpt_disabled           :1, | ||
|  |     /* white list state, see IOT_CLI_SG_WL_STATE_XXX */ | ||
|  |                 whitelist_state            :2, | ||
|  |     /* equipment service provider, see IOT_SG_CCO_ESP_XXX */ | ||
|  |                 esp_code                   :6, | ||
|  |     /* sec node register active auto */ | ||
|  |                 auto_reg_active            :1, | ||
|  |     /* zc notify valid flag, 0 - invalid, 1 - valid */ | ||
|  |                 zc_notify_valid            :1, | ||
|  |     /* zc notify enable: 0 - disabled, 1 - enable */ | ||
|  |                 zc_notify_enable           :1, | ||
|  |     /* abnormal electric current report enable for neutralwire and livewire */ | ||
|  |                 nli_enable                 :1, | ||
|  |     /* reserved for future use */ | ||
|  |                 reserve                    :3; | ||
|  |     /* major node mac for driver */ | ||
|  |     uint8_t     major_node_mac[IOT_MAC_ADDR_LEN]; | ||
|  |     /* magic marker */ | ||
|  |     uint32_t    mark_magic; | ||
|  |     /* bcast meter reading max concurrent count */ | ||
|  |     uint8_t     max_bcast_con_count; | ||
|  |     /* secondary node monitor timeout limit in second, set by cli */ | ||
|  |     uint16_t    sec_node_monitor_timeout_cli; | ||
|  |     /* correct time interval, unit is 1ms */ | ||
|  |     uint32_t    correct_sta_time_interval; | ||
|  |     /* 645 protocol sta collect parameter */ | ||
|  |     iot_sg_645_clct_param_pib_t clct_param_645; | ||
|  |     /* bcast collect task */ | ||
|  |     iot_sg_bcast_collect_task_t collect_task; | ||
|  |     /* pm score parameter */ | ||
|  |     iot_sg_score_parameter_t score_param; | ||
|  |     /* 698 protocol sta collect parameter */ | ||
|  |     iot_sg_698_clct_param_pib_t clct_param_698; | ||
|  |     /* uart config parameter */ | ||
|  |     iot_sg_uart_config_param_pib_t uart_param; | ||
|  |     /* module reset infomation */ | ||
|  |     iot_sg_module_reset_info_t reset_info; | ||
|  |     /* if the value is valid the repeater in the range are allowed to join
 | ||
|  |      * network. | ||
|  |      * if the value is invalid then all repeater are allowed to join network. | ||
|  |      * | ||
|  |      * 00:00:00:00:00:00 and FF:FF:FF:FF:FF:FF are invalid data. | ||
|  |      * big-endian. | ||
|  |      */ | ||
|  |     uint8_t     repeater_addr_start[IOT_MAC_ADDR_LEN]; | ||
|  |     uint8_t     repeater_addr_end[IOT_MAC_ADDR_LEN]; | ||
|  |     /* vendor device sn infomation */ | ||
|  |     iot_sg_vendor_device_sn_info_t vendor_device_sn; | ||
|  |     /* diff data valid index, 0 is invalid */ | ||
|  |     uint8_t     diff_valid_index; | ||
|  |     union { | ||
|  |         /* diff data max length */ | ||
|  |         uint8_t diff_max[IOT_SG_PIB_DIFF_DATA_MAX_LEN]; | ||
|  |         iot_sg_clct_param_v28_info_t  clct_param_info; | ||
|  |     } diff; | ||
|  |     iot_sg_edge_computing_pib_t     edge_set_info; | ||
|  |     /* driver specific persistent storage */ | ||
|  |     uint8_t drv[IOT_PIB_CCO_APP_WRITE_SECTION_SIZE - \ | ||
|  |         sizeof(iot_sg_wl_pib_entry_t) * IOT_SG_APP_WL_MAX_NUM - \ | ||
|  |         sizeof(uint32_t) - \ | ||
|  |         IOT_MAC_ADDR_LEN - \ | ||
|  |         sizeof(uint32_t) - \ | ||
|  |         sizeof(uint8_t) - \ | ||
|  |         sizeof(uint16_t) - \ | ||
|  |         sizeof(uint32_t) - \ | ||
|  |         sizeof(iot_sg_645_clct_param_pib_t) - \ | ||
|  |         sizeof(iot_sg_bcast_collect_task_t) - \ | ||
|  |         sizeof(iot_sg_score_parameter_t) - \ | ||
|  |         sizeof(iot_sg_698_clct_param_pib_t) - \ | ||
|  |         sizeof(iot_sg_uart_config_param_pib_t) - \ | ||
|  |         sizeof(iot_sg_module_reset_info_t) - \ | ||
|  |         IOT_MAC_ADDR_LEN - \ | ||
|  |         IOT_MAC_ADDR_LEN - \ | ||
|  |         sizeof(iot_sg_vendor_device_sn_info_t) - \ | ||
|  |         sizeof(uint8_t) - \ | ||
|  |         IOT_SG_PIB_DIFF_DATA_MAX_LEN -\ | ||
|  |         sizeof(iot_sg_edge_computing_pib_t)]; | ||
|  | } iot_sg_cco_app_pib_rw_t; | ||
|  | 
 | ||
|  | /* sta role common configuration definition */ | ||
|  | typedef struct _iot_sg_sta_cmn_cfg { | ||
|  |     /* enabled features */ | ||
|  |     iot_sg_sta_feature_t    fr; | ||
|  |     /* driver id, see IOT_SG_STA_DRV_ID_XXX */ | ||
|  |     uint8_t                 drv_id; | ||
|  | } iot_sg_sta_cmn_cfg_t; | ||
|  | 
 | ||
|  | /* app layer STA role read-only section layout in PIB */ | ||
|  | typedef struct _iot_sg_sta_app_pib_ro { | ||
|  |     /* common configuration */ | ||
|  |     iot_sg_sta_cmn_cfg_t    cfg; | ||
|  | } iot_sg_sta_app_pib_ro_t; | ||
|  | 
 | ||
|  | /* app layer STA role save info */ | ||
|  | typedef struct _iot_sg_sta_app_info { | ||
|  |     /* flag of sta power off event */ | ||
|  |     uint8_t power_off_flag      : 1, | ||
|  |     /* flag of power off event time valid */ | ||
|  |             power_off_time_flag : 1, | ||
|  |     /* flag of meter phase. 1 mean that meter is three phase meter,
 | ||
|  |      * 0 mean that meter is not three phase meter and when module type is | ||
|  |      * power meter flag is available. | ||
|  |      */ | ||
|  |             is_three_phase      : 1, | ||
|  |     /* flag of lock time valid */ | ||
|  |             lock_time_flag      : 1, | ||
|  |     /* flag to mark if enable join check, 1 - enable, 0 - disable */ | ||
|  |             join_check          : 1, | ||
|  |     /* parent address type, see IOT_SG_STA_PA_ADDR_TYPE_XXX */ | ||
|  |             pa_type             : 2, | ||
|  |     /* flag of auto correct time */ | ||
|  |             auto_corr           : 1; | ||
|  |     /* extend load curve period, uint is 1min */ | ||
|  |     uint8_t ext_lr_period; | ||
|  |     /* delta mode, 0 - default mode, 1 - hlj mode */ | ||
|  |     uint16_t delta_mode         : 1, | ||
|  |     /* delta threshold, uint is 1 min */ | ||
|  |              delta_threshold    : 10, | ||
|  |     /* extend neutral wire and live wire abnormal detect,
 | ||
|  |      * 0 - disable, 1 - enable. | ||
|  |      */ | ||
|  |              ext_nli_en         : 1, | ||
|  |     /* flag ext_nli_en valid */ | ||
|  |              ext_nli_valid      : 1, | ||
|  |     /* reserve for future */ | ||
|  |              reserve            : 3; | ||
|  |     /* tsfm address, little-endian */ | ||
|  |     uint8_t tsfm_addr[IOT_MAC_ADDR_LEN]; | ||
|  |     /* physical phase */ | ||
|  |     uint8_t phase; | ||
|  |     /* parent address, little-endian */ | ||
|  |     uint8_t parent_addr[IOT_MAC_ADDR_LEN]; | ||
|  |     /* power off event time */ | ||
|  |     uint16_t power_off_year; | ||
|  |     uint8_t power_off_mon; | ||
|  |     uint8_t power_off_day; | ||
|  |     uint8_t power_off_hour; | ||
|  |     uint8_t power_off_min; | ||
|  |     uint8_t power_off_sec; | ||
|  |     /* the delta time between correct time and RTC, uint is 1s */ | ||
|  |     int64_t tm_sta_delta; | ||
|  |     /* last delta time pm address, big-endian */ | ||
|  |     uint8_t pm_addr[IOT_MAC_ADDR_LEN]; | ||
|  |     /* 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_sta_app_info_t; | ||
|  | 
 | ||
|  | /* app layer STA role writable section layout in PIB */ | ||
|  | typedef struct _iot_sg_sta_app_pib_rw { | ||
|  |     iot_sg_sta_app_info_t     sta; | ||
|  |       /* driver specific persistent storage */ | ||
|  |     uint8_t     drv[IOT_PIB_STA_APP_WRITE_SECTION_SIZE - \ | ||
|  |         sizeof(iot_sg_sta_app_info_t)]; | ||
|  | } iot_sg_sta_app_pib_rw_t; | ||
|  | 
 | ||
|  | /* app layer read-only section layout in PIB */ | ||
|  | typedef struct _iot_sg_app_pib_ro { | ||
|  |     /* cco configuration */ | ||
|  |     iot_sg_cco_app_pib_ro_t cco_pib; | ||
|  |     /* power meter configuration */ | ||
|  |     iot_sg_sta_app_pib_ro_t pm_pib; | ||
|  |     /* type ii collector configuration */ | ||
|  |     iot_sg_sta_app_pib_ro_t ct2_pib; | ||
|  |     /* sta test configuration */ | ||
|  |     iot_sg_sta_app_pib_ro_t sta_test_pib; | ||
|  | } iot_sg_app_pib_ro_t; | ||
|  | 
 | ||
|  | #pragma pack(pop)
 | ||
|  | 
 | ||
|  | /* CCO access handle descriptor */ | ||
|  | typedef  struct _iot_sg_cco_app_pib { | ||
|  |     /* pointer to read-only section of CCO in PIB */ | ||
|  |     iot_sg_cco_app_pib_ro_t *ro; | ||
|  |     /* pointer to writable section of CCO in PIB */ | ||
|  |     iot_sg_cco_app_pib_rw_t *rw; | ||
|  | } iot_sg_cco_app_pib_t; | ||
|  | 
 | ||
|  | /* STA access handle descriptor */ | ||
|  | typedef  struct _iot_sg_sta_app_pib { | ||
|  |     /* pointer to read-only section of STA in PIB */ | ||
|  |     iot_sg_sta_app_pib_ro_t *ro; | ||
|  |     /* pointer to writable section of STA in PIB */ | ||
|  |     iot_sg_sta_app_pib_rw_t *rw; | ||
|  | } iot_sg_sta_app_pib_t; | ||
|  | 
 | ||
|  | 
 | ||
|  | #ifdef __cplusplus
 | ||
|  | } | ||
|  | #endif
 | ||
|  | 
 | ||
|  | #endif  /* IOT_SG_CFG_H */
 | ||
|  | 
 |