Mistake on this page?
Report an issue in GitHub or email us
mx_wifi.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file mx_wifi.h
4  * @author MCD Application Team
5  * @brief Header for mx_wifi.c module
6  ******************************************************************************
7  * @attention
8  *
9  * Copyright (c) 2021 STMicroelectronics.
10  * All rights reserved.
11  *
12  * This software is licensed under terms that can be found in the LICENSE file
13  * in the root directory of this software component.
14  * If no LICENSE file comes with this software, it is provided AS-IS.
15  *
16  ******************************************************************************
17  */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef MX_WIFI_H
21 #define MX_WIFI_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "mx_wifi_conf.h"
29 
30 
31 /**
32  * @defgroup MX_WIFI Wi-Fi_API
33  * @brief Driver API on STM32 for MXCHIP Wi-Fi module, see mx_wifi.h
34  * @{ **
35  */
36 
37 /* API version V2.1.8 */
38 #define MX_WIFI_API_VERSION_MAJ (2)
39 #define MX_WIFI_API_VERSION_SUB (1)
40 #define MX_WIFI_API_VERSION_REV (10)
41 
42 /*******************************************************************************
43  * MXCHIP Wi-Fi Module Defines
44  ******************************************************************************/
45 /* common defines */
46 #define MX_MAX_IP_LEN (16)
47 #define MX_MAX_SSID_LEN (32)
48 #define MX_MAX_KEY_LEN (64)
49 #define MX_MAX_BSSID_LEN (6)
50 #define MX_MAX_DNSNAME_LEN (253)
51 #define MX_MAX_IDENTITY_LEN (32)
52 #define MX_TLS_SNI_SERVERNAME_SIZE (128)
53 #define MX_SERVICE_NAME_SIZE (255)
54 #define MC_WIFI_INTERFACE_NUM (2)
55 #define MX_WIFI_PING_MAX (10)
56 
57 #define MX_WIFI_SCAN_TIMEOUT (5000)
58 
59 /**
60  * @brief Wi-Fi mode
61  */
62 enum
63 {
64  MC_SOFTAP, /**< wifi softap mode. */
65  MC_STATION /**< wifi station mode. */
66 };
67 
68 typedef uint8_t mwifi_if_t; /**< wifi mode. */
69 
70 /**
71  * @brief Wi-Fi scan mode
72  */
73 enum
74 {
75  MC_SCAN_PASSIVE = 0, /**< wifi passive scan mode. */
76  MC_SCAN_ACTIVE = 1 /**< wifi active scan mode. */
77 };
78 
79 typedef uint8_t mc_wifi_scan_mode_t; /**< wifi scan mode. */
80 
81 /**
82  * @brief Wi-Fi ip address info
83  */
84 typedef struct
85 {
86  char localip[MX_MAX_IP_LEN]; /**< lcoal ip address */
87  char netmask[MX_MAX_IP_LEN]; /**< netmask */
88  char gateway[MX_MAX_IP_LEN]; /**< gateway ip address */
89  char dnserver[MX_MAX_IP_LEN]; /**< dns server ip address */
90 } mwifi_ip_attr_t; /**< wifi ip address info. */
91 
92 /**
93  * @brief Wi-Fi EAP type
94  */
95 typedef enum
96 {
97  EAP_TYPE_TLS = 13, /* RFC 2716 */
98  EAP_TYPE_TTLS = 21, /* RFC 5281 */
99  EAP_TYPE_PEAP = 25 /* draft-josefsson-pppext-eap-tls-eap-06.txt */
100 } EapType;
101 
102 /**
103  * @brief Wi-Fi EAP info
104  */
105 typedef struct
106 {
107  uint8_t eap_type; /* support: EAP_TYPE_PEAP, EAP_TYPE_TTLS, EAP_TYPE_TLS */
108  const char *rootca; /* the EAP server rootca. NULL for don't check the server's certificate */
109  const char *client_cert; /* client cert, only need this if the server need check the client's certificate,
110  such as EAP_TYPE_TLS mode. */
111  const char *client_key; /* client private key. DONOT support encrypted key. */
113 
114 /*******************************************************************************
115  * STM32Cube Driver API Defines
116  ******************************************************************************/
117 /* status code */
118 #define MX_WIFI_STATUS_OK (0) /**< status code success. */
119 #define MX_WIFI_STATUS_ERROR (-1) /**< status code common error. */
120 #define MX_WIFI_STATUS_TIMEOUT (-2) /**< status code timeout. */
121 #define MX_WIFI_STATUS_IO_ERROR (-3) /**< status code I/O error. */
122 #define MX_WIFI_STATUS_PARAM_ERROR (-4) /**< status code bad argument error. */
123 #define MX_WIFI_STATUS_T int32_t /**< status code. */
124 
125 /* macro */
126 #define MX_WIFI_MAC_SIZE (6) /**< max length of MAC address. */
127 #define MX_WIFI_SCAN_BUF_SIZE (2000) /**< max size of scan buffer. */
128 
129 #define MIN(a, b) ( ((a) < (b)) ? (a) : (b)) /**< helper function: get minimum. */
130 
131 #if 0
132 /* IPv6 address states. */
133 #define IP6_ADDR_INVALID 0x00
134 #define IP6_ADDR_TENTATIVE 0x08
135 #define IP6_ADDR_TENTATIVE_1 0x09 /* 1 probe sent */
136 #define IP6_ADDR_TENTATIVE_2 0x0a /* 2 probes sent */
137 #define IP6_ADDR_TENTATIVE_3 0x0b /* 3 probes sent */
138 #define IP6_ADDR_TENTATIVE_4 0x0c /* 4 probes sent */
139 #define IP6_ADDR_TENTATIVE_5 0x0d /* 5 probes sent */
140 #define IP6_ADDR_TENTATIVE_6 0x0e /* 6 probes sent */
141 #define IP6_ADDR_TENTATIVE_7 0x0f /* 7 probes sent */
142 #define IP6_ADDR_VALID 0x10
143 #define IP6_ADDR_PREFERRED 0x30
144 #define IP6_ADDR_DEPRECATED 0x50
145 #endif /* 0 */
146 
147 /*
148 #define ip6_addr_isinvalid(addr_state) (addr_state == IP6_ADDR_INVALID)
149 #define ip6_addr_istentative(addr_state) (addr_state & IP6_ADDR_TENTATIVE)
150 #define ip6_addr_isvalid(addr_state) (addr_state & IP6_ADDR_VALID)
151 #define ip6_addr_ispreferred(addr_state) (addr_state == IP6_ADDR_PREFERRED)
152 #define ip6_addr_isdeprecated(addr_state) (addr_state == IP6_ADDR_DEPRECATED)
153  */
154 
155 /**
156  * @brief Security settings for wifi network
157  */
158 typedef enum
159 {
160  MX_WIFI_SEC_NONE, /**< Open system. */
161  MX_WIFI_SEC_WEP, /**< Wired Equivalent Privacy. WEP security. */
162  MX_WIFI_SEC_WPA_TKIP, /**< WPA /w TKIP */
163  MX_WIFI_SEC_WPA_AES, /**< WPA /w AES */
164  MX_WIFI_SEC_WPA2_TKIP, /**< WPA2 /w TKIP */
165  MX_WIFI_SEC_WPA2_AES, /**< WPA2 /w AES */
166  MX_WIFI_SEC_WPA2_MIXED, /**< WPA2 /w AES or TKIP */
167  MX_WIFI_SEC_AUTO /**< It is used when calling @ref mwifi_connect,
168  MXOS read security type from scan result. */
170 
171 typedef int8_t (*IO_Init_Func)(uint16_t mode); /**< I/O interface init function. */
172 typedef int8_t (*IO_DeInit_Func)(void); /**< I/O interface deinit function. */
173 typedef void (*IO_Delay_Func)(uint32_t ms); /**< I/O interface delay function. */
174 typedef uint16_t (*IO_Send_Func)(uint8_t *data, uint16_t len); /**< I/O interface send function. */
175 typedef uint16_t (*IO_Receive_Func)(uint8_t *buffer, uint16_t buff_size); /**< I/O interface receive function. */
176 
177 /**
178  * @brief Wi-Fi low level I/O interface operation handles
179  */
180 typedef struct
181 {
182  IO_Init_Func IO_Init; /**< I/O interface init function. */
183  IO_DeInit_Func IO_DeInit; /**< I/O interface deinit function. */
184  IO_Delay_Func IO_Delay; /**< I/O interface delay function. */
185  IO_Send_Func IO_Send; /**< I/O interface send function. */
186  IO_Receive_Func IO_Receive; /**< I/O interface receive function. */
187 } MX_WIFI_IO_t;
188 
189 /**
190  * @brief Wi-Fi system info
191  */
192 typedef struct
193 {
194  /* FW info */
195  uint8_t Product_Name[MX_WIFI_PRODUCT_NAME_SIZE];/**< product name. */
196  uint8_t Product_ID[MX_WIFI_PRODUCT_ID_SIZE]; /**< product ID. */
197  uint8_t FW_Rev[MX_WIFI_FW_REV_SIZE]; /**< firmware version. */
198  uint8_t MAC[MX_WIFI_MAC_SIZE]; /**< Wi-Fi MAC address. */
200 
201 /**
202  * @brief Wi-Fi station info
203  */
204 typedef struct
205 {
206  /* wifi station setting */
207  uint8_t SSID[MX_WIFI_MAX_SSID_NAME_SIZE + 1]; /**< Wi-Fi station SSID. */
208  uint8_t pswd[MX_WIFI_MAX_PSWD_NAME_SIZE + 1]; /**< Wi-Fi station passwd. */
209  MX_WIFI_SecurityType_t Security; /**< Wi-Fi station security. */
210  uint8_t DHCP_IsEnabled; /**< Wi-Fi station DHCP. */
211  /* status */
212  int8_t IsConnected; /**< Wi-Fi station connection status. */
213  /*ipv4 */
214  uint8_t IP_Addr[4]; /**< Wi-Fi station IP address. */
215  uint8_t IP_Mask[4]; /**< Wi-Fi station IP mask. */
216  uint8_t Gateway_Addr[4]; /**< Wi-Fi station gateway. */
217  uint8_t DNS1[4]; /**< Wi-Fi station DNS server. */
218  /* ipv6 */
219  int32_t IP6_state[3]; /**< Wi-Fi station IPv6 address state. */
220  uint8_t IP6_Addr[3][16]; /**< Wi-Fi station IPv6 address. */
221  uint8_t IP6_Mask[16]; /**< Wi-Fi station IPv6 mask. */
222  uint8_t Gateway6_Addr[16]; /**< Wi-Fi station IPv6 gateway. */
223  uint8_t IP6_DNS1[16]; /**< Wi-Fi station IPv6 DNS server. */
225 
226 /**
227  * @brief Wi-Fi softAP info
228  */
229 typedef struct
230 {
231  char SSID[MX_WIFI_MAX_SSID_NAME_SIZE + 1]; /**< Wi-Fi softAP SSID. */
232  char pswd[MX_WIFI_MAX_PSWD_NAME_SIZE + 1]; /**< Wi-Fi softAP password. */
233  /* MX_WIFI_SecurityType_t Security; OPEN: no passwd, WPA2: has passwd, NOT SUPPORTED NOW */
234  uint8_t channel; /**< Wi-Fi softAP Channel. */
235  mwifi_ip_attr_t ip; /**< Wi-Fi softAP IP settings. */
237 
238 /** Prototype of Wi-Fi status changed callback function. */
239 /**
240  * @param cate wifi status: MC_STATION, MC_SOFTAP
241  * @param event wifi events: MWIFI_EVENT_STA_DOWN,
242  * MWIFI_EVENT_STA_UP,
243  * WIFI_EVENT_STA_GOT_IP,
244  * MWIFI_EVENT_AP_UP,
245  * MWIFI_EVENT_AP_DOWN
246  * @param arg user argument passed by @MX_WIFI_RegisterStatusCallback
247  */
248 typedef void (*mx_wifi_status_callback_t)(uint8_t cate, uint8_t event, void *arg);
249 
250 /**
251  * @brief FOTA status
252  */
253 typedef enum
254 {
255  MX_WIFI_FOTA_SUCCESS,
256  MX_WIFI_FOTA_FAILED
258 
259 /**
260  * @brief Prototype of FOTA status callback function
261  */
262 typedef void (*mx_wifi_fota_status_cb_t)(mx_wifi_fota_status_e status, uint32_t user_args);
263 
264 /**
265  * @brief Prototype of netlink input callback function for network bypass mode
266  */
267 typedef void (*mx_wifi_netlink_input_cb_t)(mx_buf_t *pbuf, void *user_args);
268 
269 /**
270  * @brief Wi-Fi runtime info
271  */
272 typedef struct
273 {
274  uint32_t Timeout; /**< Wi-Fi cmd timeout in ms. */
275 
276  mx_wifi_status_callback_t status_cb[MC_WIFI_INTERFACE_NUM]; /**< Wi-Fi status callback. */
277  void *callback_arg[MC_WIFI_INTERFACE_NUM]; /**< Wi-Fi status callback argument. */
278 
279  mx_wifi_fota_status_cb_t fota_status_cb; /**< FOTA status callback. */
280  uint32_t fota_user_args; /**< FOTA status callback argument. */
281 
282  mx_wifi_netlink_input_cb_t netlink_input_cb; /**< netlink input callback. */
283  void *netlink_user_args; /**< netlink input callback argument. */
284 
285  uint8_t scan_result[MX_WIFI_SCAN_BUF_SIZE]; /**< Wi-Fi scan result buffer. */
286  uint8_t scan_number; /**< Num of Wi-Fi scan result to get. */
287 
288  uint8_t interfaces; /**< Num of Wi-Fi interfaces inited, 2 if STA+AP inited. */
290 
291 /**
292  * @brief Wi-Fi Wi-Fi object handle
293  */
294 typedef struct
295 {
296  /* HW IO */
297  MX_WIFI_IO_t fops; /**< Wi-Fi low level I/O operation handles. */
298 
299  /* system info */
300  MX_WIFI_SystemInfo_t SysInfo; /**< Wi-Fi system info. */
301 
302  /* network info */
303  MX_WIFI_Network_t NetSettings; /**< Wi-Fi station info. */
304  MX_WIFI_APSettings_t APSettings; /**< Wi-Fi softAP info. */
305 
306  /* run time data */
307  MX_WIFI_Runtime_t Runtime; /**< Wi-Fi runtime info. */
308 
309  /* wifi obj lock */
310  LOCK_DECLARE(lockcmd);
312 
313 
314 /* Exported functions --------------------------------------------------------*/
315 
316 /**
317  * @defgroup MX_WIFI_IO Driver_I/O
318  * @brief Driver I/O interface setting API
319  * @{ **
320  */
321 
322 
323 /**
324  * @brief Register low level IO interface.
325  * @param Obj wifi object handle.
326  * @param IO_Init IO init function
327  * @param IO_DeInit IO de-init function
328  * @param IO_Delay IO delay function in ms
329  * @param IO_Send IO send data function
330  * @param IO_Receive IO receive data function
331  *
332  * @return result
333  * @retval MX_WIFI_STATUS_OK success
334  * @retval others failure
335  */
337  IO_Init_Func IO_Init, IO_DeInit_Func IO_DeInit, IO_Delay_Func IO_Delay,
338  IO_Send_Func IO_Send, IO_Receive_Func IO_Receive);
339 /**
340  * @brief Reset wifi module by hardware IO.
341  * @param Obj wifi object handle.
342  *
343  * @return result
344  * @retval MX_WIFI_STATUS_OK success
345  * @retval others failure
346  */
348 
349 /**
350  * @} **
351  */
352 
353 /**
354  * @defgroup MX_WIFI_INIT Driver_init
355  * @brief Driver init API
356  * @{ **
357  */
358 
359 /**
360  * @brief Wi-Fi module init type
361  */
362 typedef enum
363 {
364  MX_WIFI_INIT = 0, /**< Wi-Fi module init(not reboot). */
365  MX_WIFI_RESET = 1 /**< Wi-Fi module reset(reboot). */
367 
368 /**
369  * @brief Initialize WIFI module and get module fw & mac info.
370  * @param Obj: pointer to module handle
371  * @retval Operation Status.
372  */
374 
375 /**
376  * @brief DeInitialize WIFI module.
377  * @param Obj: pointer to module handle
378  * @retval Operation Status.
379  */
381 
382 /**
383  * @brief Change default Timeout for wifi cmd.
384  * @param Obj: pointer to module handle
385  * @param Timeout: Timeout in mS
386  * @retval Operation Status.
387  */
388 MX_WIFI_STATUS_T MX_WIFI_SetTimeout(MX_WIFIObject_t *Obj, uint32_t Timeout);
389 
390 /**
391  * @brief Yield data from Wi-Fi module.
392  * @param Obj: pointer to module handle
393  * @param timeout: yield timeout in ms
394  * @retval Operation Status.
395  * @note This will be called periodically
396  */
397 MX_WIFI_STATUS_T MX_WIFI_IO_YIELD(MX_WIFIObject_t *Obj, uint32_t timeout);
398 
399 /**
400  * @} **
401  */
402 
403 /**
404  * @defgroup MX_WIFI_NETWORK_BYPASS_MODE Network bypass mode
405  * @brief Network bypass mode API
406  * @{ **
407  */
408 
409 /**
410  * @brief Network bypass interface index
411  */
412 enum
413 {
414  STATION_IDX = 0,
415  SOFTAP_IDX = 1 /* NOT SUPPORTED NOW */
416 };
417 
418 
419 MX_WIFIObject_t *wifi_obj_get(void);
420 
421 
422 
423 #if (MX_WIFI_NETWORK_BYPASS_MODE == 1)
424 /**
425  * @brief Set network bypass mode
426  * @param Obj: pointer to module handle
427  * @param enable: 0=disable, 1=enable
428  * @param netlink_input_callbck: input data callback function
429  * @param user_args: user arguments for callback function
430  * @retval Operation Status.
431  */
432 MX_WIFI_STATUS_T MX_WIFI_Network_bypass_mode_set(MX_WIFIObject_t *Obj, int32_t enable,
433  mx_wifi_netlink_input_cb_t netlink_input_callbck, void *user_args);
434 
435 /**
436  * @brief Network bypass mode data output
437  * @param Obj: pointer to module handle
438  * @param pbuf: pbuf data to send
439  * @param size: pbuf size
440  * @param data: pbuf payload
441  * @param len: payload len
442  * @param interface: STATION_IDX, SOFTAP_IDX(not supported now)
443  * @retval Operation Status.
444  */
445 MX_WIFI_STATUS_T MX_WIFI_Network_bypass_netlink_output(MX_WIFIObject_t *Obj, void *data,
446  int32_t len,
447  int32_t interface);
448 #endif /* MX_WIFI_NETWORK_BYPASS_MODE */
449 
450 
451 /**
452  * @brief set powersave onoff for wifi station mode.
453  * @param Obj: pointer to module handle
454  * @param ps_onoff: 0 -- powersave off, 1 -- powersave on
455  * @retval Operation Status.
456  */
457 int32_t MX_WIFI_station_powersave(MX_WIFIObject_t *Obj, int32_t ps_onoff);
458 
459 
460 /**
461  * @} **
462  */
463 
464 enum
465 {
466  MWIFI_EVENT_NONE = 0x00, /* invalid event */
467  MWIFI_EVENT_STA_DOWN = 0x01, /**< Wi-Fi station down event. */
468  MWIFI_EVENT_STA_UP = 0x02, /**< Wi-Fi station up event. */
469  MWIFI_EVENT_STA_GOT_IP = 0X03, /**< Wi-Fi station got ip event. */
470  MWIFI_EVENT_AP_DOWN = 0x04, /**< Wi-Fi softap down event. */
471  MWIFI_EVENT_AP_UP = 0x05, /**< Wi-Fi softap up event. */
472 };
473 typedef uint8_t mwifi_status_t;
474 
475 /**
476  * @defgroup MX_WIFI_BASIC Station
477  * @brief station mode API
478  * @{ **
479  */
480 
481 /**
482  * @brief Wi-Fi station link info
483  */
484 #pragma pack(1)
485 typedef struct
486 {
487  uint8_t is_connected; /**< Wi-Fi station connection status. */
488  char ssid[MX_MAX_SSID_LEN]; /**< Wi-Fi connection AP ssid to connect. */
489  uint8_t bssid[MX_MAX_BSSID_LEN]; /**< Wi-Fi connection AP bssid. */
490  uint8_t security; /**< Wi-Fi connection security type. */
491  uint8_t channel; /**< Wi-Fi connection channel. */
492  int32_t rssi; /**< Wi-Fi connection rssi. */
494 #pragma pack()
495 
496 /**
497  * @brief Reset the module by Software.
498  * @param Obj: pointer to module handle
499  * @retval Operation Status.
500  */
502 
503 /**
504  * @brief Reset To factory defaults.
505  * @param Obj: pointer to module handle
506  * @note NOT USED NOW
507  * @retval Operation Status.
508  */
510 
511 /**
512  * @brief Get the firmware version string of the wifi module.
513  * @param Obj: pointer to module handle
514  * @param version: buffer pointer to receive the version string.
515  * @param size: length of the buffer, max size 24Bytes.
516  * @retval Operation Status.
517  */
518 MX_WIFI_STATUS_T MX_WIFI_GetVersion(MX_WIFIObject_t *Obj, uint8_t *version, uint32_t size);
519 
520 /**
521  * @brief Get the MAC address of the wifi module.
522  * @param Obj: pointer to module handle
523  * @param mac: pointer to the MAC address array, size 6Bytes.
524  * @retval Operation Status.
525  */
527 
528 /**
529  * @brief wifi block scan
530  * @param Obj: pointer to module handle
531  * @param scan_mode: scan mode
532  * @param ssid: ssid for active scan(scan specified AP), not used(set NULL) if do passive scan(scan all APs)
533  * @param len: ssid len of the AP to scan, not used(set 0) if do passive scan
534  * @note This API just start scan, use @MX_WIFI_Get_scan_result to get the scan result.
535  * @code Example:
536  * Active scan:
537  * MX_WIFI_Scan(pWifiObj, MC_SCAN_ACTIVE, "ssid_ap", 7);
538  * Passive scan:
539  * MX_WIFI_Scan(pWifiObj, MC_SCAN_PASSIVE, NULL, 0);
540  *
541  * Get scan result:
542  * mwifi_ap_info_t mx_aps[MX_WIFI_MAX_DETECTED_AP]; ( array to store scan AP info )
543  * int32_t ap_num;
544  * ap_num = MX_WIFI_Get_scan_result(pWifiObj, (uint8_t*)&(mx_aps[0]), MX_WIFI_MAX_DETECTED_AP);
545  * if(ap_num > 0)
546  * {
547  * for(int32_t i = 0; i < ap_num; i++)
548  * {
549  * ( mx_aps[i].ssid )
550  * ( mx_aps[i].rssi )
551  * }
552  * }
553  * @endcode
554  * @retval Operation Status.
555  */
556 MX_WIFI_STATUS_T MX_WIFI_Scan(MX_WIFIObject_t *Obj, mc_wifi_scan_mode_t scan_mode, char *ssid, int32_t len);
557 
558 /**
559  * @brief wifi get scan result
560  * @param Obj: pointer to module handle
561  * @param results: scan result buffer, contains mwifi_ap_info_t * number
562  * @param number: max ap number to get, max 10
563  * @retval return the real ap number got.
564  * @note must be called after @MX_WIFI_Scan
565  */
566 int8_t MX_WIFI_Get_scan_result(MX_WIFIObject_t *Obj, uint8_t *results, uint8_t number);
567 
568 /**
569  * @brief Register wifi status changed callback
570  * @param Obj: pointer to module handle
571  * @param cb: wifi status callback function
572  * @param arg: argument pass to callback
573  * @retval Operation Status.
574  */
576  mx_wifi_status_callback_t cb, void *arg);
579  void *arg,
580  mwifi_if_t interface);
581 
582 /**
583  * @brief UnRegister wifi status changed callback
584  * @param Obj: pointer to module handle
585  * @retval Operation Status.
586  */
589 
590 /**
591  * @brief Join an Access point.
592  * @param Obj: pointer to module handle
593  * @param Ssid: the access point id.
594  * @param Password: the Access point password.
595  * @param SecType: Security type.
596  * @retval Operation Status.
597  */
598 MX_WIFI_STATUS_T MX_WIFI_Connect(MX_WIFIObject_t *Obj, const char *SSID,
599  const char *Password, MX_WIFI_SecurityType_t SecType);
600 
601 /**
602  * @brief Join an Access point with WPA-E.
603  * @param Obj: pointer to module handle
604  * @param Ssid: the access point ID.
605  * @param Identity: client identity.
606  * @param Password: client password.
607  * @param attr: extral attributes of EAP method. NULL for default mode EAP-PEAP.
608  * @param ip: Station IP settings, NULL for DHCP mode.
609  * @retval Operation Status.
610  */
612  const char *Identity, const char *Password,
613  mwifi_eap_attr_t *attr, mwifi_ip_attr_t *ip);
614 
615 /**
616  * @brief Disconnect from a network.
617  * @param Obj: pointer to module handle
618  * @retval Operation Status.
619  */
621 
622 /**
623  * @brief Join an Access point with WPS (PUSH-BUTTON) mode.
624  * @retval Operation Status.
625  */
627 
628 /**
629  * @brief Stop WPS connect.
630  * @param Obj: pointer to module handle
631  * @retval Operation Status.
632  */
634 
635 /**
636  * @brief Check whether the module is connected to an access point.
637  * @retval link status 1: connected, otherwise not connect.
638  */
640 
641 /**
642  * @brief Get the local IPv4 address of the wifi module.
643  * @param Obj: pointer to module handle
644  * @param ipaddr: pointer to the IP address array(4 bytes).
645  * @param wifi_if: wifi mode(station or softap).
646  * @retval Operation Status.
647  */
648 MX_WIFI_STATUS_T MX_WIFI_GetIPAddress(MX_WIFIObject_t *Obj, uint8_t *ipaddr, mwifi_if_t wifi_if);
649 
650 /**
651  * @brief Get the local IPv6 address of the wifi module.
652  * @param Obj: pointer to module handle
653  * @param ipaddr6: buf to the IPv6 address array(16 bytes).
654  * @param addr_num: index of the IPv6 address (index: 0/1/2).
655  * @param wifi_if: wifi mode(station or softap).
656  * @retval Operation Status.
657  */
658 MX_WIFI_STATUS_T MX_WIFI_GetIP6Address(MX_WIFIObject_t *Obj, uint8_t *ipaddr6, int32_t addr_num, mwifi_if_t wifi_if);
659 
660 /**
661  * @brief Get the local IPv6 address state of the wifi module.
662  * @param Obj: pointer to module handle
663  * @param addr_num: index of the IPv6 address (index: 0/1/2).
664  * @param wifi_if: wifi mode(station or softap).
665  * @retval IPV6 address State, error if < 0
666  */
667 int32_t MX_WIFI_GetIP6AddressState(MX_WIFIObject_t *Obj, int32_t addr_num, mwifi_if_t wifi_if);
668 
669 
670 /**
671  * @} **
672  */
673 
674 /**
675  * @defgroup MX_WIFI_SOFTAP SoftAP
676  * @brief softAP mode API
677  * @{ **
678  */
679 
680 /**
681  * @brief Wi-Fi softAP info
682  */
683 typedef uint8_t mwifi_security_t;
684 #pragma pack(1)
685 typedef struct
686 {
687  int32_t rssi; /**< Signal strength of the AP */
688  char ssid[33]; /**< SSID of the AP */
689  uint8_t bssid[6]; /**< BSSID of the AP */
690  int32_t channel; /**< Channel of the AP */
691  mwifi_security_t security; /**< security of the AP */
693 #pragma pack()
694 
695 /**
696  * @brief Start softAP(miniAP) mode
697  * @param Obj: pointer to module handle
698  * @param ap_settings: softAP settings.
699  * @retval Operation Status.
700  */
702 
703 /**
704  * @brief Stop softAP(miniAP) mode
705  * @param Obj: pointer to module handle
706  * @retval Operation Status.
707  */
709 
710 /**
711  * @} **
712  */
713 
714 #if MX_WIFI_NETWORK_BYPASS_MODE == 0
715 
716 /**
717  * @defgroup WIFI_SOCKET Socket
718  * @brief socket related API
719  * @{ **
720  */
721 
722 #ifndef socklen_t
723 #define socklen_t uint32_t
724 #endif /* socklen_t */
725 
726 /**
727  * @brief socket address struct
728  */
729 
730 struct sockaddr
731 {
732  uint8_t sa_len;
733  uint8_t sa_family;
734  uint8_t sa_data[14];
735 };
736 
737 /**
738  * @brief socket address(net format)
739  */
740 struct in_addr
741 {
742  uint32_t s_addr;
743 };
744 
745 /**
746  * @brief socket address_in struct
747  */
749 {
750  uint8_t sin_len;
751  uint8_t sin_family;
752  uint16_t sin_port;
753  struct in_addr sin_addr;
754  char sin_zero[8];
755 };
756 
757 /**
758  * @brief socket address(IPV6 net format)
759  */
760 struct in6_addr
761 {
762  union
763  {
764  uint32_t u32_addr[4];
765  uint8_t u8_addr[16];
766  } un;
767  /* #define s6_addr un.u8_addr */
768 };
769 
770 /**
771  * @brief socket address_in6 struct
772  */
774 {
775  uint8_t sin6_len; /* length of this structure */
776  uint8_t sin6_family; /* AF_INET6 */
777  uint16_t sin6_port; /* Transport layer port # */
778  uint32_t sin6_flowinfo; /* IPv6 flow information */
779  struct in6_addr sin6_addr; /* IPv6 address */
780  uint32_t sin6_scope_id; /* Set of interfaces for scope */
781 };
782 
784 {
785  uint8_t s2_len;
786  uint8_t ss_family;
787  char s2_data1[2];
788  uint32_t s2_data2[3];
789  uint32_t s2_data3[3];
790 };
791 
792 /**
793  * @brief socket address_in6 info
794  */
795 struct addrinfo
796 {
797  int32_t ai_flags; /* Input flags. */
798  int32_t ai_family; /* Address family of socket. */
799  int32_t ai_socktype; /* Socket type. */
800  int32_t ai_protocol; /* Protocol of socket. */
801  uint32_t ai_addrlen; /* Length of socket address. */
802  struct sockaddr *ai_addr; /* Socket address of socket. */
803  char *ai_canonname; /* Canonical name of service location. */
804  struct addrinfo *ai_next; /* Pointer to next in list. */
805 };
806 
807 /* Socket protocol types (TCP/UDP/RAW) */
808 #define SOCK_STREAM 1
809 #define SOCK_DGRAM 2
810 #define SOCK_RAW 3
811 
812 #define SOL_SOCKET 0xfff /* options for socket level */
813 
814 #define AF_UNSPEC 0
815 #define AF_INET 2
816 #define AF_INET6 10
817 
818 #define PF_UNSPEC AF_UNSPEC
819 #define PF_INET AF_INET
820 #define PF_INET6 AF_INET6
821 
822 #define IPPROTO_IP 0
823 #define IPPROTO_ICMP 1
824 #define IPPROTO_TCP 6
825 #define IPPROTO_UDP 17
826 #define IPPROTO_IPV6 41
827 #define IPPROTO_ICMPV6 58
828 #define IPPROTO_UDPLITE 136
829 
830 #define F_GETFL 3
831 #define F_SETFL 4
832 
833 #define O_NONBLOCK 1 /* nonblocking I/O */
834 
835 /**
836  * @brief socket option value
837  */
838 typedef enum
839 {
840  SO_DEBUG = 0x0001, /**< Unimplemented: turn on debugging info recording */
841  SO_ACCEPTCONN = 0x0002, /**< socket has had listen() */
842  SO_REUSEADDR = 0x0004, /**< Allow local address reuse */
843  SO_KEEPALIVE = 0x0008, /**< keep connections alive */
844  SO_DONTROUTE = 0x0010, /**< Just use interface addresses */
845  SO_BROADCAST = 0x0020, /**< Permit to send and to receive broadcast messages */
846  SO_USELOOPBACK = 0x0040, /**< Bypass hardware when possible */
847  SO_LINGER = 0x0080, /**< linger on close if data present */
848  SO_OOBINLINE = 0x0100, /**< Leave received OOB data in line */
849  SO_REUSEPORT = 0x0200, /**< Allow local address & port reuse */
850  SO_BLOCKMODE = 0x1000, /**< set socket as block(optval=0)/non-block(optval=1) mode.
851  Default is block mode. */
852  SO_SNDBUF = 0x1001,
853  SO_SNDTIMEO = 0x1005, /**< Send timeout in block mode. block for ever in default mode. */
854  SO_RCVTIMEO = 0x1006, /**< Recv timeout in block mode. block 1 second in default mode. */
855  SO_ERROR = 0x1007, /**< Get socket error number. */
856  SO_TYPE = 0x1008, /**< Get socket type. */
857  SO_NO_CHECK = 0x100a /**< Don't create UDP checksum. */
858 
859 } SOCK_OPT_VAL;
860 
861 #if !defined __GNUC__
862 #define FD_SETSIZE 64 /**< MAX fd number is 64 in MXOS. */
863 #define HOWMANY(x, y) (((x) + ((y) - 1)) / (y))
864 
865 #define NBBY 8 /**< number of bits in a byte. */
866 #define NFDBITS (sizeof(unsigned long) * NBBY) /**< bits per mask */
867 
868 #define MC_FDSET_MASK(n) ((unsigned long)1 << ((n) % NFDBITS))
869 
870 typedef struct _fd_set
871 {
872  unsigned long fds_bits[HOWMANY(FD_SETSIZE, NFDBITS)];
873 } fd_set;
874 
875 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= MC_FDSET_MASK(n)) /**< Add a fd to FD set. */
876 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~MC_FDSET_MASK(n)) /**< Remove fd from FD set. */
877 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & MC_FDSET_MASK(n)) /**< Check if the fd is set in FD set. */
878 #define FD_ZERO(p) memset((p), 0, sizeof(*(p))) /**< Clear FD set. */
879 #endif /* !__GNUC__ */
880 
881 /**
882  * @brief IP option types, level: IPPROTO_IP
883  */
884 typedef enum
885 {
886  IP_ADD_MEMBERSHIP = 0x0003, /**< Join multicast group. */
887  IP_DROP_MEMBERSHIP = 0x0004, /**< Leave multicast group. */
888  IP_MULTICAST_TTL = 0x0005,
889  IP_MULTICAST_IF = 0x0006,
890  IP_MULTICAST_LOOP = 0x0007
891 } IP_OPT_VAL;
892 
893 /**
894  * @brief Create a socket.
895  * @param Obj: pointer to module handle
896  * @param domain: socket domain
897  * @param type: socket type
898  * @param protocol: socket protocol
899  * @retval Socket file descriptor, return < 1 if failed.
900  */
901 int32_t MX_WIFI_Socket_create(MX_WIFIObject_t *Obj, int32_t domain, int32_t type, int32_t protocol);
902 
903 /**
904  * @brief Set option for a socket
905  * @param Obj: pointer to module handle
906  * @param sockfd: socket fd
907  * @param level: option level
908  * @param optname: option to set
909  * @param optvalue: value buffer for the option
910  * @param optlen: length of the option value
911  * @retval Operation Status.
912  */
913 int32_t MX_WIFI_Socket_setsockopt(MX_WIFIObject_t *Obj, int32_t sockfd, int32_t level,
914  int32_t optname, const void *optvalue, int32_t optlen);
915 
916 /**
917  * @brief Get option of a socket.
918  * @param Obj: pointer to module handle
919  * @param sockfd: socket fd
920  * @param level: option level
921  * @param optname: option to set
922  * @param optvalue: buffer pointer of value of the option
923  * @param optlen: buffer pointer of length of the option value
924  * @retval Operation Status.
925  */
926 int32_t MX_WIFI_Socket_getsockopt(MX_WIFIObject_t *Obj, int32_t sockfd, int32_t level,
927  int32_t optname, void *optvalue, uint32_t *optlen);
928 
929 /**
930  * @brief Bind a socket.
931  * @param Obj: pointer to module handle
932  * @param sockfd: socket fd
933  * @param addr: socket address
934  * @param addrlen: address length
935  * @retval Operation Status.
936  */
937 int32_t MX_WIFI_Socket_bind(MX_WIFIObject_t *Obj, int32_t sockfd, const struct sockaddr *addr, int32_t addrlen);
938 
939 /**
940  * @brief Listen a socket.
941  * @param Obj: pointer to module handle
942  * @param sockfd: socket fd
943  * @param backlog: max number to queued.
944  * @retval Operation Status.
945  */
946 int32_t MX_WIFI_Socket_listen(MX_WIFIObject_t *Obj, int32_t sockfd, int32_t backlog);
947 
948 /**
949  * @brief Accept a socket.
950  * @param Obj: pointer to module handle
951  * @param sockfd: socket fd
952  * @param addr: client address
953  * @param addrlen: length of client address
954  * @retval Accepted client socket fd, return < 0 if failed.
955  */
956 int32_t MX_WIFI_Socket_accept(MX_WIFIObject_t *Obj, int32_t sockfd, struct sockaddr *addr, uint32_t *addrlen);
957 
958 /**
959  * @brief Socket connect.
960  * @param Obj: pointer to module handle
961  * @param sockfd: socket fd
962  * @param addr: client address
963  * @param addrlen: length of client address
964  * @retval Operation Status.
965  */
966 int32_t MX_WIFI_Socket_connect(MX_WIFIObject_t *Obj, int32_t sockfd, const struct sockaddr *addr, int32_t addrlen);
967 
968 /**
969  * @brief Socket shutdown.
970  * @param Obj: pointer to module handle
971  * @param sockfd: socket fd
972  * @param mode: shutdown mode:
973  * 0 Stop receiving data for this socket;
974  * 1 Stop trying to transmit data from this socket
975  * 2 Stop all transmit from this socket
976  * @retval Operation Status.
977  */
978 int32_t MX_WIFI_Socket_shutdown(MX_WIFIObject_t *Obj, int32_t sockfd, int32_t mode);
979 
980 /**
981  * @brief Socket close.
982  * @param Obj: pointer to module handle
983  * @param sockfd: socket fd
984  * @retval Operation Status.
985  */
986 int32_t MX_WIFI_Socket_close(MX_WIFIObject_t *Obj, int32_t sockfd);
987 
988 /**
989  * @brief Socket send.
990  * @param Obj: pointer to module handle
991  * @param sockfd: socket fd
992  * @param buf: send data buffer
993  * @param len: length of send data
994  * @param flags: zero for MXOS
995  * @retval Number of bytes sent, return < 0 if failed.
996  */
997 int32_t MX_WIFI_Socket_send(MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags);
998 
999 /**
1000  * @brief Socket recv.
1001  * @param Obj: pointer to module handle
1002  * @param sockfd: socket fd
1003  * @param buf: recv buffer
1004  * @param len: length of recv buffer
1005  * @param flags: zero for MXOS
1006  * @retval Number of bytes received, return < 0 if failed.
1007  */
1008 int32_t MX_WIFI_Socket_recv(MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags);
1009 
1010 /**
1011  * @brief Socket sendto.
1012  * @param Obj: pointer to module handle
1013  * @param sockfd: socket fd
1014  * @param buf: send data buffer
1015  * @param len: length of send data
1016  * @param flags: zero for MXOS
1017  * @param toaddr: address to send
1018  * @param toaddrlen: length of address to send
1019  * @retval Number of bytes sent, return < 0 if failed.
1020  */
1021 int32_t MX_WIFI_Socket_sendto(MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags,
1022  struct sockaddr *toaddr, int32_t toaddrlen);
1023 
1024 /**
1025  * @brief Socket recvfrom.
1026  * @param Obj: pointer to module handle
1027  * @param sockfd: socket fd
1028  * @param buf: recv buffer
1029  * @param len: length of recv buffer
1030  * @param fromaddr: address of the data source
1031  * @param fromaddrlen: length of address of the data source
1032  * @param flags: zero for MXOS
1033  * @retval Number of bytes received, return < 0 if failed.
1034  */
1035 int32_t MX_WIFI_Socket_recvfrom(MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags,
1036  struct sockaddr *fromaddr, uint32_t *fromaddrlen);
1037 
1038 /**
1039  * @brief Gethostbyname, only for IPv4 address.
1040  * @param Obj: pointer to module handle
1041  * @param addr: address of the host
1042  * @param name: hostname
1043  * @retval Operation Status.
1044  */
1045 int32_t MX_WIFI_Socket_gethostbyname(MX_WIFIObject_t *Obj, struct sockaddr *addr, char *name);
1046 
1047 /**
1048  * @brief Ping a host, only for IPv4 address.
1049  * @param Obj: pointer to module handle
1050  * @param addr: hostname
1051  * @param count: ping max count
1052  * @param delay: ping delay in millisecond
1053  * @param response: response time array of ping result
1054  * @retval Operation Status.
1055  */
1056 int32_t MX_WIFI_Socket_ping(MX_WIFIObject_t *Obj, const char *hostname, int32_t count, int32_t delay,
1057  int32_t response[]);
1058 
1059 #if 0
1060 /**
1061  * @brief Get IPv4/v6 address info by nodename.
1062  * @param Obj: pointer to module handle
1063  * @param nodename: descriptive name or address string of the host
1064  * @param servname: not used, set NULL
1065  * @param hints: structure containing input values that set socktype and protocol
1066  * @param res: buf to store the result (set to NULL on failure)
1067  * @retval Operation Status.
1068  */
1069 int32_t MX_WIFI_Socket_getaddrinfo(MX_WIFIObject_t *Obj, const char *nodename, const char *servname,
1070  const struct addrinfo *hints, struct mc_addrinfo *res);
1071 
1072 /**
1073  * @brief Monitor multiple file descriptors for sockets
1074  * @attention Never doing operations in different threads
1075  * @param Obj: pointer to module handle
1076  * @param nfds: is the highest-numbered file descriptor in any of the three
1077  * sets, plus 1
1078  * @param readfds: A file descriptor sets will be watched to see if characters
1079  * become available for reading
1080  * @param writefds: A file descriptor sets will be watched to see if a write
1081  * will not block.
1082  * @param exceptfds: A file descriptor sets will be watched for exceptions.
1083  * @param timeout: The timeout argument specifies the interval that select()
1084  * should block waiting for a file descriptor to become ready.
1085  * If timeout is NULL (no timeout), select() can block until API timeout.
1086  * @retval On success, return the number of file descriptors contained in the
1087  * three returned descriptor sets (that is, the total number of bits
1088  * that are set in readfds, writefds, exceptfds) which may be zero if
1089  * the timeout expires before anything interesting happens. On error,
1090  * -1 is returned, the file descriptor sets are unmodified, and timeout
1091  * becomes undefined.
1092  */
1093 int32_t MX_WIFI_Socket_select(MX_WIFIObject_t *Obj, int32_t nfds, fd_set *readfds, fd_set *writefds,
1094  fd_set *exceptfds, struct mc_timeval *timeout);
1095 #endif /* 0 */
1096 
1097 
1098 /**
1099  * @brief socket getpeername.
1100  * @param Obj: pointer to module handle
1101  * @param sockfd: socket fd
1102  * @param addr: address buffer
1103  * @param addrlen: size of address buffer
1104  * @retval get address of peer socket, return < 0 if failed.
1105  */
1106 int32_t MX_WIFI_Socket_getpeername(MX_WIFIObject_t *Obj, int32_t sockfd, struct sockaddr *addr, uint32_t *addrlen);
1107 
1108 /**
1109  * @brief socket getsockname.
1110  * @param Obj: pointer to module handle
1111  * @param sockfd: socket fd
1112  * @param addr: address buffer
1113  * @param addrlen: size of address buffer
1114  * @retval get address of local socket, return < 0 if failed.
1115  */
1116 int32_t MX_WIFI_Socket_getsockname(MX_WIFIObject_t *Obj, int32_t sockfd, struct sockaddr *addr, uint32_t *addrlen);
1117 
1118 /**
1119  * @} **
1120  */
1121 
1122 /**
1123  * @defgroup MX_WIFI_MDNS mDNS
1124  * @brief mDNS related API
1125  * @{ **
1126  */
1127 
1128 /** Maximum length of labels
1129  *
1130  * A label is one segment of a DNS name. For example, "foo" is a label in the
1131  * name "foo.local.". RFC 1035 requires that labels do not exceed 63 bytes.
1132  */
1133 #define MDNS_MAX_LABEL_LEN 63 /* defined by the standard */
1134 
1135 /** Maximum length of names
1136  *
1137  * A name is a list of labels such as "My Webserver.foo.local" or
1138  * mydevice.local. RFC 1035 requires that names do not exceed 255 bytes.
1139  */
1140 #define MDNS_MAX_NAME_LEN 255 /* defined by the standard : 255*/
1141 
1142 /** Maximum length of key/value pair
1143  *
1144  * TXT records associated with a service are populated with key/value pairs.
1145  * These key/value pairs must not exceed this length.
1146  */
1147 #define MDNS_MAX_KEYVAL_LEN 255 /* defined by the standard : 255*/
1148 
1149 /** protocol values for the proto member of the mdns_service descriptor */
1150 /** TCP Protocol */
1151 #define MDNS_PROTO_TCP 0
1152 /** UDP Protocol */
1153 #define MDNS_PROTO_UDP 1
1154 
1155 /** Maximum no. of services allowed to be announced on a single interface. */
1156 #define MAX_MDNS_LST 5 /* Maximum no. of services */
1157 
1158 /* MDNS Error Codes */
1159 #define ERR_MDNS_BASE -36650 /**< Starting error code for all mdns errors. */
1160 #define ERR_MDNS_INVAL -36651 /**< invalid argument */
1161 #define ERR_MDNS_BADSRC -36652 /**< bad service descriptor */
1162 #define ERR_MDNS_TOOBIG -36653 /**< not enough room for everything */
1163 #define ERR_MDNS_NOIMPL -36654 /**< unimplemented feature */
1164 #define ERR_MDNS_NOMEM -36655 /**< insufficient memory */
1165 #define ERR_MDNS_INUSE -36656 /**< requested resource is in use */
1166 #define ERR_MDNS_NORESP -36657 /**< requested resource is in use */
1167 #define ERR_MDNS_FSOC -36658 /**< failed to create socket for mdns */
1168 #define ERR_MDNS_FREUSE -36659 /**< failed to reuse multicast socket */
1169 #define ERR_MDNS_FBINDTODEVICE -36660 /**< failed to bind mdns socket to device */
1170 #define ERR_MDNS_FBIND -36661 /**< failed to bind mdns socket */
1171 #define ERR_MDNS_FMCAST_JOIN -36662 /**< failed to join multicast socket */
1172 #define ERR_MDNS_FMCAST_SET -36663 /**< failed to set multicast socket */
1173 #define ERR_MDNS_FQUERY_SOC -36664 /**< failed to create query socket */
1174 #define ERR_MDNS_FQUERY_THREAD -36665 /**< failed to create mdns thread */
1175 #define ERR_MDNS_END -36670 /**< Last generic error code (inclusive) */
1176 
1177 /** mDNS Interface State
1178  * mDNS interface state can be changed by using mdns_iface_state_change()
1179  * function. For details about when to use the enum please refer to
1180  * documentation for mdns_iface_state_change(). */
1182 {
1183  /** UP the interface and announce services
1184  * mDNS will probe and announce all services announced via
1185  * mdns_announce_service() and/or mdns_announce_service_arr().
1186  * mDNS will go through entire probing sequence explained in above
1187  * functions. Interface state can be changed to UP, if its DOWN.
1188  */
1189  UP = 0,
1190  /** DOWN the interface and de-announce services
1191  * mDNS sends good bye packet with ttl=0 so that mDNS clients can remove
1192  * the services from their mDNS cache table.
1193  */
1195  /** Forcefully re-announce services
1196  * This state should be used after services are already
1197  * announced and force announcement is needed due to some reason.
1198  * mDNS will not perform probing sequence, as it does in case of UP, and
1199  * will directly re-announce services.
1200  */
1202 };
1203 
1204 /**
1205  * @brief mDNS service info
1206  */
1207 #pragma pack(1)
1209 {
1210  /** Name of MDNS service */
1211  char servname[MDNS_MAX_LABEL_LEN + 1];
1212  /** Type of MDNS service */
1213  char servtype[MDNS_MAX_LABEL_LEN + 1];
1214  /** Domain for MDNS service */
1215  char domain[MDNS_MAX_LABEL_LEN + 1];
1216  /** Port number */
1217  uint16_t port;
1218  /** Protocol used */
1219  int32_t proto;
1220  /** Key value pairs for TXT records*/
1221  char keyvals[MDNS_MAX_KEYVAL_LEN + 1];
1222  /** IP Address of device */
1223  uint32_t ipaddr;
1224  /** IPv6 Address of device */
1225  uint32_t ip6addr[4];
1226 
1227  /** separator for txt record */
1228  char separator; /* user set this for keyvals */
1229 };
1230 #pragma pack()
1231 
1232 /**
1233  * @brief start mDNS service.
1234  * @param Obj: pointer to module handle
1235  * @param domain: domain of service
1236  * @param name: hostname
1237  * @retval Operation Status.
1238  */
1239 int32_t MX_WIFI_MDNS_start(MX_WIFIObject_t *Obj, const char *domain, char *hostname);
1240 
1241 /**
1242  * @brief stop mDNS service.
1243  * @param Obj: pointer to module handle
1244  * @retval Operation Status.
1245  */
1246 int32_t MX_WIFI_MDNS_stop(MX_WIFIObject_t *Obj);
1247 
1248 /**
1249  * @brief announce a service.
1250  * @param Obj: pointer to module handle
1251  * @param service: service to announce
1252  * @param interface: wifi interface
1253  * @retval Operation Status.
1254  */
1255 int32_t MX_WIFI_MDNS_announce_service(MX_WIFIObject_t *Obj, struct mc_mdns_service *service, mwifi_if_t interface);
1256 
1257 /**
1258  * @brief deannounce a service.
1259  * @param Obj: pointer to module handle
1260  * @param service: service to deannounce
1261  * @param interface: wifi interface
1262  * @retval Operation Status.
1263  */
1264 int32_t MX_WIFI_MDNS_deannounce_service(MX_WIFIObject_t *Obj, struct mc_mdns_service *service, mwifi_if_t interface);
1265 
1266 /**
1267  * @brief deannounce all services.
1268  * @param Obj: pointer to module handle
1269  * @param interface: wifi interface
1270  * @retval Operation Status.
1271  */
1272 int32_t MX_WIFI_MDNS_deannounce_service_all(MX_WIFIObject_t *Obj, mwifi_if_t interface);
1273 
1274 /**
1275  * @brief Send interface state change event to mdns
1276  * @param Obj: pointer to module handle
1277  * @param interface: wifi interface
1278  * @param state: state event, valid interface state from \ref iface_state
1279  * @retval Operation Status.
1280  */
1281 int32_t MX_WIFI_MDNS_iface_state_change(MX_WIFIObject_t *Obj, mwifi_if_t interface, enum iface_state state);
1282 
1283 /**
1284  * @brief Set new host name, use mdns_iface_state_change(interface, REANNOUNCE) to anounce
1285  * the new host name.
1286  * @param Obj: pointer to module handle
1287  * @param hostname: new hostname
1288  * @retval Operation Status.
1289  */
1290 int32_t MX_WIFI_MDNS_set_hostname(MX_WIFIObject_t *Obj, char *hostname);
1291 
1292 /**
1293  * @brief sets the TXT record field for a given mDNS service.
1294  * @param Obj: pointer to module handle
1295  * @param service: mDNS service
1296  * @param keyvals: new txt record string
1297  * @param separator: the separator used to separate individual key value pairs
1298  * @retval Operation Status.
1299  */
1300 int32_t MX_WIFI_MDNS_set_txt_rec(MX_WIFIObject_t *Obj, struct mc_mdns_service *service, char *keyvals,
1301  char separator);
1302 
1303 /**
1304  * @} **
1305  */
1306 
1307 /**
1308  * @defgroup MX_WIFI_TLS TLS
1309  * @brief TLS related API
1310  * @{ **
1311  */
1312 
1313 /**
1314  * @brief mxchip TLS handler type
1315  */
1316 typedef void *mtls_t;
1317 
1318 /**
1319  * @brief mxchip TLS version
1320  */
1321 enum
1322 {
1323  SSL_V3_MODE = 1, /**< SSL V3 */
1324  TLS_V1_0_MODE = 2, /**< TLS V1.0 */
1325  TLS_V1_1_MODE = 3, /**< TLS V1.1 */
1326  TLS_V1_2_MODE = 4 /**< TLS V1.2 */
1327 };
1328 
1329 typedef uint8_t mtls_ver_t;
1330 
1331 /**
1332  * @brief set the TLS protocol version.
1333  * @param Obj: pointer to module handle
1334  * @param version: TLS protocol version
1335  * @retval Operation Status.
1336  * @note This function should be called before TLS is ready to function (before
1337  * mtls_connect and mtls_accept is called by application ).
1338  */
1339 int32_t MX_WIFI_TLS_set_ver(MX_WIFIObject_t *Obj, mtls_ver_t version);
1340 
1341 /**
1342  * @brief TLS set client certificate
1343  * @param Obj: pointer to module handle
1344  * @param client_cert: Point to buffer of client cert.
1345  * @param cert_len: length of the client cert.
1346  * @retval Operation Status.
1347  */
1348 int32_t MX_WIFI_TLS_set_clientCertificate(MX_WIFIObject_t *Obj, uint8_t *client_cert, uint16_t cert_len);
1349 
1350 /**
1351  * @brief TLS set client private key
1352  * @param Obj: pointer to module handle
1353  * @param client_private_key: Point to buffer of client private key.
1354  * @param key_len: length of the client cert.
1355  * @retval Operation Status.
1356  */
1357 int32_t MX_WIFI_TLS_set_clientPrivateKey(MX_WIFIObject_t *Obj, uint8_t *client_private_key, uint16_t key_len);
1358 
1359 /**
1360  * @brief TLS client create a TLS connection.
1361  * @param Obj: pointer to module handle
1362  * @details This function is called on the client side and initiates an TLS/TLS handshake with a
1363  * server. When this function is called, the underlying communication channel has already
1364  * been set up. This function is called after TCP 3-way handshak finished.
1365  * @param domain: Specifies a communication domain
1366  * @param type: Specifies the communication semantics.
1367  * @param protocol: specifies a particular protocol to be used with the socket.
1368  * @param addr: Point to the target address to be connected
1369  * @param addrlen: containing the size of the buffer pointed to by addr
1370  * @param ca: pointer to the CA certificate string, used to verify server's certificate.
1371  * @param calen: the string length of ca. 0=do not verify server's certificate.
1372  * @retval return the TLS context pointer on success or NULL for fail.
1373  */
1374 int32_t MX_WIFI_TLS_connect(MX_WIFIObject_t *Obj, int32_t domain, int32_t type, int32_t protocol,
1375  const struct sockaddr *addr, int32_t addrlen, char *ca, int32_t calen);
1376 
1377 /**
1378  * @brief TLS client create a TLS connection with SNI.
1379  * @param Obj: pointer to module handle
1380  * @details This function is called on the client side and initiates an TLS/TLS handshake with a
1381  * server. When this function is called, the underlying communication channel has already
1382  * been set up. This function is called after TCP 3-way handshak finished.
1383  * @param sni_servername: Specifies the SNI servername
1384  * @param sni_servername_len: Specifies the SNI servername length, max size MX_TLS_SNI_SERVERNAME_SIZE
1385  * @param addr: Point to the target address to be connected
1386  * @param addrlen: containing the size of the buffer pointed to by addr
1387  * @param ca: pointer to the CA certificate string, used to verify server's certificate.
1388  * @param calen: the string length of ca. 0=do not verify server's certificate.
1389  * @retval return the TLS context pointer on success or NULL for fail.
1390  */
1391 int32_t MX_WIFI_TLS_connect_sni(MX_WIFIObject_t *Obj, const char *sni_servername, int32_t sni_servername_len,
1392  const struct sockaddr *addr, int32_t addrlen, char *ca, int32_t calen);
1393 
1394 /**
1395  * @brief TLS send data
1396  * @param Obj: pointer to module handle
1397  * @param tls: Point to the TLS context.
1398  * @param data: Point to data to send.
1399  * @param len: data length.
1400  * @retval On success, return the number of bytes sent. On error,
1401  * error code (< 0) is returned.
1402  */
1403 int32_t MX_WIFI_TLS_send(MX_WIFIObject_t *Obj, mtls_t tls, void *data, int32_t len);
1404 
1405 /**
1406  * @brief TLS redeive data
1407  * @param Obj: pointer to module handle
1408  * @param tls: Point to the TLS context.
1409  * @param data: Point to buffer to receive TLS data.
1410  * @param len: max receive buffer length.
1411  * @retval On success, return the number of bytes received. On error,
1412  * error code (< 0) is returned.
1413  */
1414 int32_t MX_WIFI_TLS_recv(MX_WIFIObject_t *Obj, mtls_t tls, void *buf, int32_t len);
1415 
1416 /**
1417  * @brief Close the TLS session, release resource.
1418  * @param Obj: pointer to module handle
1419  * @param tls: Point to the TLS context.
1420  * @retval Operation Status.
1421  */
1422 int32_t MX_WIFI_TLS_close(MX_WIFIObject_t *Obj, mtls_t tls);
1423 
1424 /**
1425  * @brief Set TLS nonblock mode.
1426  * @param Obj: pointer to module handle
1427  * @param tls: Point to the TLS context.
1428  * @param nonblock: true - nonblock, flase - block
1429  * @retval Operation Status.
1430  */
1431 int32_t MX_WIFI_TLS_set_nonblock(MX_WIFIObject_t *Obj, mtls_t tls, int32_t nonblock);
1432 
1433 /**
1434  * @} **
1435  */
1436 
1437 
1438 /**
1439  * @defgroup MX_WIFI_WEBSERVER Webserver
1440  * @brief Webserver related API
1441  * @{ **
1442  */
1443 
1444 
1445 /**
1446  * @brief Start webserver.
1447  * @param Obj: pointer to module handle
1448  * @retval Operation Status.
1449  */
1451 
1452 /**
1453  * @brief Stop webserver.
1454  * @param Obj: pointer to module handle
1455  * @retval Operation Status.
1456  */
1458 
1459 
1460 /**
1461  * @} **
1462  */
1463 
1464 
1465 /**
1466  * @defgroup MX_WIFI_FOTA FOTA
1467  * @brief FOTA related API
1468  * @{ **
1469  */
1470 
1471 
1472 /**
1473  * @brief Start FOTA.
1474  * @param Obj: pointer to module handle
1475  * @param url: HTTP/HTTPS url of bin file to update
1476  * @param md5: MD5 string(32Bytes) of bin file to update
1477  * @param ota_status_callback: callback function for ota status
1478  * @retval Operation Status.
1479  */
1480 int32_t MX_WIFI_FOTA_start(MX_WIFIObject_t *Obj, const char *url, const char *md5,
1481  mx_wifi_fota_status_cb_t fota_status_callback, uint32_t user_args);
1482 
1483 /**
1484  * @} **
1485  */
1486 
1487 /**
1488  * @defgroup MX_WIFI_STATION_POWERSAVE
1489  * @brief Wi-Fi station powersave API
1490  * @{ **
1491  */
1492 
1493 #endif /* MX_WIFI_NETWORK_BYPASS_MODE */
1494 
1495 /**
1496  * @} **
1497  */
1498 
1499 
1500 /**
1501  * @} **
1502  */
1503 
1504 
1505 
1506 #ifdef __cplusplus
1507 }
1508 #endif /* __cplusplus */
1509 
1510 #endif /* MX_WIFI_H */
int32_t MX_WIFI_MDNS_set_hostname(MX_WIFIObject_t *Obj, char *hostname)
Set new host name, use mdns_iface_state_change(interface, REANNOUNCE) to anounce the new host name...
int32_t MX_WIFI_ResetModule(MX_WIFIObject_t *Obj)
Reset the module by Software.
DOWN the interface and de-announce services mDNS sends good bye packet with ttl=0 so that mDNS client...
Definition: mx_wifi.h:1194
int32_t MX_WIFI_TLS_set_clientCertificate(MX_WIFIObject_t *Obj, uint8_t *client_cert, uint16_t cert_len)
TLS set client certificate.
int32_t MX_WIFI_Socket_accept(MX_WIFIObject_t *Obj, int32_t sockfd, struct sockaddr *addr, uint32_t *addrlen)
Accept a socket.
uint16_t port
Port number.
Definition: mx_wifi.h:1217
uint8_t interfaces
Num of Wi-Fi interfaces inited, 2 if STA+AP inited.
Definition: mx_wifi.h:288
WPA /w TKIP.
Definition: mx_wifi.h:162
IO_Receive_Func IO_Receive
I/O interface receive function.
Definition: mx_wifi.h:186
int32_t MX_WIFI_MDNS_deannounce_service(MX_WIFIObject_t *Obj, struct mc_mdns_service *service, mwifi_if_t interface)
deannounce a service.
int32_t MX_WIFI_Webserver_stop(MX_WIFIObject_t *Obj)
Stop webserver.
Recv timeout in block mode.
Definition: mx_wifi.h:854
uint8_t mwifi_security_t
Wi-Fi softAP info.
Definition: mx_wifi.h:683
int8_t MX_WIFI_Get_scan_result(MX_WIFIObject_t *Obj, uint8_t *results, uint8_t number)
wifi get scan result
int32_t MX_WIFI_SetTimeout(MX_WIFIObject_t *Obj, uint32_t Timeout)
Change default Timeout for wifi cmd.
int32_t MX_WIFI_GetIP6Address(MX_WIFIObject_t *Obj, uint8_t *ipaddr6, int32_t addr_num, mwifi_if_t wifi_if)
Get the local IPv6 address of the wifi module.
socket has had listen()
Definition: mx_wifi.h:841
IO_Init_Func IO_Init
I/O interface init function.
Definition: mx_wifi.h:182
void * netlink_user_args
netlink input callback argument.
Definition: mx_wifi.h:283
wifi active scan mode.
Definition: mx_wifi.h:76
int32_t MX_WIFI_TLS_set_clientPrivateKey(MX_WIFIObject_t *Obj, uint8_t *client_private_key, uint16_t key_len)
TLS set client private key.
uint8_t mc_wifi_scan_mode_t
wifi scan mode.
Definition: mx_wifi.h:79
int32_t MX_WIFI_TLS_close(MX_WIFIObject_t *Obj, mtls_t tls)
Close the TLS session, release resource.
Get socket type.
Definition: mx_wifi.h:856
int32_t MX_WIFI_Socket_create(MX_WIFIObject_t *Obj, int32_t domain, int32_t type, int32_t protocol)
Create a socket.
int32_t MX_WIFI_TLS_connect_sni(MX_WIFIObject_t *Obj, const char *sni_servername, int32_t sni_servername_len, const struct sockaddr *addr, int32_t addrlen, char *ca, int32_t calen)
TLS client create a TLS connection with SNI.
Wired Equivalent Privacy.
Definition: mx_wifi.h:161
Wi-Fi module reset(reboot).
Definition: mx_wifi.h:365
IO_Delay_Func IO_Delay
I/O interface delay function.
Definition: mx_wifi.h:184
int32_t MX_WIFI_RegisterStatusCallback_if(MX_WIFIObject_t *Obj, mx_wifi_status_callback_t cb, void *arg, mwifi_if_t interface)
< status code.
wifi softap mode.
Definition: mx_wifi.h:64
keep connections alive
Definition: mx_wifi.h:843
int32_t MX_WIFI_DeInit(MX_WIFIObject_t *Obj)
DeInitialize WIFI module.
int32_t MX_WIFI_GetMACAddress(MX_WIFIObject_t *Obj, uint8_t *mac)
Get the MAC address of the wifi module.
int32_t MX_WIFI_MDNS_start(MX_WIFIObject_t *Obj, const char *domain, char *hostname)
start mDNS service.
void(* mx_wifi_netlink_input_cb_t)(mx_buf_t *pbuf, void *user_args)
Prototype of netlink input callback function for network bypass mode.
Definition: mx_wifi.h:267
MX_WIFI_SecurityType_t
Security settings for wifi network.
Definition: mx_wifi.h:158
int32_t MX_WIFI_Socket_recv(MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags)
Socket recv.
Wi-Fi EAP info.
Definition: mx_wifi.h:105
int32_t MX_WIFI_TLS_set_nonblock(MX_WIFIObject_t *Obj, mtls_t tls, int32_t nonblock)
Set TLS nonblock mode.
wifi passive scan mode.
Definition: mx_wifi.h:75
iface_state
mDNS Interface State mDNS interface state can be changed by using mdns_iface_state_change() function...
Definition: mx_wifi.h:1181
void md5(unsigned char *input, int ilen, unsigned char output[16])
Output = MD5( input buffer )
int32_t MX_WIFI_StopAP(MX_WIFIObject_t *Obj)
Stop softAP(miniAP) mode.
TLS V1.0.
Definition: mx_wifi.h:1324
Unimplemented: turn on debugging info recording.
Definition: mx_wifi.h:840
int32_t MX_WIFI_Socket_shutdown(MX_WIFIObject_t *Obj, int32_t sockfd, int32_t mode)
Socket shutdown.
Send timeout in block mode.
Definition: mx_wifi.h:853
#define MDNS_MAX_KEYVAL_LEN
Maximum length of key/value pair.
Definition: mx_wifi.h:1147
UP the interface and announce services mDNS will probe and announce all services announced via mdns_a...
Definition: mx_wifi.h:1189
Wi-Fi ip address info.
Definition: mx_wifi.h:84
void * mtls_t
mxchip TLS handler type
Definition: mx_wifi.h:1316
int32_t MX_WIFI_Socket_sendto(MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags, struct sockaddr *toaddr, int32_t toaddrlen)
Socket sendto.
Bypass hardware when possible.
Definition: mx_wifi.h:846
Wi-Fi low level I/O interface operation handles.
Definition: mx_wifi.h:180
int32_t MX_WIFI_HardResetModule(MX_WIFIObject_t *Obj)
Reset wifi module by hardware IO.
uint8_t channel
Wi-Fi softAP Channel.
Definition: mx_wifi.h:234
socket address_in struct
Definition: mx_wifi.h:748
Wi-Fi system info.
Definition: mx_wifi.h:192
int32_t MX_WIFI_Socket_getsockopt(MX_WIFIObject_t *Obj, int32_t sockfd, int32_t level, int32_t optname, void *optvalue, uint32_t *optlen)
Get option of a socket.
MX_WIFI_SecurityType_t Security
Wi-Fi station security.
Definition: mx_wifi.h:209
int32_t MX_WIFI_UnRegisterStatusCallback(MX_WIFIObject_t *Obj)
UnRegister wifi status changed callback.
int32_t MX_WIFI_Init(MX_WIFIObject_t *Obj)
Initialize WIFI module and get module fw & mac info.
mwifi_security_t security
security of the AP
Definition: mx_wifi.h:691
linger on close if data present
Definition: mx_wifi.h:847
int32_t MX_WIFI_Socket_setsockopt(MX_WIFIObject_t *Obj, int32_t sockfd, int32_t level, int32_t optname, const void *optvalue, int32_t optlen)
Set option for a socket.
int32_t MX_WIFI_Socket_send(MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags)
Socket send.
uint32_t fota_user_args
FOTA status callback argument.
Definition: mx_wifi.h:280
int32_t MX_WIFI_Disconnect(MX_WIFIObject_t *Obj)
Disconnect from a network.
MX_WIFI_IO_t fops
Wi-Fi low level I/O operation handles.
Definition: mx_wifi.h:297
int8_t(* IO_Init_Func)(uint16_t mode)
I/O interface init function.
Definition: mx_wifi.h:171
SOCK_OPT_VAL
socket option value
Definition: mx_wifi.h:838
IO_Send_Func IO_Send
I/O interface send function.
Definition: mx_wifi.h:185
void(* mx_wifi_status_callback_t)(uint8_t cate, uint8_t event, void *arg)
Prototype of Wi-Fi status changed callback function.
Definition: mx_wifi.h:248
uint16_t(* IO_Send_Func)(uint8_t *data, uint16_t len)
I/O interface send function.
Definition: mx_wifi.h:174
mx_wifi_netlink_input_cb_t netlink_input_cb
netlink input callback.
Definition: mx_wifi.h:282
uint8_t mwifi_if_t
wifi mode.
Definition: mx_wifi.h:68
IP_OPT_VAL
IP option types, level: IPPROTO_IP.
Definition: mx_wifi.h:884
Wi-Fi station got ip event.
Definition: mx_wifi.h:469
Get socket error number.
Definition: mx_wifi.h:855
Just use interface addresses.
Definition: mx_wifi.h:844
int32_t MX_WIFI_TLS_recv(MX_WIFIObject_t *Obj, mtls_t tls, void *buf, int32_t len)
TLS redeive data.
int32_t MX_WIFI_Socket_ping(MX_WIFIObject_t *Obj, const char *hostname, int32_t count, int32_t delay, int32_t response[])
Ping a host, only for IPv4 address.
IO_DeInit_Func IO_DeInit
I/O interface deinit function.
Definition: mx_wifi.h:183
MX_WIFI_Network_t NetSettings
Wi-Fi station info.
Definition: mx_wifi.h:303
WPA2 /w AES.
Definition: mx_wifi.h:165
int32_t MX_WIFI_MDNS_iface_state_change(MX_WIFIObject_t *Obj, mwifi_if_t interface, enum iface_state state)
Send interface state change event to mdns.
Wi-Fi softap down event.
Definition: mx_wifi.h:470
int32_t MX_WIFI_Socket_close(MX_WIFIObject_t *Obj, int32_t sockfd)
Socket close.
Wi-Fi runtime info.
Definition: mx_wifi.h:272
int32_t MX_WIFI_WPS_Connect(MX_WIFIObject_t *Obj)
Join an Access point with WPS (PUSH-BUTTON) mode.
set socket as block(optval=0)/non-block(optval=1) mode.
Definition: mx_wifi.h:850
Forcefully re-announce services This state should be used after services are already announced and fo...
Definition: mx_wifi.h:1201
Allow local address & port reuse.
Definition: mx_wifi.h:849
socket address(IPV6 net format)
Definition: mx_wifi.h:760
SSL V3.
Definition: mx_wifi.h:1323
int32_t MX_WIFI_IO_YIELD(MX_WIFIObject_t *Obj, uint32_t timeout)
Yield data from Wi-Fi module.
Open system.
Definition: mx_wifi.h:160
int8_t(* IO_DeInit_Func)(void)
I/O interface deinit function.
Definition: mx_wifi.h:172
uint32_t ipaddr
IP Address of device.
Definition: mx_wifi.h:1223
int32_t MX_WIFI_TLS_send(MX_WIFIObject_t *Obj, mtls_t tls, void *data, int32_t len)
TLS send data.
socket address struct
Definition: mx_wifi.h:730
Main packet buffer struct.
Wi-Fi softap up event.
Definition: mx_wifi.h:471
WPA2 /w TKIP.
Definition: mx_wifi.h:164
MX_WIFI_InitMode_t
Wi-Fi module init type.
Definition: mx_wifi.h:362
int32_t MX_WIFI_MDNS_set_txt_rec(MX_WIFIObject_t *Obj, struct mc_mdns_service *service, char *keyvals, char separator)
sets the TXT record field for a given mDNS service.
socket address(net format)
Definition: mx_wifi.h:740
Wi-Fi station info.
Definition: mx_wifi.h:204
Permit to send and to receive broadcast messages.
Definition: mx_wifi.h:845
int32_t MX_WIFI_Scan(MX_WIFIObject_t *Obj, mc_wifi_scan_mode_t scan_mode, char *ssid, int32_t len)
wifi block scan
WPA /w AES.
Definition: mx_wifi.h:163
uint8_t DHCP_IsEnabled
Wi-Fi station DHCP.
Definition: mx_wifi.h:210
int32_t MX_WIFI_MDNS_stop(MX_WIFIObject_t *Obj)
stop mDNS service.
int32_t MX_WIFI_Socket_getsockname(MX_WIFIObject_t *Obj, int32_t sockfd, struct sockaddr *addr, uint32_t *addrlen)
socket getsockname.
Wi-Fi softAP info.
Definition: mx_wifi.h:229
int32_t MX_WIFI_GetVersion(MX_WIFIObject_t *Obj, uint8_t *version, uint32_t size)
Get the firmware version string of the wifi module.
int32_t MX_WIFI_StartAP(MX_WIFIObject_t *Obj, MX_WIFI_APSettings_t *ap_settings)
Start softAP(miniAP) mode.
int32_t MX_WIFI_Socket_listen(MX_WIFIObject_t *Obj, int32_t sockfd, int32_t backlog)
Listen a socket.
int32_t MX_WIFI_Socket_recvfrom(MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags, struct sockaddr *fromaddr, uint32_t *fromaddrlen)
Socket recvfrom.
Join multicast group.
Definition: mx_wifi.h:886
int32_t MX_WIFI_Socket_gethostbyname(MX_WIFIObject_t *Obj, struct sockaddr *addr, char *name)
Gethostbyname, only for IPv4 address.
mDNS service info
Definition: mx_wifi.h:1208
int32_t MX_WIFI_WPS_Stop(MX_WIFIObject_t *Obj)
Stop WPS connect.
mx_wifi_fota_status_e
FOTA status.
Definition: mx_wifi.h:253
It is used when calling mwifi_connect, MXOS read security type from scan result.
Definition: mx_wifi.h:167
MX_WIFI_SystemInfo_t SysInfo
Wi-Fi system info.
Definition: mx_wifi.h:300
int32_t MX_WIFI_Connect(MX_WIFIObject_t *Obj, const char *SSID, const char *Password, MX_WIFI_SecurityType_t SecType)
Join an Access point.
int32_t MX_WIFI_station_powersave(MX_WIFIObject_t *Obj, int32_t ps_onoff)
set powersave onoff for wifi station mode.
int32_t MX_WIFI_Socket_bind(MX_WIFIObject_t *Obj, int32_t sockfd, const struct sockaddr *addr, int32_t addrlen)
Bind a socket.
int32_t MX_WIFI_Socket_getpeername(MX_WIFIObject_t *Obj, int32_t sockfd, struct sockaddr *addr, uint32_t *addrlen)
socket getpeername.
#define NFDBITS
bits per mask
Definition: mx_wifi.h:866
mwifi_ip_attr_t ip
Wi-Fi softAP IP settings.
Definition: mx_wifi.h:235
int32_t MX_WIFI_GetIPAddress(MX_WIFIObject_t *Obj, uint8_t *ipaddr, mwifi_if_t wifi_if)
Get the local IPv4 address of the wifi module.
int32_t MX_WIFI_TLS_set_ver(MX_WIFIObject_t *Obj, mtls_ver_t version)
set the TLS protocol version.
int32_t MX_WIFI_MDNS_announce_service(MX_WIFIObject_t *Obj, struct mc_mdns_service *service, mwifi_if_t interface)
announce a service.
Wi-Fi module init(not reboot).
Definition: mx_wifi.h:364
int32_t MX_WIFI_RegisterStatusCallback(MX_WIFIObject_t *Obj, mx_wifi_status_callback_t cb, void *arg)
Register wifi status changed callback.
void(* mx_wifi_fota_status_cb_t)(mx_wifi_fota_status_e status, uint32_t user_args)
Prototype of FOTA status callback function.
Definition: mx_wifi.h:262
uint8_t scan_number
Num of Wi-Fi scan result to get.
Definition: mx_wifi.h:286
int32_t channel
Channel of the AP.
Definition: mx_wifi.h:690
#define MDNS_MAX_LABEL_LEN
Maximum length of labels.
Definition: mx_wifi.h:1133
EapType
Wi-Fi EAP type.
Definition: mx_wifi.h:95
#define MX_WIFI_SCAN_BUF_SIZE
max size of scan buffer.
Definition: mx_wifi.h:127
Allow local address reuse.
Definition: mx_wifi.h:842
int32_t MX_WIFI_UnRegisterStatusCallback_if(MX_WIFIObject_t *Obj, mwifi_if_t interface)
< status code.
#define MX_WIFI_STATUS_T
status code.
Definition: mx_wifi.h:123
Wi-Fi Wi-Fi object handle.
Definition: mx_wifi.h:294
Leave multicast group.
Definition: mx_wifi.h:887
uint16_t(* IO_Receive_Func)(uint8_t *buffer, uint16_t buff_size)
I/O interface receive function.
Definition: mx_wifi.h:175
Wi-Fi station up event.
Definition: mx_wifi.h:468
int32_t MX_WIFI_TLS_connect(MX_WIFIObject_t *Obj, int32_t domain, int32_t type, int32_t protocol, const struct sockaddr *addr, int32_t addrlen, char *ca, int32_t calen)
TLS client create a TLS connection.
int32_t MX_WIFI_Socket_connect(MX_WIFIObject_t *Obj, int32_t sockfd, const struct sockaddr *addr, int32_t addrlen)
Socket connect.
socket address_in6 struct
Definition: mx_wifi.h:773
TLS V1.1.
Definition: mx_wifi.h:1325
int8_t IsConnected
Wi-Fi station connection status.
Definition: mx_wifi.h:212
int32_t MX_WIFI_FOTA_start(MX_WIFIObject_t *Obj, const char *url, const char *md5, mx_wifi_fota_status_cb_t fota_status_callback, uint32_t user_args)
Start FOTA.
int32_t rssi
Signal strength of the AP.
Definition: mx_wifi.h:687
wifi station mode.
Definition: mx_wifi.h:65
int32_t MX_WIFI_RegisterBusIO(MX_WIFIObject_t *Obj, IO_Init_Func IO_Init, IO_DeInit_Func IO_DeInit, IO_Delay_Func IO_Delay, IO_Send_Func IO_Send, IO_Receive_Func IO_Receive)
Register low level IO interface.
mx_wifi_fota_status_cb_t fota_status_cb
FOTA status callback.
Definition: mx_wifi.h:279
int32_t MX_WIFI_Webserver_start(MX_WIFIObject_t *Obj)
Start webserver.
Wi-Fi station down event.
Definition: mx_wifi.h:467
uint32_t Timeout
Wi-Fi cmd timeout in ms.
Definition: mx_wifi.h:274
socket address_in6 info
Definition: mx_wifi.h:795
#define FD_SETSIZE
MAX fd number is 64 in MXOS.
Definition: mx_wifi.h:862
#define MX_WIFI_MAC_SIZE
max length of MAC address.
Definition: mx_wifi.h:126
int32_t proto
Protocol used.
Definition: mx_wifi.h:1219
MX_WIFI_APSettings_t APSettings
Wi-Fi softAP info.
Definition: mx_wifi.h:304
int32_t MX_WIFI_EAP_Connect(MX_WIFIObject_t *Obj, const char *SSID, const char *Identity, const char *Password, mwifi_eap_attr_t *attr, mwifi_ip_attr_t *ip)
Join an Access point with WPA-E.
Don&#39;t create UDP checksum.
Definition: mx_wifi.h:857
TLS V1.2.
Definition: mx_wifi.h:1326
int8_t MX_WIFI_IsConnected(MX_WIFIObject_t *Obj)
Check whether the module is connected to an access point.
void(* IO_Delay_Func)(uint32_t ms)
I/O interface delay function.
Definition: mx_wifi.h:173
MX_WIFI_Runtime_t Runtime
Wi-Fi runtime info.
Definition: mx_wifi.h:307
Leave received OOB data in line.
Definition: mx_wifi.h:848
int32_t MX_WIFI_GetIP6AddressState(MX_WIFIObject_t *Obj, int32_t addr_num, mwifi_if_t wifi_if)
Get the local IPv6 address state of the wifi module.
int32_t MX_WIFI_MDNS_deannounce_service_all(MX_WIFIObject_t *Obj, mwifi_if_t interface)
deannounce all services.
WPA2 /w AES or TKIP.
Definition: mx_wifi.h:166
char separator
separator for txt record
Definition: mx_wifi.h:1228
int32_t MX_WIFI_ResetToFactoryDefault(MX_WIFIObject_t *Obj)
Reset To factory defaults.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.