481 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			481 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								/****************************************************************************
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
							 | 
						||
| 
								 | 
							
								be copied by any method or incorporated into another program without
							 | 
						||
| 
								 | 
							
								the express written consent of Aerospace C.Power. This Information or any portion
							 | 
						||
| 
								 | 
							
								thereof remains the property of Aerospace C.Power. The Information contained herein
							 | 
						||
| 
								 | 
							
								is believed to be accurate and Aerospace C.Power assumes no responsibility or
							 | 
						||
| 
								 | 
							
								liability for its use in any way and conveys no license or title under
							 | 
						||
| 
								 | 
							
								any patent or copyright and makes no representation or warranty that this
							 | 
						||
| 
								 | 
							
								Information is free from patent or copyright infringement.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								****************************************************************************/
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifndef PROTO_645_TOPO_H
							 | 
						||
| 
								 | 
							
								#define PROTO_645_TOPO_H
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "iot_utils_api.h"
							 | 
						||
| 
								 | 
							
								#include "iot_sg_sta_tsfm.h"
							 | 
						||
| 
								 | 
							
								#include "iot_sg_proto.h"
							 | 
						||
| 
								 | 
							
								#include "iot_plc_hw_tsfm_api.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* definition branch recognition response result code */
							 | 
						||
| 
								 | 
							
								#define PROTO_645_2007_EXT_BR_RESULT_OK           0
							 | 
						||
| 
								 | 
							
								#define PROTO_645_2007_EXT_BR_RESULT_BUSY         1
							 | 
						||
| 
								 | 
							
								#define PROTO_645_2007_EXT_BR_RESULT_NOSUPP       2
							 | 
						||
| 
								 | 
							
								#define PROTO_645_2007_EXT_BR_RESULT_INVAL        3
							 | 
						||
| 
								 | 
							
								#define PROTO_645_2007_EXT_BR_RESULT_FAIL         4
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* define the description information version of the meters under
							 | 
						||
| 
								 | 
							
								 * the meter box
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define PROTO_645_EXT_BR_PM_INFO_V0               0
							 | 
						||
| 
								 | 
							
								#define PROTO_645_EXT_BR_PM_INFO_V1               1
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma pack(push)      /* save the pack status */
							 | 
						||
| 
								 | 
							
								#pragma pack(1)         /* 1 byte align */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* branch recognition meter query payload */
							 | 
						||
| 
								 | 
							
								typedef struct _proto_645_ext_br_meter_query {
							 | 
						||
| 
								 | 
							
								    /* data block sequence */
							 | 
						||
| 
								 | 
							
								    uint8_t  block_seq;
							 | 
						||
| 
								 | 
							
								    /* query message version, see PROTO_645_EXT_BR_PM_INFO_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t  ver    : 2,
							 | 
						||
| 
								 | 
							
								    /* reserved for further use */
							 | 
						||
| 
								 | 
							
								             rsvd   : 6;
							 | 
						||
| 
								 | 
							
								} proto_645_ext_br_meter_query_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* branch recognition response data payload */
							 | 
						||
| 
								 | 
							
								typedef struct _proto_645_ext_br_rsp_data {
							 | 
						||
| 
								 | 
							
								    /* DI */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    /* response result, see PROTO_645_2007_EXT_BR_RESULT_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t result                  :4,
							 | 
						||
| 
								 | 
							
								    /* data format. 0 mean data structure is bitmap format,
							 | 
						||
| 
								 | 
							
								     * see proto_645_ext_br_info_rsp_t. 1 mean data structure is energy list,
							 | 
						||
| 
								 | 
							
								     * see proto_645_ext_br_energy_rsp_t.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								            format                  :1,
							 | 
						||
| 
								 | 
							
								    /* reserved */
							 | 
						||
| 
								 | 
							
								            reserved                :3;
							 | 
						||
| 
								 | 
							
								    /* recognition response data */
							 | 
						||
| 
								 | 
							
								    uint8_t data[0];
							 | 
						||
| 
								 | 
							
								} proto_645_ext_br_rsp_data_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* branch recognition energy uint */
							 | 
						||
