MeterLogger
at_custom.h
Go to the documentation of this file.
1 /*
2  * ESPRSSIF MIT License
3  *
4  * Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
5  *
6  * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
7  * it is free of charge, to any person obtaining a copy of this software and associated
8  * documentation files (the "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11  * to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or
14  * substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  */
24 
25 #ifndef CUSTOM_AT_H_
26 #define CUSTOM_AT_H_
27 
28 #include "c_types.h"
29 
30 typedef struct
31 {
32  char *at_cmdName;
33  int8_t at_cmdLen;
34  void (*at_testCmd)(uint8_t id);
35  void (*at_queryCmd)(uint8_t id);
36  void (*at_setupCmd)(uint8_t id, char *pPara);
37  void (*at_exeCmd)(uint8_t id);
39 
40 typedef void (*at_custom_uart_rx_intr)(uint8* data,int32 len);
41 
42 typedef void (*at_custom_response_func_type)(const char *str);
43 
44 typedef void (*at_fake_uart_tx_func_type)(const uint8*data,uint32 length);
45 
46 extern uint8 at_customLinkMax;
47 
48 /**
49  * @brief Response "OK" to uart.
50  * @param None
51  * @retval None
52  */
53 void at_response_ok(void);
54 /**
55  * @brief Response "ERROR" to uart.
56  * @param None
57  * @retval None
58  */
59 void at_response_error(void);
60 /**
61  * @brief Response string.
62  * It is equivalent to at_port_print,if not call at_register_response_func or call at_register_response_func(NULL);
63  * It will run custom response function,if call at_register_response_func and parameter is not NULL.
64  * @param string
65  * @retval None
66  */
67 void at_response(const char *str);
68 /**
69  * @brief register custom response function.
70  * @param response_func: the function that will run when call at_response
71  * @retval None
72  */
74 /**
75  * @brief Task of process command or txdata.
76  * @param custom_at_cmd_array: the array of at cmd that custom defined
77  * cmd_num : the num of at cmd that custom defined
78  * @retval None
79  */
80 void at_cmd_array_regist(at_funcationType *custom_at_cmd_array,uint32 cmd_num);
81 /**
82  * @brief get digit form at cmd line.the maybe alter pSrc
83  * @param p_src: at cmd line string
84  * result:the buffer to be placed result
85  * err : err num
86  * @retval TRUE:
87  * FALSE:
88  */
89 bool at_get_next_int_dec(char **p_src,int*result,int* err);
90 /**
91  * @brief get string form at cmd line.the maybe alter pSrc
92  * @param p_dest: the buffer to be placed result
93  * p_src: at cmd line string
94  * max_len :max len of string excepted to get
95  * @retval None
96  */
97 int32 at_data_str_copy(char *p_dest, char **p_src, int32 max_len);
98 
99 /**
100  * @brief initialize at module
101  * @param None
102  * @retval None
103  */
104 void at_init(void);
105 /**
106  * @brief print string to at port
107  * @param string
108  * @retval None
109  */
110 void at_port_print(const char *str);
111 /**
112  * @brief print custom information when AT+GMR
113  * @param string
114  * @retval None
115  */
116 void at_set_custom_info(char* info);
117 /**
118  * @brief if current at command is processing,you can call at_enter_special_state,
119  * then if other comamnd coming,it will return busy.
120  * @param None
121  * @retval None
122  */
123 void at_enter_special_state(void);
124 /**
125  * @brief
126  * @param None
127  * @retval None
128  */
129 void at_leave_special_state(void);
130 /**
131  * @brief get at version
132  * @param None
133  * @retval at version
134  * bit24~31: at main version
135  * bit23~16: at sub version
136  * bit15~8 : at test version
137  * bit7~0 : customized version
138  */
139 uint32 at_get_version(void);
140 
141 /**
142  * @brief register custom uart rx interrupt function
143  * @param rx_func: custom uart rx interrupt function.
144  * If rx_func is non-void,when rx interrupt comming,it will call rx_func(data,len),
145  * data is the buffer of data,len is the length of data.Otherwise,it will run AT rx function.
146  * @retval None
147  */
149 /**
150  * @brief notify at module that has receive data
151  * @param data: data buffer.
152  * @param length: data length
153  * @retval data len,if ok len == length
154  */
155 uint32 at_fake_uart_rx(uint8* data,uint32 length);
156 
157 /**
158  * @brief enable fake uart,and register fake uart tx
159  * @param enable: enable fake uart.
160  * @param at_fake_uart_tx_func:
161  * @retval data len,if ok len == length
162  */
163 bool at_fake_uart_enable(bool enable,at_fake_uart_tx_func_type at_fake_uart_tx_func);
164 
165 /**
166  * @brief set at escape character
167  * @param ch: escape character.
168  * @retval TRUE,if set ok,otherwize FALSE.
169  */
171 
172 #endif
void at_port_print(const char *str)
print string to at port
void at_register_response_func(at_custom_response_func_type response_func)
register custom response function.
int int32
Definition: c_types.h:59
uint32 at_get_version(void)
get at version
u16_t len
Definition: pbuf.h:93
uint32 at_fake_uart_rx(uint8 *data, uint32 length)
notify at module that has receive data
void at_set_custom_info(char *info)
print custom information when AT+GMR
char * at_cmdName
Definition: at_custom.h:32
void at_register_uart_rx_intr(at_custom_uart_rx_intr rx_func)
register custom uart rx interrupt function
void at_response_ok(void)
Response "OK" to uart.
void(* at_custom_response_func_type)(const char *str)
Definition: at_custom.h:42
void at_response(const char *str)
Response string. It is equivalent to at_port_print,if not call at_register_response_func or call at_r...
void at_leave_special_state(void)
uint8 at_customLinkMax
bool at_fake_uart_enable(bool enable, at_fake_uart_tx_func_type at_fake_uart_tx_func)
enable fake uart,and register fake uart tx
int32 at_data_str_copy(char *p_dest, char **p_src, int32 max_len)
get string form at cmd line.the maybe alter pSrc
void(* at_fake_uart_tx_func_type)(const uint8 *data, uint32 length)
Definition: at_custom.h:44
unsigned char uint8
Definition: c_types.h:45
void(* at_custom_uart_rx_intr)(uint8 *data, int32 len)
Definition: at_custom.h:40
void at_enter_special_state(void)
if current at command is processing,you can call at_enter_special_state, then if other comamnd coming...
void at_response_error(void)
Response "ERROR" to uart.
unsigned int uint32
Definition: c_types.h:54
bool at_set_escape_character(uint8 ch)
set at escape character
void at_init(void)
initialize at module
int8_t at_cmdLen
Definition: at_custom.h:33
bool at_get_next_int_dec(char **p_src, int *result, int *err)
get digit form at cmd line.the maybe alter pSrc
void at_cmd_array_regist(at_funcationType *custom_at_cmd_array, uint32 cmd_num)
Task of process command or txdata.