497 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			497 lines
		
	
	
		
			13 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_PROTO_CCTT_H
							 | 
						||
| 
								 | 
							
								#define IOT_PROTO_CCTT_H
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "iot_proto_dl645.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/************ mini cctt command   *****************************************/
							 | 
						||
| 
								 | 
							
								/* cctt add whitelist */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_ADD_WHITELISET              (0x08000000u)
							 | 
						||
| 
								 | 
							
								/* cctt delete whitelist */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_DEL_WHITELISET              (0x08000001u)
							 | 
						||
| 
								 | 
							
								/* cctt query whitelist */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_QUERY_WHITELIST             (0x08000002u)
							 | 
						||
| 
								 | 
							
								/* cctt reboot */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_REBOOT_CCTT                 (0x08000003u)
							 | 
						||
| 
								 | 
							
								/* cctt reboot cco */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_REBOOT_CCO                  (0x08000004u)
							 | 
						||
| 
								 | 
							
								/* cctt reboot sta */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_REBOOT_STA                  (0x08000005u)
							 | 
						||
| 
								 | 
							
								/* cctt set or query whitelist state */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_WL_STATE                    (0x08000006u)
							 | 
						||
| 
								 | 
							
								/* cctt clear whitelist */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_CLEAR_WL                    (0x08000007u)
							 | 
						||
| 
								 | 
							
								/* cctt check mac in whitelist */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_CHECK_WL_ADDR               (0x08000008u)
							 | 
						||
| 
								 | 
							
								/* cctt query topo */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_QUERY_TOPO                  (0x08000009u)
							 | 
						||
| 
								 | 
							
								/* set parameter of rs485 */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_RS485_CONFIG                (0x0800000Cu)
							 | 
						||
| 
								 | 
							
								/* dl645 include dl645 frame */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_TRANS_DL645                 (0x0800000Du)
							 | 
						||
| 
								 | 
							
								/* dl645 include modbus frame */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_TRANS_MODBUS                (0x0800000Eu)
							 | 
						||
| 
								 | 
							
								/* enable or disable plc network */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_HANDLE_PLC_NW               (0x08000014u)
							 | 
						||
| 
								 | 
							
								/* find mac_list pco reboot */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_REBOOT_MAC_LIST_PCO         (0x08000015u)
							 | 
						||
| 
								 | 
							
								/* get delaytime */
							 | 
						||
| 
								 | 
							
								#define DL645_07_DI_DELAYTIME                   (0x08000016u)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**************************************************************************/
							 | 
						||
| 
								 | 
							
								#define IOT_CCTT_CACHE_PCO_CNT                  (36)
							 | 
						||
| 
								 | 
							
								#define IOT_CCTT_RS485_CACHE_SIZE               (256)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma pack(push)  // save the pack status
							 | 
						||
| 
								 | 
							
								#pragma pack(1)     // 1 byte align
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* add whitelist */
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_set_whitelist_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    /* password */
							 | 
						||
| 
								 | 
							
								    uint32_t passwd;
							 | 
						||
| 
								 | 
							
								    uint32_t user_code;
							 | 
						||
| 
								 | 
							
								    uint8_t  seq;
							 | 
						||
| 
								 | 
							
								    uint8_t  cnt;
							 | 
						||
| 
								 | 
							
								    uint8_t  mac[0][IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} cctt_set_whitelist_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_reboot_cco_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    /* password */
							 | 
						||
| 
								 | 
							
								    uint32_t passwd;
							 | 
						||
| 
								 | 
							
								    uint32_t user_code;
							 | 
						||
| 
								 | 
							
								    uint8_t  resv;
							 | 
						||
| 
								 | 
							
								} cctt_reboot_cco_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_reboot_sta_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    /* password */
							 | 
						||
| 
								 | 
							
								    uint32_t passwd;
							 | 
						||
| 
								 | 
							
								    uint32_t user_code;
							 | 
						||
| 
								 | 
							
								    uint8_t  mac[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} cctt_reboot_sta_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_set_wl_state_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    /* password */
							 | 
						||
| 
								 | 
							
								    uint32_t passwd;
							 | 
						||
| 
								 | 
							
								    uint32_t user_code;
							 | 
						||
