at_custom.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * ESPRESSIF 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. #ifndef CUSTOM_AT_H_
  25. #define CUSTOM_AT_H_
  26. #include "c_types.h"
  27. typedef struct
  28. {
  29. char *at_cmdName;
  30. int8_t at_cmdLen;
  31. void (*at_testCmd)(uint8_t id);
  32. void (*at_queryCmd)(uint8_t id);
  33. void (*at_setupCmd)(uint8_t id, char *pPara);
  34. void (*at_exeCmd)(uint8_t id);
  35. }at_funcationType;
  36. typedef void (*at_custom_uart_rx_intr)(uint8* data,int32 len);
  37. typedef void (*at_custom_response_func_type)(const char *str);
  38. typedef void (*at_fake_uart_tx_func_type)(const uint8*data,uint32 length);
  39. extern uint8 at_customLinkMax;
  40. /**
  41. * @brief Response "OK" to uart.
  42. * @param None
  43. * @retval None
  44. */
  45. void at_response_ok(void);
  46. /**
  47. * @brief Response "ERROR" to uart.
  48. * @param None
  49. * @retval None
  50. */
  51. void at_response_error(void);
  52. /**
  53. * @brief Response string.
  54. * It is equivalent to at_port_print,if not call at_register_response_func or call at_register_response_func(NULL);
  55. * It will run custom response function,if call at_register_response_func and parameter is not NULL.
  56. * @param string
  57. * @retval None
  58. */
  59. void at_response(const char *str);
  60. /**
  61. * @brief register custom response function.
  62. * @param response_func: the function that will run when call at_response
  63. * @retval None
  64. */
  65. void at_register_response_func(at_custom_response_func_type response_func);
  66. /**
  67. * @brief Task of process command or txdata.
  68. * @param custom_at_cmd_array: the array of at cmd that custom defined
  69. * cmd_num : the num of at cmd that custom defined
  70. * @retval None
  71. */
  72. void at_cmd_array_regist(at_funcationType *custom_at_cmd_array,uint32 cmd_num);
  73. /**
  74. * @brief get digit form at cmd line.the maybe alter pSrc
  75. * @param p_src: at cmd line string
  76. * result:the buffer to be placed result
  77. * err : err num
  78. * @retval TRUE:
  79. * FALSE:
  80. */
  81. bool at_get_next_int_dec(char **p_src,int*result,int* err);
  82. /**
  83. * @brief get string form at cmd line.the maybe alter pSrc
  84. * @param p_dest: the buffer to be placed result
  85. * p_src: at cmd line string
  86. * max_len :max len of string excepted to get
  87. * @retval None
  88. */
  89. int32 at_data_str_copy(char *p_dest, char **p_src, int32 max_len);
  90. /**
  91. * @brief initialize at module
  92. * @param None
  93. * @retval None
  94. */
  95. void at_init(void);
  96. /**
  97. * @brief print string to at port
  98. * @param string
  99. * @retval None
  100. */
  101. void at_port_print(const char *str);
  102. /**
  103. * @brief print custom information when AT+GMR
  104. * @param string
  105. * @retval None
  106. */
  107. void at_set_custom_info(char* info);
  108. /**
  109. * @brief if current at command is processing,you can call at_enter_special_state,
  110. * then if other comamnd coming,it will return busy.
  111. * @param None
  112. * @retval None
  113. */
  114. void at_enter_special_state(void);
  115. /**
  116. * @brief
  117. * @param None
  118. * @retval None
  119. */
  120. void at_leave_special_state(void);
  121. /**
  122. * @brief get at version
  123. * @param None
  124. * @retval at version
  125. * bit24~31: at main version
  126. * bit23~16: at sub version
  127. * bit15~8 : at test version
  128. * bit7~0 : customized version
  129. */
  130. uint32 at_get_version(void);
  131. /**
  132. * @brief register custom uart rx interrupt function
  133. * @param rx_func: custom uart rx interrupt function.
  134. * If rx_func is non-void,when rx interrupt comming,it will call rx_func(data,len),
  135. * data is the buffer of data,len is the length of data.Otherwise,it will run AT rx function.
  136. * @retval None
  137. */
  138. void at_register_uart_rx_intr(at_custom_uart_rx_intr rx_func);
  139. /**
  140. * @brief notify at module that has receive data
  141. * @param data: data buffer.
  142. * @param length: data length
  143. * @retval data len,if ok len == length
  144. */
  145. uint32 at_fake_uart_rx(uint8* data,uint32 length);
  146. /**
  147. * @brief enable fake uart,and register fake uart tx
  148. * @param enable: enable fake uart.
  149. * @param at_fake_uart_tx_func:
  150. * @retval data len,if ok len == length
  151. */
  152. bool at_fake_uart_enable(bool enable,at_fake_uart_tx_func_type at_fake_uart_tx_func);
  153. /**
  154. * @brief set at escape character
  155. * @param ch: escape character.
  156. * @retval TRUE,if set ok,otherwize FALSE.
  157. */
  158. bool at_set_escape_character(uint8 ch);
  159. #endif