91 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			91 lines
		
	
	
		
			3.2 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_ATCMD_PROC_H_
							 | 
						||
| 
								 | 
							
								#define _IOT_ATCMD_PROC_H_
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* common includes */
							 | 
						||
| 
								 | 
							
								#include "iot_utils_api.h"
							 | 
						||
| 
								 | 
							
								#include "iot_plc_msg_cco_api.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								  extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define ATCMD_BUF_MAX_LEN               (512)
							 | 
						||
| 
								 | 
							
								#define ATCMD_SEND_MAX                  (512)
							 | 
						||
| 
								 | 
							
								#define ATCMD_STR_BUF_LEN               (ATCMD_SEND_MAX * 2 + \
							 | 
						||
| 
								 | 
							
								                                            IOT_SNIFFER_STR_HEAD_LEN)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define ATCMD_HEX_FLAG                  (0)
							 | 
						||
| 
								 | 
							
								#define ATCMD_STRING_FLAG               (1)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define ATCMD_MAXARGS                   (20)
							 | 
						||
| 
								 | 
							
								#define ATCMD_QUERY_FLAG                (1)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void iot_atcmd_printf(const char *fmt, ...);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define AT_RESP(fmt, ...)          iot_atcmd_printf(fmt, ##__VA_ARGS__)
							 | 
						||
| 
								 | 
							
								#define AT_RESP_OK()               iot_atcmd_printf("OK\r\n\r\n")
							 | 
						||
| 
								 | 
							
								#define AT_RESP_ERROR()            iot_atcmd_printf("ERROR\r\n\r\n")
							 | 
						||
| 
								 | 
							
								#define AT_RESP_FAIL()             iot_atcmd_printf("FAILED\r\n\r\n")
							 | 
						||
| 
								 | 
							
								#define AT_RESP_EQU(cmd,fmt, ...)  iot_atcmd_printf("+"cmd":"fmt, ##__VA_ARGS__)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define AT_ARRAY_COUNT(x)          (sizeof(x) / sizeof((x)[0]))
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef enum {
							 | 
						||
| 
								 | 
							
								    AT_RET_OK   = 0x00,
							 | 
						||
| 
								 | 
							
								    AT_RET_ERR  = 0x01,
							 | 
						||
| 
								 | 
							
								    AT_RET_FAIL = 0x02,
							 | 
						||
| 
								 | 
							
								    AT_RET_NULL
							 | 
						||
| 
								 | 
							
								} AT_RET;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef AT_RET (*at_call_back_func)(uint16_t argc, char *argv[]);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct {
							 | 
						||
| 
								 | 
							
								    char *name;                     /* Command Name */
							 | 
						||
| 
								 | 
							
								    uint16_t maxargs;               /* Maximum Number of Arguments */
							 | 
						||
| 
								 | 
							
								    at_call_back_func test_cmd;     /* AT Test Command */
							 | 
						||
| 
								 | 
							
								    at_call_back_func query_cmd;    /* AT Query Command */
							 | 
						||
| 
								 | 
							
								    at_call_back_func setup_cmd;    /* AT Setup Command */
							 | 
						||
| 
								 | 
							
								    at_call_back_func exe_cmd;      /* AT EXE Command */
							 | 
						||
| 
								 | 
							
								    char *usage;                    /* Usage Message */
							 | 
						||
| 
								 | 
							
								    uint8_t is_remote;              /* Is Support Remote Command */
							 | 
						||
| 
								 | 
							
								} cmd_tbl_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma pack(push)  // save the pack status
							 | 
						||
| 
								 | 
							
								#pragma pack(1)     // 1 byte align
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct {
							 | 
						||
| 
								 | 
							
								    uint32_t mcu_tx_time;   /* mcu transmit time (us) */
							 | 
						||
| 
								 | 
							
								    uint32_t cco_tx_time;   /* cco transmit time (us) */
							 | 
						||
| 
								 | 
							
								    uint32_t sta_rx_time;   /* cco receive time (us) */
							 | 
						||
| 
								 | 
							
								    uint32_t sta_tx_time;   /* sta transmit time (us) */
							 | 
						||
| 
								 | 
							
								    uint32_t cco_rx_time;   /* sta receive time (us) */
							 | 
						||
| 
								 | 
							
								    uint16_t datalen;       /* data lenth */
							 | 
						||
| 
								 | 
							
								    uint8_t reserve[0];     /* reserve */
							 | 
						||
| 
								 | 
							
								} delay_time_test;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma pack(pop)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void iot_sniffer_fix_send_atcmd_data(iot_plc_msdu_app_sniffer_recv_t *msdu);
							 | 
						||
| 
								 | 
							
								void iot_atcmd_parse_handle(uint8_t *buffer, uint32_t buffer_len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								 }
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif  /* _IOT_ATCMD_PROC_H_ */
							 |