| 
								 | 
							
								    /* 0: disable 1:enable */
							 | 
						||
| 
								 | 
							
								    uint8_t  state;
							 | 
						||
| 
								 | 
							
								} cctt_set_wl_state_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_clear_whitelist_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    /* password */
							 | 
						||
| 
								 | 
							
								    uint32_t passwd;
							 | 
						||
| 
								 | 
							
								    uint32_t user_code;
							 | 
						||
| 
								 | 
							
								    uint8_t  resv;
							 | 
						||
| 
								 | 
							
								} cctt_clear_whitelist_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_query_whitelist_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    uint16_t start;
							 | 
						||
| 
								 | 
							
								    uint16_t cnt;
							 | 
						||
| 
								 | 
							
								} cctt_query_whitelist_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_resp_whitelist_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    uint16_t total_cnt;
							 | 
						||
| 
								 | 
							
								    uint8_t  mac[0][IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} cctt_resp_whitelist_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_resp_whitelist_withseq_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    uint8_t  mac[0][IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} cctt_resp_whitelist_withseq_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_check_whitelist_mac_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    /* password */
							 | 
						||
| 
								 | 
							
								    uint32_t passwd;
							 | 
						||
| 
								 | 
							
								    uint32_t user_code;
							 | 
						||
| 
								 | 
							
								    uint8_t  mac[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} cctt_check_whitelist_mac_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_query_topo_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    uint16_t start;
							 | 
						||
| 
								 | 
							
								    uint16_t cnt;
							 | 
						||
| 
								 | 
							
								    /* query topo type */
							 | 
						||
| 
								 | 
							
								    uint8_t  q_ver;
							 | 
						||
| 
								 | 
							
								} cctt_query_topo_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _node_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    uint8_t    level;
							 | 
						||
| 
								 | 
							
								    uint8_t    mac[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} node_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_resp_topo_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    uint16_t total_cnt;
							 | 
						||
| 
								 | 
							
								    /* query topo type */
							 | 
						||
| 
								 | 
							
								    uint8_t  q_ver;
							 | 
						||
| 
								 | 
							
								    node_t   node[0];
							 | 
						||
| 
								 | 
							
								} cctt_resp_topo_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_set_plc_net_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    /* password */
							 | 
						||
| 
								 | 
							
								    uint32_t passwd;
							 | 
						||
| 
								 | 
							
								    /* user code */
							 | 
						||
| 
								 | 
							
								    uint32_t user_code;
							 | 
						||
| 
								 | 
							
								    /* 0:disable plc network,1:enable plc network */
							 | 
						||
| 
								 | 
							
								    uint8_t action;
							 | 
						||
| 
								 | 
							
								} cctt_set_plc_net_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* reboot pco */
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_reboot_mac_list_pco_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    /* password */
							 | 
						||
| 
								 | 
							
								    uint32_t passwd;
							 | 
						||
| 
								 | 
							
								    /* user code */
							 | 
						||
| 
								 | 
							
								    uint32_t user_code;
							 | 
						||
| 
								 | 
							
								    /* set command seq, when seq equal to 0 execute */
							 | 
						||
| 
								 | 
							
								    uint8_t  seq;
							 | 
						||
| 
								 | 
							
								    /* mac count for mac list */
							 | 
						||
| 
								 | 
							
								    uint8_t  cnt;
							 | 
						||
| 
								 | 
							
								    /* mac list */
							 | 
						||
| 
								 | 
							
								    uint8_t  mac[0][IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} cctt_reboot_mac_list_pco_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_delaytime_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    ge_delay_tm_test_t time_info;
							 | 
						||
| 
								 | 
							
								} cctt_delaytime_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_set_rs485_cfg_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    /* user */
							 | 
						||
| 
								 | 
							
								    uint32_t user;
							 | 
						||
| 
								 | 
							
								    /* password */
							 | 
						||
| 
								 | 
							
								    uint32_t password;
							 | 
						||
| 
								 | 
							
								    /* baudrate */
							 | 
						||
| 
								 | 
							
								    uint32_t baudrate;
							 | 
						||
| 
								 | 
							
								    /* parity:0=none, 1=odd, 2=even */
							 | 
						||
| 
								 | 
							
								    uint8_t  parity;
							 | 
						||