| 
								 | 
							
								typedef struct _proto_645_ext_br_energy_unit {
							 | 
						||
| 
								 | 
							
								    /* sn */
							 | 
						||
| 
								 | 
							
								    uint16_t sn;
							 | 
						||
| 
								 | 
							
								    /* energy */
							 | 
						||
| 
								 | 
							
								    uint16_t energy;
							 | 
						||
| 
								 | 
							
								} proto_645_ext_br_energy_unit_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* branch recognition energy uint for Beijing*/
							 | 
						||
| 
								 | 
							
								typedef struct _proto_645_ext_br_energy_unit_bj {
							 | 
						||
| 
								 | 
							
								    /* sn */
							 | 
						||
| 
								 | 
							
								    uint16_t     sn;
							 | 
						||
| 
								 | 
							
								    /* energy, unit: 0.0001A*/
							 | 
						||
| 
								 | 
							
								    uint16_t     energy;
							 | 
						||
| 
								 | 
							
								    /* reserved for further use */
							 | 
						||
| 
								 | 
							
								    uint8_t      rsvd[2];
							 | 
						||
| 
								 | 
							
								} proto_645_ext_br_energy_unit_bj_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* branch recognition information response */
							 | 
						||
| 
								 | 
							
								typedef struct _proto_645_ext_br_info_rsp {
							 | 
						||
| 
								 | 
							
								    /* branch recognition data block total */
							 | 
						||
| 
								 | 
							
								    uint8_t data_block_total;
							 | 
						||
| 
								 | 
							
								    /* response data block sequence */
							 | 
						||
| 
								 | 
							
								    uint8_t data_block_seq          :6,
							 | 
						||
| 
								 | 
							
								    /* phase type, see PROTO_645_2007_EXT_BRM_PHASE_XXX */
							 | 
						||
| 
								 | 
							
								            phase_type              :2;
							 | 
						||
| 
								 | 
							
								    /* bitmap data len, include the start_index */
							 | 
						||
| 
								 | 
							
								    uint8_t bm_data_len;
							 | 
						||
| 
								 | 
							
								    /* start index */
							 | 
						||
| 
								 | 
							
								    uint16_t start_index;
							 | 
						||
| 
								 | 
							
								    /* bitmap */
							 | 
						||
| 
								 | 
							
								    uint8_t bitmap[0];
							 | 
						||
| 
								 | 
							
								} proto_645_ext_br_info_rsp_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* branch recognition energy information response */
							 | 
						||
| 
								 | 
							
								typedef struct _proto_645_ext_br_energy_rsp {
							 | 
						||
| 
								 | 
							
								    /* branch recognition data block total */
							 | 
						||
| 
								 | 
							
								    uint8_t data_block_total;
							 | 
						||
| 
								 | 
							
								    /* response data block sequence */
							 | 
						||
| 
								 | 
							
								    uint8_t data_block_seq          :6,
							 | 
						||
| 
								 | 
							
								    /* phase type, see PROTO_645_2007_EXT_BRM_PHASE_XXX */
							 | 
						||
| 
								 | 
							
								            phase_type              :2;
							 | 
						||
| 
								 | 
							
								    /* energy cnt */
							 | 
						||
| 
								 | 
							
								    uint8_t energy_cnt;
							 | 
						||
| 
								 | 
							
								    /* energy list */
							 | 
						||
| 
								 | 
							
								    proto_645_ext_br_energy_unit_t energy_list[0];
							 | 
						||
| 
								 | 
							
								} proto_645_ext_br_energy_rsp_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* branch recognition info query payload for Beijing*/
							 | 
						||
| 
								 | 
							
								typedef struct _proto_645_ext_br_info_query_bj {
							 | 
						||
| 
								 | 
							
								    /* index to read from the result list */
							 | 
						||
| 
								 | 
							
								    uint16_t     start_index;
							 | 
						||
| 
								 | 
							
								    /* number of energy information to read */
							 | 
						||
| 
								 | 
							
								    uint8_t      num;
							 | 
						||
| 
								 | 
							
								    /* reserve for future */
							 | 
						||
| 
								 | 
							
								    uint8_t      rsvd[13];
							 | 
						||
| 
								 | 
							
								} proto_645_ext_br_info_query_bj_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* branch recognition energy information response for Beijing*/
							 | 
						||
