ql_api_wifi.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /**
  2. @file
  3. ql_api_wifi.h
  4. @brief
  5. This file provides the definitions for wifi, and declares the
  6. API functions.
  7. */
  8. /*============================================================================
  9. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  10. Quectel Wireless Solution Proprietary and Confidential.
  11. =============================================================================*/
  12. /*===========================================================================
  13. EDIT HISTORY FOR MODULE
  14. This section contains comments describing changes made to the module.
  15. Notice that changes are listed in reverse chronological order.
  16. WHEN WHO WHAT, WHERE, WHY
  17. ---------- ------------ ----------------------------------------------------
  18. =============================================================================*/
  19. #ifndef QL_API_WIFI_H
  20. #define QL_API_WIFI_H
  21. #include "ql_api_common.h"
  22. #include "lwip/ip_addr.h"
  23. #include "lwip/netif.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /*========================================================================
  28. * Marco Definition
  29. *========================================================================*/
  30. #define QL_WIFI_SSID_MAX_LEN 32
  31. #define QL_WIFI_PASSWORD_MAX_LEN 64
  32. #define QL_WIFI_IPV4_MAX_LEN 16
  33. /*========================================================================
  34. * Enumeration Definition
  35. *========================================================================*/
  36. typedef enum
  37. {
  38. QL_WIFI_SUCCESS = 0,
  39. QL_WIFI_EXECUTE_ERR = 1 | (QL_COMPONENT_LWIP_WIFI << 16),
  40. QL_WIFI_INVALID_PARAM_ERR,
  41. QL_WIFI_INVALID_PARAM_LEN_ERR,
  42. QL_WIFI_NO_MEM_ERR,
  43. QL_WIFI_MEM_ADDR_NULL_ERR = 5 | (QL_COMPONENT_LWIP_WIFI << 16),
  44. QL_WIFI_INVALID_IP_ERR,
  45. QL_WIFI_INVALID_GW_ERR,
  46. QL_WIFI_INVALID_NETMASK_ERR,
  47. QL_WIFI_INVALID_DNS_ERR,
  48. QL_WIFI_INVALID_DHCP_ERR = 10 | (QL_COMPONENT_LWIP_WIFI << 16),
  49. QL_WIFI_INVALID_MAC_ERR,
  50. QL_WIFI_INVALID_CID_ERR,
  51. QL_WIFI_STATE_ERR,
  52. } ql_wifi_errcode_e;
  53. // Wi-Fi options
  54. typedef enum
  55. {
  56. QL_WIFI_OPT_IP = 0, // val_len: sizeof(ip4_addr_t),static ip
  57. QL_WIFI_OPT_GW, // val_len: sizeof(ip4_addr_t),static gateway
  58. QL_WIFI_OPT_NETMASK, // val_len: sizeof(ip4_addr_t),static netmask
  59. QL_WIFI_OPT_DNS, // val_len: sizeof(ql_wifi_dns_s),static dns
  60. QL_WIFI_OPT_DHCP, // val_len: sizeof(char)
  61. QL_WIFI_OPT_MAC, // val_len: ETHARP_HWADDR_LEN
  62. QL_WIFI_OPT_STATE, // val_len: sizeof(ql_wifi_state_e),netcard status
  63. QL_WIFI_OPT_CID, // val_len: sizeof(ql_wifi_cid_s),wifi cid
  64. QL_WIFI_OPT_MAX
  65. } ql_wifi_opt_e;
  66. typedef enum
  67. {
  68. QL_WIFI_STATE_NONE = 0, // wifinet initialization state
  69. QL_WIFI_STATE_CONNECTING, // wifinet connecting
  70. QL_WIFI_STATE_CONNECTED, // wifinet connected
  71. QL_WIFI_STATE_DISCONNECT, // wifi disconnect
  72. QL_WIFI_STATE_MAX,
  73. } ql_wifi_state_e;
  74. /*========================================================================
  75. * Type Definition
  76. *========================================================================*/
  77. typedef void (*ql_wifi_status_notify_cb)(void *ctx);
  78. typedef int (*ql_wifi_linkoutput_cb)(void *ctx);
  79. typedef struct
  80. {
  81. unsigned int data_len;
  82. unsigned char *data;
  83. } ql_wifi_msg_info_s;
  84. typedef struct
  85. {
  86. uint8_t sim_id;
  87. int cid;
  88. uint8_t enable;
  89. } ql_wifi_cid_s;
  90. typedef struct
  91. {
  92. ip_addr_t dns_server[LWIP_NETIF_IP_TYPE_MAX][LWIP_NETIF_DNS_MAX];
  93. } ql_wifi_dns_s;
  94. /*========================================================================
  95. * function Definition
  96. *========================================================================*/
  97. /*****************************************************************
  98. * Function: ql_wifi_opt_set
  99. *
  100. * Description: Set Wi-Fi option.See ql_wifi_opt_e.
  101. *
  102. * Parameters:
  103. * ql_wifi_opt_e [in] Option type.See ql_wifi_opt_e.
  104. * val [in] The address of input parameter.
  105. * val_len [in] The length of input parameter.See ql_wifi_opt_e.
  106. *
  107. * Return:
  108. * 0 success
  109. * other error code
  110. *
  111. *****************************************************************/
  112. ql_wifi_errcode_e ql_wifi_opt_set(ql_wifi_opt_e opt, void *val, int val_len);
  113. /*****************************************************************
  114. * Function: ql_wifi_opt_get
  115. *
  116. * Description: Get Wi-Fi option.See ql_wifi_opt_e.
  117. *
  118. * Parameters:
  119. * ql_wifi_opt_e [in] Option type.See ql_wifi_opt_e.
  120. * val [Out] The address of output parameter.
  121. * val_len [in] The length of output parameter.
  122. * [out] Some options will return a valid "val_len".See ql_wifi_opt_e.
  123. *
  124. * Return:
  125. * 0 success
  126. * other error code
  127. *
  128. *****************************************************************/
  129. ql_wifi_errcode_e ql_wifi_opt_get(ql_wifi_opt_e opt, void *val, int *val_len);
  130. /*****************************************************************
  131. * Function: ql_wifi_status_notify_cb_register
  132. *
  133. * Description: Register Wi-Fi status notification callback.
  134. *
  135. * Parameters:
  136. * cb [in] Wi-Fi status notification callback.
  137. *
  138. * Return:
  139. * 0 success
  140. * other error code
  141. *
  142. *****************************************************************/
  143. ql_wifi_errcode_e ql_wifi_status_notify_cb_register(ql_wifi_status_notify_cb cb);
  144. /*****************************************************************
  145. * Function: ql_wifi_sta_ip_start
  146. *
  147. * Description: Start Wi-Fi STA dhcp or set Wi-Fi STA static IP information from the parameter of ql_wifi_opt_set.
  148. *
  149. * Parameters:
  150. * argv [in] No defined yet.
  151. *
  152. * Return:
  153. * 0 success
  154. * other error code
  155. *
  156. *****************************************************************/
  157. ql_wifi_errcode_e ql_wifi_sta_ip_start(void *argv);
  158. /*****************************************************************
  159. * Function: ql_wifi_sta_ip_down
  160. *
  161. * Description: Stop Wi-Fi STA dhcp and set Wi-Fi STA down.
  162. *
  163. * Parameters:
  164. * argv [in] No defined yet.
  165. *
  166. * Return:
  167. * 0 success
  168. * other error code
  169. *
  170. *****************************************************************/
  171. ql_wifi_errcode_e ql_wifi_sta_ip_down(void *argv);
  172. /*****************************************************************
  173. * Function: ql_wifi_wlan_create
  174. *
  175. * Description: Create Wi-Fi netcard.
  176. *
  177. * Parameters:
  178. * argv [in] Netcard MAC.Handle as char mac[6]
  179. *
  180. * Return:
  181. * 0 success
  182. * other error code
  183. *
  184. *****************************************************************/
  185. ql_wifi_errcode_e ql_wifi_wlan_create(void *argv);
  186. /*****************************************************************
  187. * Function: ql_wifi_wlan_destroy
  188. *
  189. * Description: Destroy Wi-Fi netcard.
  190. *
  191. * Parameters:
  192. * argv [in] No defined yet.
  193. *
  194. * Return:
  195. * 0 success
  196. * other error code
  197. *
  198. *****************************************************************/
  199. ql_wifi_errcode_e ql_wifi_wlan_destroy(void *argv);
  200. /*****************************************************************
  201. * Function: ql_wifi_linkoutput_cb_register
  202. *
  203. * Description: Register the link layer output callback for LWIP.
  204. *
  205. * Parameters:
  206. * ql_wifi_linkoutput_cb [in] Link layer output callback for LWIP.
  207. * Callback is called when a raw link packet is ready to be transmitted.
  208. *
  209. * Return:
  210. * 0 success
  211. * other error code
  212. *
  213. *****************************************************************/
  214. ql_wifi_errcode_e ql_wifi_linkoutput_cb_register(ql_wifi_linkoutput_cb cb);
  215. /*****************************************************************
  216. * Function: ql_wifi_data_input
  217. *
  218. * Description: Input Wi-Fi data streams to LWIP.
  219. *
  220. * Parameters:
  221. * data [in] Input data
  222. * len [in] Input data length
  223. *
  224. * Return:
  225. * 0 success
  226. * other error code
  227. *
  228. *****************************************************************/
  229. ql_wifi_errcode_e ql_wifi_data_input(uint8_t *data,uint32_t len);
  230. #ifdef __cplusplus
  231. } /*"C" */
  232. #endif
  233. #endif