| 
								 | 
							
								    /* data bits, 5/6/7/8 */
							 | 
						||
| 
								 | 
							
								    uint8_t  databits;
							 | 
						||
| 
								 | 
							
								    /* stop bits, 1=one bit, 2=two bit */
							 | 
						||
| 
								 | 
							
								    uint8_t  stopbits;
							 | 
						||
| 
								 | 
							
								} cctt_set_rs485_cfg_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_read_rs485_cfg_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* di */
							 | 
						||
| 
								 | 
							
								    uint32_t di;
							 | 
						||
| 
								 | 
							
								    /* baudrate */
							 | 
						||
| 
								 | 
							
								    uint32_t baudrate;
							 | 
						||
| 
								 | 
							
								    /* parity:0=none, 1=odd, 2=even */
							 | 
						||
| 
								 | 
							
								    uint8_t  parity;
							 | 
						||
| 
								 | 
							
								    /* data bits, 5/6/7/8 */
							 | 
						||
| 
								 | 
							
								    uint8_t  databits;
							 | 
						||
| 
								 | 
							
								    /* stop bits, 1=one bit, 2=two bit */
							 | 
						||
| 
								 | 
							
								    uint8_t  stopbits;
							 | 
						||
| 
								 | 
							
								} cctt_read_rs485_cfg_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* cctt report sta event */
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_rpt_sta_evt_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    uint8_t  mac[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* sta join(1) or leave(2) */
							 | 
						||
| 
								 | 
							
								    uint8_t  event;
							 | 
						||
| 
								 | 
							
								} cctt_rpt_sta_evt_t ;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* cctt local rs485 port management struct */
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_local_rs485_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* rs485 handler */
							 | 
						||
| 
								 | 
							
								    iot_uart_h handler;
							 | 
						||
| 
								 | 
							
								    /* rs485 is ready or not */
							 | 
						||
| 
								 | 
							
								    bool_t     ready;
							 | 
						||
| 
								 | 
							
								    /* rs485 data cache */
							 | 
						||
| 
								 | 
							
								    os_mutex_h cache_mutex;
							 | 
						||
| 
								 | 
							
								    /* data length of rs485 data cache */
							 | 
						||
| 
								 | 
							
								    uint8_t    cache_len;
							 | 
						||
| 
								 | 
							
								    /* rs485 cache buffer */
							 | 
						||
| 
								 | 
							
								    uint8_t    cache[IOT_CCTT_RS485_CACHE_SIZE];
							 | 
						||
| 
								 | 
							
								    /* timestamp of rs485 received data */
							 | 
						||
| 
								 | 
							
								    uint64_t   recv_ts;
							 | 
						||
| 
								 | 
							
								    /* rs485 led gpio pin */
							 | 
						||
| 
								 | 
							
								    uint8_t    rs485_led_pin;
							 | 
						||
| 
								 | 
							
								} cctt_local_rs485_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* cctt record data info */
							 | 
						||
| 
								 | 
							
								typedef struct _cctt_context_t
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /* query whitelist seq, for dl645 query next cmd  */
							 | 
						||
| 
								 | 
							
								    uint8_t  q_wl_seq;
							 | 
						||
| 
								 | 
							
								    /* query topo seq, for dl645 query next cmd */
							 | 
						||
| 
								 | 
							
								    uint8_t  q_topo_seq;
							 | 
						||
| 
								 | 
							
								    /* mark of wl list query postion for cvg layer.
							 | 
						||
| 
								 | 
							
								     * continue call cvg with this mark untill finish.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint16_t q_wl_pos;
							 | 
						||
| 
								 | 
							
								    /* query whitelist cnt, for dl645 query next cmd  */
							 | 
						||
| 
								 | 
							
								    uint16_t q_wl_cnt;
							 | 
						||
| 
								 | 
							
								    /* query topo result handle, 0=report topo, 1=report online */
							 | 
						||
| 
								 | 
							
								    uint8_t q_topo_rpt_online;
							 | 
						||
| 
								 | 
							
								    /* query topo type, for dl645 query next cmd  */
							 | 
						||
| 
								 | 
							
								    uint8_t q_topo_type;
							 | 
						||