| 
								 | 
							
								typedef struct _proto_645_ext_br_energy_rsp_bj {
							 | 
						||
| 
								 | 
							
								    /* total number of physical topology IDs received */
							 | 
						||
| 
								 | 
							
								    uint16_t      total_number;
							 | 
						||
| 
								 | 
							
								    /* start index */
							 | 
						||
| 
								 | 
							
								    uint16_t      start_index;
							 | 
						||
| 
								 | 
							
								    /* the number of physical topology IDs reported this time */
							 | 
						||
| 
								 | 
							
								    uint8_t       report_number;
							 | 
						||
| 
								 | 
							
								    /* energy list */
							 | 
						||
| 
								 | 
							
								    proto_645_ext_br_energy_unit_bj_t energy_list[0];
							 | 
						||
| 
								 | 
							
								} proto_645_ext_br_energy_rsp_bj_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* query neighbor network node info down-link.
							 | 
						||
| 
								 | 
							
								 * for PROTO_645_2007_EXT_DI_NEI_NODE_INFO
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								typedef struct _proto_645_07_ext_brm_nei_node_info_dl {
							 | 
						||
| 
								 | 
							
								    /* packet serial number of neighbor network node info */
							 | 
						||
| 
								 | 
							
								    uint8_t sn;
							 | 
						||
| 
								 | 
							
								} proto_645_07_ext_brm_nei_node_info_dl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma pack(pop)   /* restore the pack status */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define PROTO_645_VENDOR_BR_DATA_LEN sizeof(proto_hw_tsfm_hdr_t) + \
							 | 
						||
| 
								 | 
							
								    sizeof(proto_hw_tsfm_topo_sn_t)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief proto_645_vendor_build_br_launch_req() - create a branch recognition
							 | 
						||
| 
								 | 
							
								 *     launch message for the 645 protocol.
							 | 
						||
| 
								 | 
							
								 * @param addr:        address of meter, little endian.
							 | 
						||
| 
								 | 
							
								 * @param fwd_addr:    forward node addr, valid in connectionless, little endian
							 | 
						||
| 
								 | 
							
								 * @param node_seq:    node sequence number.
							 | 
						||
| 
								 | 
							
								 * @param ahead:       ahead interval time.
							 | 
						||
| 
								 | 
							
								 * @param dur_output:  duration of bit data output.
							 | 
						||
| 
								 | 
							
								 * @param repeat_cnt:  repeat cnt.
							 | 
						||
| 
								 | 
							
								 * @param send_mode:   send mode, see IOT_PLC_HW_TSFM_SEND_MODE_XXX.
							 | 
						||
| 
								 | 
							
								 * @param launch_sn:   launch sequence number.
							 | 
						||
| 
								 | 
							
								 * @param pa_freq:     power amplifier hw tsfm mode encode frequency,
							 | 
						||
| 
								 | 
							
								 *                     unit is 75MHz/(1 << 14).
							 | 
						||
| 
								 | 
							
								 * @retval: NULL    -- for failure case.
							 | 
						||
| 
								 | 
							
								 * @retval: pkt     -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_launch_req(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint8_t *fwd_addr, uint16_t node_seq, uint16_t ahead, uint16_t dur_output,
							 | 
						||
| 
								 | 
							
								    uint8_t repeat_cnt, uint8_t send_mode, uint8_t launch_sn, uint16_t pa_freq);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* proto_645_vendor_build_br_launch_state_req() - create a branch recognition
							 | 
						||
| 
								 | 
							
								 * launch state query message for the 645 protocol.
							 | 
						||
| 
								 | 
							
								 * @param addr: address of meter, little endian.
							 | 
						||
| 
								 | 
							
								 * @param fwd_addr: forward node addr, valid in connectionless, little endian.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL    -- for failure case.
							 | 
						||
