ql_wifi_app.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /**
  2. @file
  3. ql_wifi_app.h
  4. @brief
  5. Quectel wifi app api header.
  6. */
  7. /*============================================================================
  8. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  9. Quectel Wireless Solution Proprietary and Confidential.
  10. =============================================================================*/
  11. /*===========================================================================
  12. EDIT HISTORY FOR MODULE
  13. This section contains comments describing changes made to the module.
  14. Notice that changes are listed in reverse chronological order.
  15. WHEN WHO WHAT, WHERE, WHY
  16. ---------- ------------ ----------------------------------------------------
  17. =============================================================================*/
  18. #ifndef QL_WIFI_APP_H
  19. #define Ql_WIFI_APP_H
  20. #include "ql_api_common.h"
  21. #include "ql_api_wifi.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /*========================================================================
  26. * Macro Definition
  27. *========================================================================*/
  28. /*========================================================================
  29. * Enumeration Definition
  30. *========================================================================*/
  31. typedef enum
  32. {
  33. // ql_wifi_app_errcode_e extends from ql_wifi_errcode_e in file ql_api_wifi.h
  34. QL_WIFI_APP_SUCCESS = 0,
  35. QL_WIFI_APP_EXECUTE_ERR = 1 | (QL_COMPONENT_LWIP_WIFI << 16),
  36. QL_WIFI_APP_INVALID_PARAM_ERR,
  37. QL_WIFI_APP_INVALID_PARAM_LEN_ERR,
  38. QL_WIFI_APP_NO_MEM_ERR,
  39. QL_WIFI_APP_MEM_ADDR_NULL_ERR = 5 | (QL_COMPONENT_LWIP_WIFI << 16),
  40. QL_WIFI_APP_INVALID_IP_ERR,
  41. QL_WIFI_APP_INVALID_GW_ERR,
  42. QL_WIFI_APP_INVALID_NETMASK_ERR,
  43. QL_WIFI_APP_INVALID_DNS_ERR,
  44. QL_WIFI_APP_INVALID_DHCP_ERR = 10 | (QL_COMPONENT_LWIP_WIFI << 16),
  45. QL_WIFI_APP_INVALID_MAC_ERR,
  46. QL_WIFI_APP_INVALID_CID_ERR,
  47. QL_WIFI_APP_STATE_ERR,
  48. // ql_wifi_app.h add
  49. QL_WIFI_APP_INIT_UART_ERR,
  50. QL_WIFI_APP_INIT_SPI_ERR = 15 | (QL_COMPONENT_LWIP_WIFI << 16),
  51. QL_WIFI_APP_INIT_NET_ERR,
  52. QL_WIFI_APP_INIT_MSG_ERR,
  53. QL_WIFI_APP_INIT_TASK_ERR,
  54. QL_WIFI_APP_INVALID_AP_USER_INFO_ERR,
  55. QL_WIFI_APP_CB_NULL_ERR = 20 | (QL_COMPONENT_LWIP_WIFI << 16),
  56. QL_WIFI_APP_SCAN_WORKING_ERR,
  57. QL_WIFI_APP_REPEAT_INIT_ERR,
  58. QL_WIFI_APP_MUTEX_CREATE_ERR,
  59. } ql_wifi_app_errcode_e;
  60. typedef enum
  61. {
  62. QL_WIFI_APP_OPT_SSID = 0, // val_len: ssid len,STA/AP ssid
  63. QL_WIFI_APP_OPT_PASSWORD, // val_len: password len,STA/AP password
  64. } ql_wifi_app_opt_e;
  65. /*========================================================================
  66. * Type Definition
  67. *=========================================================================*/
  68. typedef void (*ql_wifi_app_sta_status_cb)(void *ctx);
  69. typedef void (*ql_wifi_app_scan_result_cb)(void *ctx);
  70. typedef int (*ql_wifi_app_output_data_msg_cb)(void *ctx);
  71. typedef struct
  72. {
  73. char ssid[QL_WIFI_SSID_MAX_LEN];
  74. char password[QL_WIFI_PASSWORD_MAX_LEN];
  75. } ql_wifi_app_user_ap_info_s;
  76. typedef struct
  77. {
  78. char ssid[QL_WIFI_SSID_MAX_LEN + 1]; // The SSID of an access point
  79. char ap_power; // Signal strength, min:0, max:100
  80. uint8_t bssid[6]; // The BSSID of an access point
  81. char channel; // The RF frequency, 1-13
  82. uint8_t security; // Security type, @ref wlan_sec_type_t
  83. } ql_wifi_app_ap_info_s;
  84. typedef struct
  85. {
  86. char ApNum; // The number of access points found in scanning
  87. ql_wifi_app_ap_info_s *ApList;
  88. } ql_wifi_app_scan_result_s;
  89. /*========================================================================
  90. * function Definition
  91. *========================================================================*/
  92. /*****************************************************************
  93. * Function: ql_wifi_app_get_user_ap_info
  94. *
  95. * Description: Get Wi-Fi user ap information.
  96. *
  97. * Parameters:
  98. * info [out] Wi-Fi user ap information.See ql_wifi_app_user_ap_info_s.
  99. *
  100. * Return:
  101. * 0 success
  102. * other error code
  103. *
  104. *****************************************************************/
  105. ql_wifi_app_errcode_e ql_wifi_app_get_user_ap_info(ql_wifi_app_user_ap_info_s *info);
  106. /*****************************************************************
  107. * Function: ql_wifi_app_set_user_ap_info
  108. *
  109. * Description: Set Wi-Fi user ap information.
  110. * Parameters:
  111. * info [in] Wi-Fi user ap information.See ql_wifi_app_user_ap_info_s.
  112. *
  113. * Return:
  114. * 0 success
  115. * other error code
  116. *
  117. *****************************************************************/
  118. ql_wifi_app_errcode_e ql_wifi_app_set_user_ap_info(ql_wifi_app_user_ap_info_s *info);
  119. /*****************************************************************
  120. * Function: ql_wifi_app_scan
  121. *
  122. * Description: Register Wi-Fi scan callback which get the scan result and start Wi-Fi scan.
  123. *
  124. * Parameters:
  125. * cb [in] Wi-Fi scan callback.Once we get the result of Wi-Fi scan,this callback will be called.
  126. *
  127. * Return:
  128. * 0 success
  129. * other error code
  130. *
  131. *****************************************************************/
  132. ql_wifi_app_errcode_e ql_wifi_app_scan(ql_wifi_app_scan_result_cb cb);
  133. /*****************************************************************
  134. * Function: ql_wifi_app_sta_enable
  135. *
  136. * Description: Register Wi-Fi STA callback and enable the function of Wi-Fi STA(Station).
  137. *
  138. * Parameters:
  139. * sta_status_cb [in] Wi-Fi STA callback.Once we get the status of Wi-Fi access procedure,this callback will be called.
  140. *
  141. * Return:
  142. * 0 success
  143. * other error code
  144. *
  145. *****************************************************************/
  146. ql_wifi_app_errcode_e ql_wifi_app_sta_enable(ql_wifi_app_sta_status_cb sta_status_cb);
  147. /*****************************************************************
  148. * Function: ql_wifi_app_sta_disable
  149. *
  150. * Description: Register Wi-Fi STA callback and enable the function of Wi-Fi STA(Station).
  151. *
  152. * Parameters:
  153. * argv [in] No defined yet.
  154. *
  155. * Return:
  156. * 0 success
  157. * other error code
  158. *
  159. *****************************************************************/
  160. ql_wifi_app_errcode_e ql_wifi_app_sta_disable(void *argv);
  161. /*****************************************************************
  162. * Function: ql_wifi_app_reset
  163. *
  164. * Description: Software reset of Wi-Fi device.
  165. *
  166. * Parameters:
  167. * argv [in] No defined yet.
  168. *
  169. * Return:
  170. * 0 success
  171. * other error code
  172. *
  173. *****************************************************************/
  174. ql_wifi_app_errcode_e ql_wifi_app_reset(void *argv);
  175. /*****************************************************************
  176. * Function: ql_wifi_app_init
  177. *
  178. * Description: Wi-Fi application initialization.All needed tasks and communication bus are initialized in this function.
  179. *
  180. * Parameters:
  181. * argv [in] No defined yet.
  182. *
  183. * Return:
  184. * 0 success
  185. * other error code
  186. *
  187. *****************************************************************/
  188. ql_wifi_app_errcode_e ql_wifi_app_init(void *argv);
  189. /*****************************************************************
  190. * Function: ql_wifi_app_deinit
  191. *
  192. * Description: Wi-Fi application deinitialization.Release all Wi-Fi application resource.
  193. *
  194. * Parameters:
  195. * argv [in] No defined yet.
  196. *
  197. * Return:
  198. * 0 success
  199. * other error code
  200. *
  201. *****************************************************************/
  202. ql_wifi_app_errcode_e ql_wifi_app_deinit(void *argv);
  203. #ifdef __cplusplus
  204. } /*"C" */
  205. #endif
  206. #endif