| 
								 | 
							
								    /* mark of topo result query postion for cvg layer.
							 | 
						||
| 
								 | 
							
								     * continue call cvg with this mark untill finish.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint16_t q_topo_pos;
							 | 
						||
| 
								 | 
							
								    /* query topo cnt, for dl645 query next cmd  */
							 | 
						||
| 
								 | 
							
								    uint16_t q_topo_cnt;
							 | 
						||
| 
								 | 
							
								    /* plc network state, open or close */
							 | 
						||
| 
								 | 
							
								    uint8_t plc_nw_state;
							 | 
						||
| 
								 | 
							
								    /* store pco count for reboot */
							 | 
						||
| 
								 | 
							
								    uint8_t  pco_cnt;
							 | 
						||
| 
								 | 
							
								    uint8_t  q_delaytime_seq;
							 | 
						||
| 
								 | 
							
								    /* store pco mac list for reboot */
							 | 
						||
| 
								 | 
							
								    uint8_t  pco_list[IOT_CCTT_CACHE_PCO_CNT][IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} cctt_context_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma pack(pop)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if PLC_SUPPORT_CCO_ROLE
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_handle_local_dl645_cmd() - handle the local cmd
							 | 
						||
| 
								 | 
							
								 *                                           data is del 0x33
							 | 
						||
| 
								 | 
							
								 * @param pkt:   point to the dl645 pkt data
							 | 
						||
| 
								 | 
							
								 * @return: 0 success, others false
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cctt_handle_local_dl645_cmd(iot_pkt_t *pkt);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_set_whitelist() - cctt set whitelist to cco
							 | 
						||
| 
								 | 
							
								 * @param data:   point to the data for set whitelist
							 | 
						||
| 
								 | 
							
								 * @param len:    data length
							 | 
						||
| 
								 | 
							
								 * @param action: 0 - delete, 1 - add.
							 | 
						||
| 
								 | 
							
								 * @return: 0 success, others false
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cctt_set_whitelist(uint8_t *data, uint8_t len, uint8_t action);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_reboot_cco() - cctt reboot cco
							 | 
						||
| 
								 | 
							
								 * @param data:   point to the data for reboot cco
							 | 
						||
| 
								 | 
							
								 * @param len:    data length
							 | 
						||