| 
								 | 
							
								 * @retval: pkt     -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_launch_state_req(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint8_t *fwd_addr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* proto_645_vendor_build_br_info_query_req() - create a branch recognition
							 | 
						||
| 
								 | 
							
								 *                                              information query message
							 | 
						||
| 
								 | 
							
								 *                                              for the 645 protocol.
							 | 
						||
| 
								 | 
							
								 * @addr:        address of meter.
							 | 
						||
| 
								 | 
							
								 * @seq:         data block sequence number.
							 | 
						||
| 
								 | 
							
								 * @phase_type   phase type, see PROTO_645_2007_EXT_BRM_PHASE_XXX
							 | 
						||
| 
								 | 
							
								 * return
							 | 
						||
| 
								 | 
							
								 *    NULL    -- for failure case.
							 | 
						||
| 
								 | 
							
								 *    pkt     -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_info_query_req(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint8_t seq, uint8_t phase_type);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* proto_645_vendor_build_br_tsfm_addr_clear_req() - create a branch recognition
							 | 
						||
| 
								 | 
							
								 *                                              information clear tsfm addr
							 | 
						||
| 
								 | 
							
								 *                                              for the 645 protocol.
							 | 
						||
| 
								 | 
							
								 * @addr:        address of meter.
							 | 
						||
| 
								 | 
							
								 * return
							 | 
						||
| 
								 | 
							
								 *    NULL    -- for failure case.
							 | 
						||
| 
								 | 
							
								 *    pkt     -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_tsfm_addr_clear_req(uint8_t *addr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* proto_645_vendor_build_br_info_clean_req() - create a branch recognition
							 | 
						||
| 
								 | 
							
								 *                                              information clean message
							 | 
						||
| 
								 | 
							
								 *                                              for the 645 protocol.
							 | 
						||
| 
								 | 
							
								 * @addr:           address of meter.
							 | 
						||
| 
								 | 
							
								 * @phase_type:     phase type, see PROTO_645_2007_EXT_BRM_PHASE_XXX.
							 | 
						||
| 
								 | 
							
								 * @param pa_freq:  power amplifier hw tsfm mode encode frequency,
							 | 
						||
| 
								 | 
							
								 *                  unit is 75MHz/(1 << 14).
							 | 
						||
| 
								 | 
							
								 * return
							 | 
						||
| 
								 | 
							
								 *    NULL    -- for failure case.
							 | 
						||
| 
								 | 
							
								 *    pkt     -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_info_clean_req(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint8_t send_phase, uint16_t pa_freq);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* @brief proto_645_vendor_build_br_nei_node_info_query_req() - create a branch
							 | 
						||
| 
								 | 
							
								 * recognition information query neighbor node info for the 645 protocol.
							 | 
						||
| 
								 | 
							
								 * @param addr: address of meter.
							 | 
						||
| 
								 | 
							
								 * @param seq: data block sequence number.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL -- for failure case.
							 | 
						||
| 
								 | 
							
								 * @retval: pkt  -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_nei_node_info_query_req(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint8_t seq);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* @brief proto_645_vendor_build_br_tsfm_info_query_req() - create a branch
							 | 
						||
| 
								 | 
							
								 * recognition info query neighbor node tsfm detect info for the 645 protocol.
							 | 
						||
| 
								 | 
							
								 * @param addr: address of meter, little endian.
							 | 
						||
| 
								 | 
							
								 * @param fwd_addr: forward node addr, valid in connectionless, little endian.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL -- for failure case.
							 | 
						||
| 
								 | 
							
								 * @retval: pkt  -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_tsfm_info_query_req(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint8_t *fwd_addr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* proto_645_vendor_build_br_meter_info_query_req() - create a branch
							 | 
						||
| 
								 | 
							
								 *                                                    recognition information
							 | 
						||
| 
								 | 
							
								 *                                                    query meter for the
							 | 
						||
| 
								 | 
							
								 *                                                    645 protocol.
							 | 
						||
| 
								 | 
							
								 * @addr:        address of meter.
							 | 
						||
| 
								 | 
							
								 * @seq:         data block sequence number.
							 | 
						||
| 
								 | 
							
								 * @ver:         query message version, see PROTO_645_EXT_BR_PM_INFO_VX;
							 | 
						||
| 
								 | 
							
								 * return
							 | 
						||
| 
								 | 
							
								 *    NULL    -- for failure case.
							 | 
						||
| 
								 | 
							
								 *    pkt     -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_meter_info_query_req(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint8_t seq, uint8_t ver);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* proto_645_vendor_build_br_info_add_pm_req() - create a branch recognition
							 | 
						||
| 
								 | 
							
								 * information set meter info for the 645 protocol.
							 | 
						||
| 
								 | 
							
								 * @addr:   address of meter, little endian.
							 | 
						||
| 
								 | 
							
								 * @data:   pointer to protocol data buffer.
							 | 
						||
| 
								 | 
							
								 * @len:    data length.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL -- for failure case.
							 | 
						||
| 
								 | 
							
								 * @retval: pkt  -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_info_add_pm_req(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if IOT_SMART_GTID_BRANCH_DETECT_SUPPORT_BJ
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief proto_645_vendor_build_br_launch_req_bj() - create a branch
							 | 
						||
| 
								 | 
							
								 *        recognition launch message for the 645 protocol for beijing
							 | 
						||
| 
								 | 
							
								 * @param addr:        address of meter, little endian.
							 | 
						||
| 
								 | 
							
								 * @param node_seq:    node sequence number.
							 | 
						||
| 
								 | 
							
								 * @param bit_dur:     characteristics data per bit duration time, unit: 1ms.
							 | 
						||
| 
								 | 
							
								 * @param high_dur:    modulate pulse signal high duration time, unit: 1us.
							 | 
						||
| 
								 | 
							
								 * @param low_dur:     modulate pulse signal low duration time, unit: 1us.
							 | 
						||
| 
								 | 
							
								 * @param launch_sn:   launch sequence number.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL    -- for failure case.
							 | 
						||
| 
								 | 
							
								 * @retval: pkt     -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_launch_req_bj(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint16_t node_seq, uint16_t bit_dur, uint16_t high_dur, uint16_t low_dur,
							 | 
						||
| 
								 | 
							
								    uint8_t launch_sn);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief proto_645_vendor_build_br_info_query_req_bj() - create a branch
							 | 
						||
| 
								 | 
							
								 *        recognition information query message for the 645 protocol for beijing
							 | 
						||
| 
								 | 
							
								 * @param addr:        address of meter.
							 | 
						||
| 
								 | 
							
								 * @param start_idx:   index to read from the result list.
							 | 
						||
| 
								 | 
							
								 * @param num          number of energy information to read.
							 | 
						||
| 
								 | 
							
								 * @retval NULL -- for failure case.
							 | 
						||
| 
								 | 
							
								 * @retval pkt  -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_info_query_req_bj(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint16_t start_idx, uint8_t num);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief proto_645_vendor_build_br_info_clean_req_bj() - create a branch
							 | 
						||
| 
								 | 
							
								 *        recognition information clean message for the 645 protocol for beijing
							 | 
						||
| 
								 | 
							
								 * @param addr:       address of meter.
							 | 
						||
| 
								 | 
							
								 * @param bit_dur:    characteristics data per bit duration time, unit: 1ms.
							 | 
						||
| 
								 | 
							
								 * @param freq: modulate pulse signal frequence, little endian, uint: 0.01Hz.
							 | 
						||
| 
								 | 
							
								 * @retval NULL -- for failure case.
							 | 
						||
| 
								 | 
							
								 * @retval pkt  -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_info_clean_req_bj(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint16_t bit_dur, uint32_t freq);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#else /* IOT_SMART_GTID_BRANCH_DETECT_SUPPORT_BJ */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define proto_645_vendor_build_br_launch_req_bj(addr, node_seq, bit_dur, \
							 | 
						||
| 
								 | 
							
								    high_dur, low_dur, launch_sn) NULL
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define proto_645_vendor_build_br_info_query_req_bj(addr, start_idx, num) NULL
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define proto_645_vendor_build_br_info_clean_req_bj(addr, bit_dur, freq) NULL
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* IOT_SMART_GTID_BRANCH_DETECT_SUPPORT_BJ */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if IOT_SMART_GTID_BRANCH_DETECT_SUPPORT_ZJ
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief proto_645_vendor_build_br_launch_req_zj() - create a branch
							 | 
						||
| 
								 | 
							
								 *        recognition launch message for the 645 protocol for beijing
							 | 
						||
| 
								 | 
							
								 * @param addr:        address of meter, little endian.
							 | 
						||
| 
								 | 
							
								 * @param bit_dur:     characteristics data per bit duration time, unit: 1ms.
							 | 
						||
| 
								 | 
							
								 * @param high_dur:    modulate pulse signal high duration time, unit: 1us.
							 | 
						||
| 
								 | 
							
								 * @param low_dur:     modulate pulse signal low duration time, unit: 1us.
							 | 
						||
| 
								 | 
							
								 * @param freq: modulate pulse signal frequence, little endian, uint: 0.01Hz.
							 | 
						||
| 
								 | 
							
								 * @param code:        launch code.
							 | 
						||
| 
								 | 
							
								 * @param code_len:    length of launch code.
							 | 
						||
| 
								 | 
							
								 * @param timep:       scheduled launch time.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL    -- for failure case.
							 | 
						||
| 
								 | 
							
								 * @retval: pkt     -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_launch_req_zj(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint16_t bit_dur, uint16_t high_dur, uint16_t low_dur, uint32_t freq,
							 | 
						||
| 
								 | 
							
								    uint8_t *code, uint8_t code_len, proto_645_07_time_ymdhms_t *timep);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief proto_645_vendor_build_br_info_query_zj_req() - create a branch
							 | 
						||
| 
								 | 
							
								 *        recognition information query message for the 645 protocol for zhejiang
							 | 
						||
| 
								 | 
							
								 * @param addr:        address of meter.
							 | 
						||
| 
								 | 
							
								 * @param start_idx:   index to read from the result list.
							 | 
						||
| 
								 | 
							
								 * @param cnt:         how many records to read.
							 | 
						||
| 
								 | 
							
								 * @param timep:       starting time for reading records.
							 | 
						||
| 
								 | 
							
								 * @retval pkt  -- the iot pkt buffer for 645 protocol.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_build_br_info_query_req_zj(uint8_t *addr,
							 | 
						||
| 
								 | 
							
								    uint16_t start_idx, uint8_t cnt, proto_645_corr_time_t *start_time);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#else
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define proto_645_vendor_build_br_launch_req_zj(addr, bit_dur, high_dur, \
							 | 
						||
| 
								 | 
							
								    low_dur, freq, code, code_len, timep) NULL
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define proto_645_vendor_build_br_info_query_req_zj(addr, start_idx, cnt, \
							 | 
						||
| 
								 | 
							
								    start_time) NULL
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* proto_645_vendor_br_rsp_check() - check branch recognition
							 | 
						||
| 
								 | 
							
								 *                                   response 645 extend protocol.
							 | 
						||
| 
								 | 
							
								 * @hdr:    645 frame header pointer
							 | 
						||
| 
								 | 
							
								 * @br_rsp: branch recognition response data.
							 | 
						||
| 
								 | 
							
								 * return
							 | 
						||
| 
								 | 
							
								 *    ERR_OK    --  success.
							 | 
						||
| 
								 | 
							
								 *    otherwise --  fail.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t proto_645_vendor_br_rsp_check(proto_645_header_t *hdr,
							 | 
						||
| 
								 | 
							
								    proto_645_ext_br_rsp_cache_t *br_rsp);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* proto_645_vendor_br_rsp_check() - check branch recognition connectionless
							 | 
						||
| 
								 | 
							
								 * forward response 645 extend protocol.
							 | 
						||
| 
								 | 
							
								 * @data: pointer, point to data buffer addr. input original data, if a forward
							 | 
						||
| 
								 | 
							
								 * message, output the forwarded data.
							 | 
						||
| 
								 | 
							
								 * @data_len: pointer, point to data length addr, input original data length, if
							 | 
						||
| 
								 | 
							
								 * a forward message, output the forwarded data length.
							 | 
						||
| 
								 | 
							
								 * @retval: ERR_OK     -- successful.
							 | 
						||
| 
								 | 
							
								 * @retval: otherwise  -- failure, see ERR_XXX.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t proto_645_vendor_conn_fwd_br_rsp_check(uint8_t **data,
							 | 
						||
| 
								 | 
							
								    uint32_t *data_len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief send brm launch data.
							 | 
						||
| 
								 | 
							
								 * @param hdr: br lanunch req 645 protocol header.
							 | 
						||
| 
								 | 
							
								 * @param di:  rsp 645 packet di.
							 | 
						||
| 
								 | 
							
								 * @param flag_addr_check:  flag of address check.
							 | 
						||
| 
								 | 
							
								 * @retval: rsp pkt packet -- successful.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL  -- failure.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_handle_br_launch_req(
							 | 
						||
| 
								 | 
							
								    proto_645_header_t *hdr, uint32_t di, uint8_t flag_addr_check);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief get brm launch state.
							 | 
						||
| 
								 | 
							
								 * @param hdr: br lanunch req 645 protocol header.
							 | 
						||
| 
								 | 
							
								 * @param di:  rsp 645 packet di.
							 | 
						||
| 
								 | 
							
								 * @param flag_addr_check:  flag of address check.
							 | 
						||
| 
								 | 
							
								 * @retval: rsp pkt packet -- successful.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL  -- failure.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_handle_br_launch_state_req(
							 | 
						||
| 
								 | 
							
								    proto_645_header_t *hdr, uint32_t di, uint8_t flag_addr_check);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief query brm launch info for Beijing.
							 | 
						||
| 
								 | 
							
								 * @param hdr: br lanunch req 645 protocol header.
							 | 
						||
| 
								 | 
							
								 * @retval: rsp pkt packet -- successful.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL  -- failure.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_handle_br_info_query_req_bj(
							 | 
						||
| 
								 | 
							
								    proto_645_header_t *hdr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief query brm launch info.
							 | 
						||
| 
								 | 
							
								 * @param hdr: br lanunch req 645 protocol header.
							 | 
						||
| 
								 | 
							
								 * @param di:  rsp 645 packet di.
							 | 
						||
| 
								 | 
							
								 * @param flag_addr_check:  flag of address check.
							 | 
						||
| 
								 | 
							
								 * @retval: rsp pkt packet -- successful.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL  -- failure.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_handle_br_info_query_req(
							 | 
						||
| 
								 | 
							
								    proto_645_header_t *hdr, uint32_t di, uint8_t flag_addr_check);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief clean brm launch.
							 | 
						||
| 
								 | 
							
								 * @param hdr: br lanunch req 645 protocol header.
							 | 
						||
| 
								 | 
							
								 * @param di:  rsp 645 packet di.
							 | 
						||
| 
								 | 
							
								 * @param flag_addr_check:  flag of address check.
							 | 
						||
| 
								 | 
							
								 * @retval: rsp pkt packet -- successful.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL  -- failure.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_handle_br_info_clean_req(
							 | 
						||
| 
								 | 
							
								    proto_645_header_t *hdr, uint32_t di, uint8_t flag_addr_check);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief proto_645_vendor_br_launch() - send br data.
							 | 
						||
| 
								 | 
							
								 * @param data: pointer to data sent.
							 | 
						||
| 
								 | 
							
								 * @param len:  length of data.
							 | 
						||
| 
								 | 
							
								 * @param cfg:  configuration of sending.
							 | 
						||
| 
								 | 
							
								 * @retval: ERR_OK     -- successful.
							 | 
						||
| 
								 | 
							
								 * @retval: otherwise  -- failure, see ERR_XXX.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t proto_645_vendor_br_launch(uint8_t *data, uint8_t len,
							 | 
						||
| 
								 | 
							
								    hw_tsfm_send_cfg_t *cfg);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief send br test command.
							 | 
						||
| 
								 | 
							
								 * @param hdr: br lanunch req 645 protocol header.
							 | 
						||
| 
								 | 
							
								 * @param di:  rsp 645 packet di.
							 | 
						||
| 
								 | 
							
								 * @retval: ERR_OK     -- successful.
							 | 
						||
| 
								 | 
							
								 * @retval: otherwise  -- failure, see ERR_XXX.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_handle_br_test_req(
							 | 
						||
| 
								 | 
							
								    proto_645_header_t *hdr, uint32_t di);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief query br test reasult.
							 | 
						||
| 
								 | 
							
								 * @param hdr: br lanunch req 645 protocol header.
							 | 
						||
| 
								 | 
							
								 * @param di:  rsp 645 packet di.
							 | 
						||
| 
								 | 
							
								 * @retval: ERR_OK     -- successful.
							 | 
						||
| 
								 | 
							
								 * @retval: otherwise  -- failure, see ERR_XXX.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_handle_br_test_query_req(
							 | 
						||
| 
								 | 
							
								    proto_645_header_t *hdr, uint32_t di);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief initialize receiving device.
							 | 
						||
| 
								 | 
							
								 * @param hdr: br info req 645 protocol header.
							 | 
						||
| 
								 | 
							
								 * @retval: rsp pkt packet -- successful.
							 | 
						||
| 
								 | 
							
								 * @retval: NULL  -- failure.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								iot_pkt_t *proto_645_vendor_handle_br_recv_init_bj(proto_645_header_t *hdr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* PROTO_645_TOPO_H */
							 |