| 
								 | 
							
								 * @return: 0 success, others false
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cctt_reboot_cco(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_reboot_cco() - cctt reboot sta
							 | 
						||
| 
								 | 
							
								 * @param data:   point to the data for reboot sta
							 | 
						||
| 
								 | 
							
								 * @param len:    data length
							 | 
						||
| 
								 | 
							
								 * @return: 0 success, others false
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cctt_reboot_sta(uint8_t *cmd, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_reboot_cco() - cctt set whitelist state enable/disable
							 | 
						||
| 
								 | 
							
								 * @param data:   point to the data for set whitelist state
							 | 
						||
| 
								 | 
							
								 * @param len:    data length
							 | 
						||
| 
								 | 
							
								 * @return: 0 success, others false
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cctt_set_wl_state(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_clear_whitelist() - cctt clean whitelist
							 | 
						||
| 
								 | 
							
								 * @param data:   point to the data for clean whitelist
							 | 
						||
| 
								 | 
							
								 * @param len:    data length
							 | 
						||
| 
								 | 
							
								 * @return: 0 success, others false
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cctt_clear_whitelist(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_read_whitelist() - cctt read whitelist
							 | 
						||
| 
								 | 
							
								 * @param data:   point to the data for read whitelist
							 | 
						||
| 
								 | 
							
								 * @param len:    data length
							 | 
						||
| 
								 | 
							
								 * @return: 0 success, others false
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cctt_read_whitelist(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_check_whitelist_mac() - cctt check mac is in whitelist or not
							 | 
						||
| 
								 | 
							
								 * @param data:   point to the data for check mac is in whitelist
							 | 
						||
| 
								 | 
							
								 * @param len:    data length
							 | 
						||
| 
								 | 
							
								 * @return: 0 success, others false
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cctt_check_whitelist_mac(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cco_resp_topo_to_cctt() - cco response topo to cctt
							 | 
						||
| 
								 | 
							
								 * @param resp_node:   point to response node info
							 | 
						||
| 
								 | 
							
								 * @param total_cnt:   total count
							 | 
						||
| 
								 | 
							
								 * @param cur_cnt:     current count
							 | 
						||
| 
								 | 
							
								 * @param flow:        not report done
							 | 
						||
| 
								 | 
							
								 * @return: 0 success, others false
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cco_resp_topo_to_cctt(plctxrx_cmd_topov2_t *resp_node,
							 | 
						||
| 
								 | 
							
								    uint16_t total_cnt, uint16_t cur_cnt, uint8_t flow);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_query_topo() - cctt query topo info
							 | 
						||
| 
								 | 
							
								 * @param data:   point to the data for query topo
							 | 
						||
| 
								 | 
							
								 * @param len:    data length
							 | 
						||
| 
								 | 
							
								 * @return: 0 success, others false
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cctt_query_topo(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* cco respone topo info set query info */
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cco_resp_topo_set_query_info() - cco set query topo index
							 | 
						||
| 
								 | 
							
								 * @param done:        query topo done or not
							 | 
						||
| 
								 | 
							
								 * @param resp_cnt:    response topo count
							 | 
						||
| 
								 | 
							
								 * @return: 0 success, others false
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cco_resp_topo_set_query_info(uint8_t done, uint16_t resp_cnt);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_set_plc_nw() - enable or disable plc network, used by cco
							 | 
						||
| 
								 | 
							
								 * @param data:   point to the data for handle network
							 | 
						||
| 
								 | 
							
								 * @param len:    data length
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void iot_cctt_set_plc_nw(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_get_plc_nw() - check the plc network is open or close
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void iot_cctt_get_plc_nw(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_reboot_mac_list_pco() - reboot mac list pco
							 | 
						||
| 
								 | 
							
								 * @param data:   point to the data for reboot pco
							 | 
						||
| 
								 | 
							
								 * @param len:    data length
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void iot_cctt_reboot_mac_list_pco(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_cctt_delaytime() - cctt pack dl645 delaytime to txrx
							 | 
						||
| 
								 | 
							
								 * @param data:   point to the data of dl645
							 | 
						||
| 
								 | 
							
								 * @param len:    data length
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void iot_cctt_delaytime(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief: set configuration of rs485 interface by dl645 protocol
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @param data: dl645 request data
							 | 
						||
| 
								 | 
							
								 * @param len : length of dl645 request data
							 | 
						||
| 
								 | 
							
								 * @return none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void iot_cctt_set_rs485_config(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief: readout configuration of rs485 interface by dl645 protocol
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @param data: dl645 request data
							 | 
						||
| 
								 | 
							
								 * @param len : length of dl645 request data
							 | 
						||
| 
								 | 
							
								 * @return none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void iot_cctt_read_rs485_config(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief: transparent transmit dl645 frame to cctt local rs485,
							 | 
						||
| 
								 | 
							
								 *         then reply dl645 response
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @param data : data to transparent transmit to rs485
							 | 
						||
| 
								 | 
							
								 * @param len  : length of data
							 | 
						||
| 
								 | 
							
								 * @return none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void iot_cctt_rs485_trans_dl645(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief: transparent transmit modbus frame to cctt local rs485,
							 | 
						||
| 
								 | 
							
								 *         then reply modbus response
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @param data : data to transparent transmit to rs485
							 | 
						||
| 
								 | 
							
								 * @param len  : length of data
							 | 
						||
| 
								 | 
							
								 * @return none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void iot_cctt_rs485_trans_modbus(uint8_t *data, uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief: report sta join or leave event
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @param p_mac: mac address of sta device
							 | 
						||
| 
								 | 
							
								 * @param evt  : event of sta device, 1=join, 2=leave
							 | 
						||
| 
								 | 
							
								 * @return : 0 if success, 1 when failed
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cctt_report_sta_event(uint8_t *p_mac, uint8_t evt);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief: request online sta device report online to server
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @param none
							 | 
						||
| 
								 | 
							
								 * @return 0 if success, 1 when failed
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t iot_cctt_req_online_sta_report(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief ccct_init() - initialize cctt information, such as plc_nw_state
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cctt_init(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* PLC_SUPPORT_CCO_ROLE */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* end IOT_PROTO_CCTT_H */
							 |