Wi-Fi¶
Introduction¶
The WiFi libraries provide support for configuring and monitoring the ESP8266 WiFi networking functionality. This includes configuration for:
- Station mode (aka STA mode or WiFi client mode). ESP8266 connects to an access point.
- AP mode (aka Soft-AP mode or Access Point mode). Stations connect to the ESP8266.
- Combined AP-STA mode (ESP8266 is concurrently an access point and a station connected to another access point).
- Various security modes for the above (WPA, WPA2, WEP, etc.)
- Scanning for access points (active & passive scanning).
- Promiscuous mode monitoring of IEEE802.11 WiFi packets.
Application Examples¶
See wifi directory of ESP8266_RTOS_SDK examples that contains the following applications:
- Simple application showing how to connect ESP8266 module to an Access Point - template.
API Reference¶
Header File¶
Functions¶
-
esp_err_t
esp_wifi_init
(const wifi_init_config_t *config)¶ Init WiFi Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer, WiFi NVS structure etc, this WiFi also start WiFi task.
- Attention
- 1. This API must be called before all other WiFi API can be called
- Attention
- 2. Always use WIFI_INIT_CONFIG_DEFAULT macro to init the config to default values, this can guarantee all the fields got correct value when more fields are added into wifi_init_config_t in future release. If you want to set your owner initial values, overwrite the default values which are set by WIFI_INIT_CONFIG_DEFAULT, please be notified that the field ‘magic’ of wifi_init_config_t should always be WIFI_INIT_CONFIG_MAGIC!
- Return
- ESP_OK: succeed
- ESP_ERR_NO_MEM: out of memory
- others: refer to error code esp_err.h
- Parameters
config
: pointer to WiFi init configuration structure; can point to a temporary variable.
-
esp_err_t
esp_wifi_deinit
(void)¶ Deinit WiFi Free all resource allocated in esp_wifi_init and stop WiFi task.
- Attention
- 1. This API should be called if you want to remove WiFi driver from the system
- Return
- ESP_OK: succeed
-
esp_err_t
esp_wifi_set_mode
(wifi_mode_t mode)¶ Set the WiFi operating mode.
Set the WiFi operating mode as station, soft-AP or station+soft-AP, The default mode is soft-AP mode.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- others: refer to error code in esp_err.h
- Parameters
mode
: WiFi operating mode
-
esp_err_t
esp_wifi_get_mode
(wifi_mode_t *mode)¶ Get current operating mode of WiFi.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
mode
: store current WiFi mode
-
esp_err_t
esp_wifi_start
(void)¶ Start WiFi according to current configuration If mode is WIFI_MODE_STA, it create station control block and start station If mode is WIFI_MODE_AP, it create soft-AP control block and start soft-AP If mode is WIFI_MODE_APSTA, it create soft-AP and station control block and start soft-AP and station.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- ESP_ERR_NO_MEM: out of memory
- ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
- ESP_FAIL: other WiFi internal errors
-
esp_err_t
esp_wifi_stop
(void)¶ Stop WiFi If mode is WIFI_MODE_STA, it stop station and free station control block If mode is WIFI_MODE_AP, it stop soft-AP and free soft-AP control block If mode is WIFI_MODE_APSTA, it stop station/soft-AP and free station/soft-AP control block.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
-
esp_err_t
esp_wifi_restore
(void)¶ Restore WiFi stack persistent settings to default values.
This function will reset settings made using the following APIs:
- esp_wifi_get_auto_connect,
- esp_wifi_set_protocol,
- esp_wifi_set_config related
- esp_wifi_set_mode
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
-
esp_err_t
esp_wifi_connect
(void)¶ Connect the ESP8266 WiFi station to the AP.
- Attention
- 1. This API only impact WIFI_MODE_STA or WIFI_MODE_APSTA mode
- Attention
- 2. If the ESP8266 is connected to an AP, call esp_wifi_disconnect to disconnect.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start
- ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
- ESP_ERR_WIFI_SSID: SSID of AP which station connects is invalid
-
esp_err_t
esp_wifi_disconnect
(void)¶ Disconnect the ESP8266 WiFi station from the AP.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi was not initialized by esp_wifi_init
- ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start
- ESP_FAIL: other WiFi internal errors
-
esp_err_t
esp_wifi_clear_fast_connect
(void)¶ Currently this API is just an stub API.
- Return
- ESP_OK: succeed
- others: fail
-
esp_err_t
esp_wifi_deauth_sta
(uint16_t aid)¶ deauthenticate all stations or associated id equals to aid
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start
- ESP_ERR_INVALID_ARG: invalid argument
- ESP_ERR_WIFI_MODE: WiFi mode is wrong
- Parameters
aid
: when aid is 0, deauthenticate all stations, otherwise deauthenticate station whose associated id is aid
-
esp_err_t
esp_wifi_scan_start
(const wifi_scan_config_t *config, bool block)¶ Scan all available APs.
- Attention
- If this API is called, the found APs are stored in WiFi driver dynamic allocated memory and the will be freed in esp_wifi_scan_get_ap_records, so generally, call esp_wifi_scan_get_ap_records to cause the memory to be freed once the scan is done
- Attention
- The values of maximum active scan time and passive scan time per channel are limited to 1500 milliseconds. Values above 1500ms may cause station to disconnect from AP and are not recommended.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start
- ESP_ERR_WIFI_TIMEOUT: blocking scan is timeout
- others: refer to error code in esp_err.h
- Parameters
config
: configuration of scanningblock
: if block is true, this API will block the caller until the scan is done, otherwise it will return immediately
-
esp_err_t
esp_wifi_scan_stop
(void)¶ Stop the scan in process.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
-
esp_err_t
esp_wifi_scan_get_ap_num
(uint16_t *number)¶ Get number of APs found in last scan.
- Attention
- This API can only be called when the scan is completed, otherwise it may get wrong value.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
number
: store number of APIs found in last scan
-
esp_err_t
esp_wifi_scan_get_ap_records
(uint16_t *number, wifi_ap_record_t *ap_records)¶ Get AP list found in last scan.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
- ESP_ERR_INVALID_ARG: invalid argument
- ESP_ERR_NO_MEM: out of memory
- Parameters
number
: As input param, it stores max AP number ap_records can hold. As output param, it receives the actual AP number this API returns.ap_records
: wifi_ap_record_t array to hold the found APs
-
esp_err_t
esp_wifi_sta_get_ap_info
(wifi_ap_record_t *ap_info)¶ Get information of AP which the ESP8266 station is associated with.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_CONN: The station interface don’t initialized
- ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
- Parameters
ap_info
: the wifi_ap_record_t to hold AP information sta can get the connected ap’s phy mode info through the struct member phy_11b,phy_11g,phy_11n,phy_lr in the wifi_ap_record_t struct. For example, phy_11b = 1 imply that ap support 802.11b mode
-
esp_err_t
esp_wifi_set_ps
(wifi_ps_type_t type)¶ Set current power save type.
- Attention
- Default power save type is WIFI_PS_NONE.
- Return
- ESP_ERR_NOT_SUPPORTED: not supported yet
- Parameters
type
: power save type
-
esp_err_t
esp_wifi_get_ps
(wifi_ps_type_t *type)¶ Get current power save type.
- Attention
- Default power save type is WIFI_PS_NONE.
- Return
- ESP_ERR_NOT_SUPPORTED: not supported yet
- Parameters
type
: store current power save type
-
esp_err_t
esp_wifi_set_protocol
(wifi_interface_t ifx, uint8_t protocol_bitmap)¶ Set protocol type of specified interface The default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G)
- Attention
- Currently we only support 802.11b or 802.11bg or 802.11bgn mode
- Attention
- Please call this API in SYSTEM_EVENT_STA_START event
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_IF: invalid interface
- others: refer to error codes in esp_err.h
- Parameters
ifx
: interfacesprotocol_bitmap
: WiFi protocol bitmap
-
esp_err_t
esp_wifi_get_protocol
(wifi_interface_t ifx, uint8_t *protocol_bitmap)¶ Get the current protocol bitmap of the specified interface.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_IF: invalid interface
- ESP_ERR_INVALID_ARG: invalid argument
- others: refer to error codes in esp_err.h
- Parameters
ifx
: interfaceprotocol_bitmap
: store current WiFi protocol bitmap of interface ifx
-
esp_err_t
esp_wifi_set_bandwidth
(wifi_interface_t ifx, wifi_bandwidth_t bw)¶ Set the bandwidth of ESP8266 specified interface.
- Attention
- 1. API return false if try to configure an interface that is not enabled
- Attention
- 2. WIFI_BW_HT40 is supported only when the interface support 11N
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_IF: invalid interface
- ESP_ERR_INVALID_ARG: invalid argument
- others: refer to error codes in esp_err.h
- Parameters
ifx
: interface to be configuredbw
: bandwidth
-
esp_err_t
esp_wifi_get_bandwidth
(wifi_interface_t ifx, wifi_bandwidth_t *bw)¶ Get the bandwidth of ESP8266 specified interface.
- Attention
- 1. API return false if try to get a interface that is not enable
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_IF: invalid interface
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
ifx
: interface to be configuredbw
: store bandwidth of interface ifx
-
esp_err_t
esp_wifi_set_channel
(uint8_t primary, wifi_second_chan_t second)¶ Set primary/secondary channel of ESP8266.
- Attention
- 1. This is a special API for sniffer
- Attention
- 2. This API should be called after esp_wifi_start() or esp_wifi_set_promiscuous()
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_IF: invalid interface
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
primary
: for HT20, primary is the channel number, for HT40, primary is the primary channelsecond
: for HT20, second is ignored, for HT40, second is the second channel
-
esp_err_t
esp_wifi_get_channel
(uint8_t *primary, wifi_second_chan_t *second)¶ Get the primary/secondary channel of ESP8266.
- Attention
- 1. API return false if try to get a interface that is not enable
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
primary
: store current primary channelsecond
: store current second channel
-
esp_err_t
esp_wifi_set_country
(const wifi_country_t *country)¶ configure country info
- Attention
- 1. The default country is {.cc=”CN”, .schan=1, .nchan=13, policy=WIFI_COUNTRY_POLICY_AUTO}
- Attention
- 2. When the country policy is WIFI_COUNTRY_POLICY_AUTO, the country info of the AP to which the station is connected is used. E.g. if the configured country info is {.cc=”USA”, .schan=1, .nchan=11} and the country info of the AP to which the station is connected is {.cc=”JP”, .schan=1, .nchan=14} then the country info that will be used is {.cc=”JP”, .schan=1, .nchan=14}. If the station disconnected from the AP the country info is set back back to the country info of the station automatically, {.cc=”USA”, .schan=1, .nchan=11} in the example.
- Attention
- 3. When the country policy is WIFI_COUNTRY_POLICY_MANUAL, always use the configured country info.
- Attention
- 4. When the country info is changed because of configuration or because the station connects to a different external AP, the country IE in probe response/beacon of the soft-AP is changed also.
- Attention
- 5. The country configuration is not stored into flash
- Attention
- 6. This API doesn’t validate the per-country rules, it’s up to the user to fill in all fields according to local regulations.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
country
: the configured country info
-
esp_err_t
esp_wifi_get_country
(wifi_country_t *country)¶ get the current country info
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
country
: country info
-
esp_err_t
esp_wifi_set_mac
(wifi_interface_t ifx, const uint8_t mac[6])¶ Set MAC address of the ESP8266 WiFi station or the soft-AP interface.
- Attention
- 1. This API can only be called when the interface is disabled
- Attention
- 2. ESP8266 soft-AP and station have different MAC addresses, do not set them to be the same.
- Attention
- 3. The bit 0 of the first byte of ESP8266 MAC address can not be 1. For example, the MAC address can set to be “1a:XX:XX:XX:XX:XX”, but can not be “15:XX:XX:XX:XX:XX”.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- ESP_ERR_WIFI_IF: invalid interface
- ESP_ERR_WIFI_MAC: invalid mac address
- ESP_ERR_WIFI_MODE: WiFi mode is wrong
- others: refer to error codes in esp_err.h
- Parameters
ifx
: interfacemac
: the MAC address
-
esp_err_t
esp_wifi_get_mac
(wifi_interface_t ifx, uint8_t mac[6])¶ Get mac of specified interface.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- ESP_ERR_WIFI_IF: invalid interface
- Parameters
ifx
: interfacemac
: store mac of the interface ifx
-
esp_err_t
esp_wifi_set_promiscuous_rx_cb
(wifi_promiscuous_cb_t cb)¶ Register the RX callback function in the promiscuous mode.
Each time a packet is received, the registered callback function will be called.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- Parameters
cb
: callback
-
esp_err_t
esp_wifi_set_promiscuous
(bool en)¶ Enable the promiscuous mode.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- Parameters
en
: false - disable, true - enable
-
esp_err_t
esp_wifi_get_promiscuous
(bool *en)¶ Get the promiscuous mode.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
en
: store the current status of promiscuous mode
-
esp_err_t
esp_wifi_set_promiscuous_filter
(const wifi_promiscuous_filter_t *filter)¶ Enable the promiscuous mode packet type filter.
- Note
- The default filter is to filter all packets except WIFI_PKT_MISC
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- Parameters
filter
: the packet type filtered in promiscuous mode.
-
esp_err_t
esp_wifi_get_promiscuous_filter
(wifi_promiscuous_filter_t *filter)¶ Get the promiscuous filter.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
filter
: store the current status of promiscuous filter
-
esp_err_t
esp_wifi_set_config
(wifi_interface_t interface, wifi_config_t *conf)¶ Set the configuration of the ESP8266 STA or AP.
- Attention
- 1. This API can be called only when specified interface is enabled, otherwise, API fail
- Attention
- 2. For station configuration, bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.
- Attention
- 3. ESP8266 is limited to only one channel, so when in the soft-AP+station mode, the soft-AP will adjust its channel automatically to be the same as the channel of the ESP8266 station.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- ESP_ERR_WIFI_IF: invalid interface
- ESP_ERR_WIFI_MODE: invalid mode
- ESP_ERR_WIFI_PASSWORD: invalid password
- ESP_ERR_WIFI_NVS: WiFi internal NVS error
- others: refer to the erro code in esp_err.h
- Parameters
interface
: interfaceconf
: station or soft-AP configuration
-
esp_err_t
esp_wifi_set_promiscuous_ctrl_filter
(const wifi_promiscuous_filter_t *filter)¶ Enable subtype filter of the control packet in promiscuous mode.
- Note
- The default filter is to filter none control packet.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- Parameters
filter
: the subtype of the control packet filtered in promiscuous mode.
-
esp_err_t
esp_wifi_get_promiscuous_ctrl_filter
(wifi_promiscuous_filter_t *filter)¶ Get the subtype filter of the control packet in promiscuous mode.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_ARG: invalid argument
- Parameters
filter
: store the current status of subtype filter of the control packet in promiscuous mode
-
esp_err_t
esp_wifi_get_config
(wifi_interface_t interface, wifi_config_t *conf)¶ Get configuration of specified interface.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- ESP_ERR_WIFI_IF: invalid interface
- Parameters
interface
: interfaceconf
: station or soft-AP configuration
-
esp_err_t
esp_wifi_ap_get_sta_list
(wifi_sta_list_t *sta)¶ Get STAs associated with soft-AP.
- Attention
- SSC only API
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- ESP_ERR_WIFI_MODE: WiFi mode is wrong
- ESP_ERR_WIFI_CONN: WiFi internal error, the station/soft-AP control block is invalid
- Parameters
sta
: station list ap can get the connected sta’s phy mode info through the struct member phy_11b,phy_11g,phy_11n,phy_lr in the wifi_sta_info_t struct. For example, phy_11b = 1 imply that sta support 802.11b mode
-
esp_err_t
esp_wifi_set_storage
(wifi_storage_t storage)¶ Set the WiFi API configuration storage type.
- Attention
- 1. The default value is WIFI_STORAGE_FLASH
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
storage
: : storage type
-
esp_err_t
esp_wifi_set_auto_connect
(bool en)¶ Set auto connect The default value is true.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_MODE: WiFi internal error, the station/soft-AP control block is invalid
- others: refer to error code in esp_err.h
- Parameters
en
: : true - enable auto connect / false - disable auto connect
-
esp_err_t
esp_wifi_get_auto_connect
(bool *en)¶ Get the auto connect flag.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
en
: store current auto connect configuration
-
esp_err_t
esp_wifi_set_vendor_ie
(bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie)¶ Set 802.11 Vendor-Specific Information Element.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init()
- ESP_ERR_INVALID_ARG: Invalid argument, including if first byte of vnd_ie is not WIFI_VENDOR_IE_ELEMENT_ID (0xDD) or second byte is an invalid length.
- ESP_ERR_NO_MEM: Out of memory
- Parameters
enable
: If true, specified IE is enabled. If false, specified IE is removed.type
: Information Element type. Determines the frame type to associate with the IE.idx
: Index to set or clear. Each IE type can be associated with up to two elements (indices 0 & 1).vnd_ie
: Pointer to vendor specific element data. First 6 bytes should be a header with fields matching vendor_ie_data_t. If enable is false, this argument is ignored and can be NULL. Data does not need to remain valid after the function returns.
-
esp_err_t
esp_wifi_set_vendor_ie_cb
(esp_vendor_ie_cb_t cb, void *ctx)¶ Register Vendor-Specific Information Element monitoring callback.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- Parameters
cb
: Callback functionctx
: Context argument, passed to callback function.
-
esp_err_t
esp_wifi_set_max_tx_power
(int8_t power)¶ Set maximum WiFi transmiting power.
- Attention
- Please Call this API after calling esp_wifi_start()
- Attention
- WiFi transmiting power is divided to six levels in phy init data. Level0 represents highest transmiting power and level5 represents lowest transmiting power. Packets of different rates are transmitted in different powers according to the configuration in phy init data. This API only sets maximum WiFi transmiting power. If this API is called, the transmiting power of every packet will be less than or equal to the value set by this API. If this API is not called, the value of maximum transmitting power set in phy_init_data.bin or menuconfig (depend on whether to use phy init data in partition or not) will be used. Default value is level0. Values passed in power are mapped to transmit power levels as follows:
- [82, 127]: level0
- [78, 81]: level1
- [74, 77]: level2
- [68, 73]: level3
- [64, 67]: level4
- [56, 63]: level5
- [49, 55]: level5 - 2dBm
- [33, 48]: level5 - 6dBm
- [25, 32]: level5 - 8dBm
- [13, 24]: level5 - 11dBm
- [ 1, 12]: level5 - 14dBm
- [-128, 0]: level5 - 17.5dBm
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start
- Parameters
power
: Maximum WiFi transmiting power.
-
void
esp_wifi_set_max_tx_power_via_vdd33
(uint16_t vdd33)¶ Adjust RF Tx Power according to VDD33; unit : 1/1024 V.
- Attention
- When TOUT pin is suspended, VDD33 can be got by esp_wifi_get_vdd33. When TOUT pin is wired to external circuitry, esp_wifi_get_vdd33 can not be used.
- Attention
- This api only worked when it is called, please call this api every day or hour according to power consumption.
- Parameters
vdd33
: unit is 1/1024V, range [1900, 3300].
-
uint16_t
esp_wifi_get_vdd33
(void)¶ Measure the power voltage of VDD3P3 pin 3 and 4; unit: 1/1024 V.
- Attention
- esp_wifi_get_vdd33 can only be called when TOUT pin is suspended.
- Attention
- The 107th byte in esp_init_data_default.bin (0 ~ 127 bytes) is named as vdd33_const. When TOUT pin is suspended, vdd33_const must be set as 0xFF, which is 255.
- Attention
- The return value of esp_wifi_get_vdd33 may be different in different Wi-Fi modes, for example, in Modem-sleep mode or in normal Wi-Fi working mode.
- Return
- the power voltage of vdd33 pin 3 and 4
-
esp_err_t
esp_wifi_get_max_tx_power
(int8_t *power)¶ Get maximum WiFi transmiting power.
- Attention
- This API gets maximum WiFi transmiting power. Values got from power are mapped to transmit power levels as follows:
- 78: 19.5dBm
- 76: 19dBm
- 74: 18.5dBm
- 68: 17dBm
- 60: 15dBm
- 52: 13dBm
- 44: 11dBm
- 34: 8.5dBm
- 28: 7dBm
- 20: 5dBm
- 8: 2dBm
- -4: -1dBm
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start
- ESP_ERR_INVALID_ARG: invalid argument
- Parameters
power
: Maximum WiFi transmiting power.
-
esp_err_t
esp_wifi_set_event_mask
(uint32_t mask)¶ Set mask to enable or disable some WiFi events.
- Attention
- 1. Mask can be created by logical OR of various WIFI_EVENT_MASK_ constants. Events which have corresponding bit set in the mask will not be delivered to the system event handler.
- Attention
- 2. Default WiFi event mask is WIFI_EVENT_MASK_AP_PROBEREQRECVED.
- Attention
- 3. There may be lots of stations sending probe request data around. Don’t unmask this event unless you need to receive probe request data.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- Parameters
mask
: WiFi event mask.
-
esp_err_t
esp_wifi_get_event_mask
(uint32_t *mask)¶ Get mask of WiFi events.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_ARG: invalid argument
- Parameters
mask
: WiFi event mask.
-
esp_err_t
esp_wifi_80211_tx
(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq)¶ Send user-define 802.11 packets.
- Attention
- 1. Packet has to be the whole 802.11 packet, does not include the FCS. The length of the packet has to be longer than the minimum length of the header of 802.11 packet which is 24 bytes, and less than 1400 bytes.
- Attention
- 2. Duration area is invalid for user, it will be filled in SDK.
- Attention
- 3. The rate of sending packet is same as the management packet which is the same as the system rate of sending packets.
- Attention
- 4. Only after the previous packet was sent, entered the sent callback, the next packet is allowed to send. Otherwise, wifi_send_pkt_freedom will return fail.
- Return
- ESP_OK, succeed;
- Return
- ESP_FAIL, fail.
- Parameters
ifx
: interface if the Wi-Fi mode is Station, the ifx should be WIFI_IF_STA. If the Wi-Fi mode is SoftAP, the ifx should be WIFI_IF_AP. If the Wi-Fi mode is Station+SoftAP, the ifx should be WIFI_IF_STA or WIFI_IF_AP. If the ifx is wrong, the API returns ESP_ERR_WIFI_IF.buffer
: pointer of packetlen
: packet lengthen_sys_seq
: follow the system’s 802.11 packets sequence number or not, if it is true, the sequence number will be increased 1 every time a packet sent.
-
wifi_state_t
esp_wifi_get_state
(void)¶ Operation system start check time and enter sleep.
- Note
- This function is called by system, user should not call this
- Return
- wifi state
-
esp_err_t
esp_wifi_set_rssi_threshold
(int32_t rssi)¶ Set RSSI threshold below which APP will get an event.
- Attention
- This API needs to be called every time after WIFI_EVENT_STA_BSS_RSSI_LOW event is received.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_ARG: invalid argument
- Parameters
rssi
: threshold value in dbm between -100 to 0
-
int64_t
esp_wifi_get_tsf_time
(wifi_interface_t interface)¶ Get the TSF time In Station mode or SoftAP+Station mode if station is not connected or station doesn’t receive at least one beacon after connected, will return 0.
- Attention
- Enabling power save may cause the return value inaccurate, except WiFi modem sleep
- Return
- 0 or the TSF time
- Parameters
interface
: The interface whose tsf_time is to be retrieved.
-
esp_err_t
esp_wifi_set_inactive_time
(wifi_interface_t ifx, uint16_t sec)¶ Set the inactive time of the ESP32 STA or AP.
- Attention
- 1. For Station, If the station does not receive a beacon frame from the connected SoftAP during the inactive time, disconnect from SoftAP. Default 6s.
- Attention
- 2. For SoftAP, If the softAP doesn’t receive any data from the connected STA during inactive time, the softAP will force deauth the STA. Default is 300s.
- Attention
- 3. The inactive time configuration is not stored into flash
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
- ESP_ERR_WIFI_ARG: invalid argument, For Station, if sec is less than 3. For SoftAP, if sec is less than 10.
- Parameters
ifx
: interface to be configured.sec
: Inactive time. Unit seconds.
-
esp_err_t
esp_wifi_get_inactive_time
(wifi_interface_t ifx, uint16_t *sec)¶ Get inactive time of specified interface.
- Return
- ESP_OK: succeed
- ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
- ESP_ERR_WIFI_ARG: invalid argument
- Parameters
ifx
: Interface to be configured.sec
: Inactive time. Unit seconds.
Structures¶
-
struct
wifi_init_config_t
¶ WiFi stack configuration parameters passed to esp_wifi_init call.
Public Members
-
system_event_handler_t
event_handler
¶ WiFi event handler
-
void *
osi_funcs
¶ WiFi OS functions
-
uint8_t
qos_enable
¶ WiFi QOS feature enable flag
-
uint8_t
ampdu_rx_enable
¶ WiFi AMPDU RX feature enable flag
-
uint8_t
rx_ba_win
¶ WiFi Block Ack RX window size
-
uint8_t
rx_ampdu_buf_num
¶ WiFi AMPDU RX buffer number
-
uint32_t
rx_ampdu_buf_len
¶ WiFi AMPDU RX buffer length
-
uint32_t
rx_max_single_pkt_len
¶ WiFi RX max single packet size
-
uint32_t
rx_buf_len
¶ WiFi RX buffer size
-
uint8_t
amsdu_rx_enable
¶ WiFi AMSDU RX feature enable flag
-
uint8_t
rx_buf_num
¶ WiFi RX buffer number
-
uint8_t
rx_pkt_num
¶ WiFi RX packet number
-
uint8_t
left_continuous_rx_buf_num
¶ WiFi Rx left continuous rx buffer number
-
uint8_t
tx_buf_num
¶ WiFi TX buffer number
-
uint8_t
nvs_enable
¶ WiFi NVS flash enable flag
-
uint8_t
nano_enable
¶ Nano option for printf/scan family enable flag
-
uint8_t
wpa3_sae_enable
¶ WiFi WPA3 feature enable flag
-
uint32_t
magic
¶ WiFi init magic number, it should be the last field
-
system_event_handler_t
Macros¶
-
ESP_ERR_WIFI_NOT_INIT
¶ WiFi driver was not installed by esp_wifi_init
-
ESP_ERR_WIFI_NOT_STARTED
¶ WiFi driver was not started by esp_wifi_start
-
ESP_ERR_WIFI_NOT_STOPPED
¶ WiFi driver was not stopped by esp_wifi_stop
-
ESP_ERR_WIFI_IF
¶ WiFi interface error
-
ESP_ERR_WIFI_MODE
¶ WiFi mode error
-
ESP_ERR_WIFI_STATE
¶ WiFi internal state error
-
ESP_ERR_WIFI_CONN
¶ WiFi internal control block of station or soft-AP error
-
ESP_ERR_WIFI_NVS
¶ WiFi internal NVS module error
-
ESP_ERR_WIFI_MAC
¶ MAC address is invalid
-
ESP_ERR_WIFI_SSID
¶ SSID is invalid
-
ESP_ERR_WIFI_PASSWORD
¶ Password is invalid
-
ESP_ERR_WIFI_TIMEOUT
¶ Timeout error
-
ESP_ERR_WIFI_WAKE_FAIL
¶ WiFi is in sleep state(RF closed) and wakeup fail
-
ESP_ERR_WIFI_WOULD_BLOCK
¶ The caller would block
-
ESP_ERR_WIFI_NOT_CONNECT
¶ Station still in disconnect status
-
ESP_ERR_WIFI_PM_MODE_OPEN
¶ Wifi is in min/max modem sleep mode
-
ESP_ERR_WIFI_FPM_MODE
¶ Have not enable fpm mode
-
ESP_WIFI_PARAM_USE_NVS
¶
-
WIFI_AMPDU_RX_ENABLED
¶
-
WIFI_AMPDU_RX_BA_WIN
¶
-
WIFI_RX_MAX_SINGLE_PKT_LEN
¶
-
WIFI_AMPDU_RX_AMPDU_BUF_LEN
¶
-
WIFI_AMPDU_RX_AMPDU_BUF_NUM
¶
-
WIFI_HW_RX_BUFFER_LEN
¶
-
WIFI_QOS_ENABLED
¶
-
WIFI_AMSDU_RX_ENABLED
¶
-
WIFI_NVS_ENABLED
¶
-
WIFI_WPA3_ENABLED
¶
-
WIFI_INIT_CONFIG_MAGIC
¶
-
WIFI_INIT_CONFIG_DEFAULT
()¶
Type Definitions¶
-
typedef void (*
wifi_promiscuous_cb_t
)(void *buf, wifi_promiscuous_pkt_type_t type)¶ The RX callback function in the promiscuous mode. Each time a packet is received, the callback function will be called.
- Parameters
buf
: Data received. Type of data in buffer (wifi_promiscuous_pkt_t or wifi_pkt_rx_ctrl_t) indicated by ‘type’ parameter.type
: promiscuous packet type.
-
typedef void (*
esp_vendor_ie_cb_t
)(void *ctx, wifi_vendor_ie_type_t type, const uint8_t sa[6], const vendor_ie_data_t *vnd_ie, int rssi)¶ Function signature for received Vendor-Specific Information Element callback.
- Parameters
ctx
: Context argument, as passed to esp_wifi_set_vendor_ie_cb() when registering callback.type
: Information element type, based on frame type received.sa
: Source 802.11 address.vnd_ie
: Pointer to the vendor specific element data received.rssi
: Received signal strength indication.
Header File¶
Unions¶
-
union
wifi_scan_time_t
¶ - #include <esp_wifi_types.h>
Aggregate of active & passive scan time per channel.
Public Members
-
wifi_active_scan_time_t
active
¶ active scan time per channel, units: millisecond.
-
uint32_t
passive
¶ passive scan time per channel, units: millisecond, values above 1500ms may cause station to disconnect from AP and are not recommended.
-
wifi_active_scan_time_t
-
union
wifi_config_t
¶ - #include <esp_wifi_types.h>
Configuration data for ESP8266 AP or STA.
The usage of this union (for ap or sta configuration) is determined by the accompanying interface argument passed to esp_wifi_set_config() or esp_wifi_get_config()
Structures¶
-
struct
wifi_country_t
¶ Structure describing WiFi country-based regional restrictions.
-
struct
wifi_active_scan_time_t
¶ Range of active scan times per channel.
-
struct
wifi_scan_config_t
¶ Parameters for an SSID scan.
Public Members
-
uint8_t *
ssid
¶ SSID of AP
-
uint8_t *
bssid
¶ MAC address of AP
-
uint8_t
channel
¶ channel, scan the specific channel
enable to scan AP whose SSID is hidden
-
wifi_scan_type_t
scan_type
¶ scan type, active or passive
-
wifi_scan_time_t
scan_time
¶ scan time per channel
-
uint8_t *
-
struct
wifi_ap_record_t
¶ Description of a WiFi AP.
Public Members
-
uint8_t
bssid
[6]¶ MAC address of AP
-
uint8_t
ssid
[33]¶ SSID of AP
-
uint8_t
primary
¶ channel of AP
-
wifi_second_chan_t
second
¶ secondary channel of AP
-
int8_t
rssi
¶ signal strength of AP
-
int16_t
freq_offset
¶ frequency offset of AP
-
wifi_auth_mode_t
authmode
¶ authmode of AP
-
wifi_cipher_type_t
pairwise_cipher
¶ pairwise cipher of AP
-
wifi_cipher_type_t
group_cipher
¶ group cipher of AP
-
wifi_ant_t
ant
¶ antenna used to receive beacon from AP
-
uint32_t
phy_11b
¶ bit: 0 flag to identify if 11b mode is enabled or not
-
uint32_t
phy_11g
¶ bit: 1 flag to identify if 11g mode is enabled or not
-
uint32_t
phy_11n
¶ bit: 2 flag to identify if 11n mode is enabled or not
-
uint32_t
phy_lr
¶ bit: 3 flag to identify if low rate is enabled or not
-
uint32_t
wps
¶ bit: 4 flag to identify if WPS is supported or not
-
uint32_t
reserved
¶ bit: 5..31 reserved
-
wifi_country_t
country
¶ country information of AP
-
uint8_t
-
struct
wifi_fast_scan_threshold_t
¶ Structure describing parameters for a WiFi fast scan.
Public Members
-
int8_t
rssi
¶ The minimum rssi to accept in the fast scan mode
-
wifi_auth_mode_t
authmode
¶ The weakest authmode to accept in the fast scan mode
-
int8_t
-
struct
esp_pm_config_t
¶ Wi-Fi Power management config for ESP8266.
Pass a pointer to this structure as an argument to esp_wifi_set_pm_config function.
Public Members
-
uint8_t
max_bcn_early_ms
¶ max beacon early time(2~15ms), default 4ms.
-
uint8_t
max_bcn_timeout_ms
¶ max beacon timeout time(12~32ms), default 24ms.
-
uint8_t
wait_time
¶ wait time before close RF (10~100ms), default 20ms.
-
uint8_t
wait_tx_cnt
¶ wait cnt after tx packet done(1~20), default 2, real time = wait_tx_cnt * wait_time.
-
uint8_t
wait_rx_bdata_cnt
¶ wait cnt after rx broadcast packet(1~100), default 2, real time = wait_tx_cnt * wait_time.
-
uint8_t
wait_rx_udata_cnt
¶ wait cnt after rx unicast packet(1~100), default 4, real time = wait_tx_cnt * wait_time.
-
bool
recv_bdata
¶ Receive broadcast/multicast packet or not when WiFi in power save. default true(receive broadcast/multicast packet)
-
uint8_t
-
struct
esp_pm_config_esp8266_t
¶ Power management config for ESP8266.
Pass a pointer to this structure as an argument to esp_pm_configure function.
-
struct
wifi_pmf_config_t
¶ Configuration structure for Protected Management Frame
-
struct
wifi_ap_config_t
¶ Soft-AP configuration settings for the ESP8266.
Public Members
-
uint8_t
ssid
[32]¶ SSID of ESP8266 soft-AP
-
uint8_t
password
[64]¶ Password of ESP8266 soft-AP
-
uint8_t
ssid_len
¶ Length of SSID. If softap_config.ssid_len==0, check the SSID until there is a termination character; otherwise, set the SSID length according to softap_config.ssid_len.
-
uint8_t
channel
¶ Channel of ESP8266 soft-AP
-
wifi_auth_mode_t
authmode
¶ Auth mode of ESP8266 soft-AP. Do not support AUTH_WEP in soft-AP mode
Broadcast SSID or not, default 0, broadcast the SSID
-
uint8_t
max_connection
¶ Max number of stations allowed to connect in, default 4, max 4
-
uint16_t
beacon_interval
¶ Beacon interval, 100 ~ 60000 ms, default 100 ms
-
uint8_t
-
struct
wifi_sta_config_t
¶ STA configuration settings for the ESP8266.
Public Members
-
uint8_t
ssid
[32]¶ SSID of target AP
-
uint8_t
password
[64]¶ password of target AP
-
wifi_scan_method_t
scan_method
¶ do all channel scan or fast scan
-
bool
bssid_set
¶ whether set MAC address of target AP or not. Generally, station_config.bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.
-
uint8_t
bssid
[6]¶ MAC address of target AP
-
uint8_t
channel
¶ channel of target AP. Set to 1~13 to scan starting from the specified channel before connecting to AP. If the channel of AP is unknown, set it to 0.
-
uint16_t
listen_interval
¶ Listen interval for ESP8266 station to receive beacon when WIFI_PS_MAX_MODEM is set. Units: AP beacon intervals. Defaults to 3 if set to 0.
-
wifi_sort_method_t
sort_method
¶ sort the connect AP in the list by rssi or security mode
-
wifi_fast_scan_threshold_t
threshold
¶ When scan_method is set to WIFI_FAST_SCAN, only APs which have an auth mode that is more secure than the selected auth mode and a signal stronger than the minimum RSSI will be used.
-
wifi_pmf_config_t
pmf_cfg
¶ Configuration for Protected Management Frame. Will be advertized in RSN Capabilities in RSN IE.
-
uint32_t
rm_enabled
¶ Whether radio measurements are enabled for the connection
-
uint32_t
btm_enabled
¶ Whether BTM is enabled for the connection
-
uint32_t
reserved
¶ Reserved for future feature set
-
uint8_t
-
struct
wifi_sta_info_t
¶ Description of STA associated with AP.
Public Members
-
uint8_t
mac
[6]¶ mac address
-
uint32_t
phy_11b
¶ bit: 0 flag to identify if 11b mode is enabled or not
-
uint32_t
phy_11g
¶ bit: 1 flag to identify if 11g mode is enabled or not
-
uint32_t
phy_11n
¶ bit: 2 flag to identify if 11n mode is enabled or not
-
uint32_t
phy_lr
¶ bit: 3 flag to identify if low rate is enabled or not
-
uint32_t
reserved
¶ bit: 4..31 reserved
-
uint8_t
-
struct
wifi_sta_list_t
¶ List of stations associated with the ESP8266 Soft-AP.
Public Members
-
wifi_sta_info_t
sta
[ESP_WIFI_MAX_CONN_NUM
]¶ station list
-
int
num
¶ number of stations in the list (other entries are invalid)
-
wifi_sta_info_t
-
struct
vendor_ie_data_t
¶ Vendor Information Element header.
The first bytes of the Information Element will match this header. Payload follows.
Public Members
-
uint8_t
element_id
¶ Should be set to WIFI_VENDOR_IE_ELEMENT_ID (0xDD)
-
uint8_t
length
¶ Length of all bytes in the element data following this field. Minimum 4.
-
uint8_t
vendor_oui
[3]¶ Vendor identifier (OUI).
-
uint8_t
vendor_oui_type
¶ Vendor-specific OUI type.
-
uint8_t
payload
[0]¶ Payload. Length is equal to value in ‘length’ field, minus 4.
-
uint8_t
-
struct
wifi_pkt_rx_ctrl_t
¶ Received packet radio metadata header, this is the common header at the beginning of all promiscuous mode RX callback buffers.
Public Members
-
signed
rssi
¶ signal intensity of packet
-
unsigned
rate
¶ data rate
-
unsigned
is_group
¶ usually not used
-
unsigned
__pad0__
¶ reserve
-
unsigned
sig_mode
¶ 0:is not 11n packet; 1:is 11n packet
-
unsigned
legacy_length
¶ Length of 11bg mode packet
-
unsigned
damatch0
¶ usually not used
-
unsigned
damatch1
¶ usually not used
-
unsigned
bssidmatch0
¶ usually not used
-
unsigned
bssidmatch1
¶ usually not used
-
unsigned
mcs
¶ if is 11n packet, shows the modulation(range from 0 to 76)
-
unsigned
cwb
¶ if is 11n packet, shows if is HT40 packet or not
-
unsigned
HT_length
¶ Length of 11n mode packet
-
unsigned
smoothing
¶ reserve
-
unsigned
not_sounding
¶ reserve
-
unsigned
__pad1__
¶ reserve
-
unsigned
aggregation
¶ Aggregation
-
unsigned
stbc
¶ STBC
-
unsigned
fec_coding
¶ Flag is set for 11n packets which are LDPC
-
unsigned
sgi
¶ SGI
-
unsigned
rxend_state
¶ usually not used
-
unsigned
ampdu_cnt
¶ ampdu cnt
-
unsigned
channel
¶ which channel this packet in
-
unsigned
__pad2__
¶ reserve
-
signed
noise_floor
¶ usually not used
-
signed
-
struct
wifi_promiscuous_pkt_t
¶ Payload passed to ‘buf’ parameter of promiscuous mode RX callback.
Public Members
-
wifi_pkt_rx_ctrl_t
rx_ctrl
¶ metadata header
-
uint8_t
payload
[0]¶ Data or management frame payload. Length of payload is min(112, (pkt->rx_ctrl.sig_mode ? pkt->rx_ctrl.HT_length : pkt->rx_ctrl.legacy_length)) Type of content determined by packet type argument of callback.
-
wifi_pkt_rx_ctrl_t
-
struct
wifi_promiscuous_filter_t
¶ Mask for filtering different packet types in promiscuous mode.
Public Members
-
uint32_t
filter_mask
¶ OR of one or more filter values WIFI_PROMIS_FILTER_*
-
uint32_t
-
struct
wifi_tx_status_t
¶ WIFI hardware TX status.
-
struct
wifi_event_sta_scan_done_t
¶ Argument structure for WIFI_EVENT_SCAN_DONE event
-
struct
wifi_event_sta_connected_t
¶ Argument structure for WIFI_EVENT_STA_CONNECTED event
-
struct
wifi_event_sta_authmode_change_t
¶ Argument structure for WIFI_EVENT_STA_AUTHMODE_CHANGE event
Public Members
-
wifi_auth_mode_t
old_mode
¶ the old auth mode of AP
-
wifi_auth_mode_t
new_mode
¶ the new auth mode of AP
-
wifi_auth_mode_t
-
struct
wifi_event_sta_wps_er_pin_t
¶ Argument structure for WIFI_EVENT_STA_WPS_ER_PIN event
Public Members
-
uint8_t
pin_code
[8]¶ PIN code of station in enrollee mode
-
uint8_t
-
struct
wifi_event_ap_staconnected_t
¶ Argument structure for WIFI_EVENT_AP_STACONNECTED event
-
struct
wifi_event_ap_stadisconnected_t
¶ Argument structure for WIFI_EVENT_AP_STADISCONNECTED event
-
struct
wifi_event_ap_probe_req_rx_t
¶ Argument structure for WIFI_EVENT_AP_PROBEREQRECVED event
-
struct
wifi_event_sta_disconnected_t
¶ Argument structure for WIFI_EVENT_STA_DISCONNECTED event
Macros¶
-
WIFI_IF_STA
¶
-
WIFI_IF_AP
¶
-
WIFI_PS_MODEM
¶
-
WIFI_PROTOCOL_11B
¶
-
WIFI_PROTOCOL_11G
¶
-
WIFI_PROTOCOL_11N
¶
-
WIFI_PROTOCOL_LR
¶
-
ESP_WIFI_MAX_CONN_NUM
¶ max number of stations which can connect to ESP8266 soft-AP
-
WIFI_VENDOR_IE_ELEMENT_ID
¶
-
WIFI_PROMIS_FILTER_MASK_ALL
¶ filter all packets
-
WIFI_PROMIS_FILTER_MASK_MGMT
¶ filter the packets with type of WIFI_PKT_MGMT
-
WIFI_PROMIS_FILTER_MASK_CTRL
¶ filter the packets with type of WIFI_PKT_CTRL
-
WIFI_PROMIS_FILTER_MASK_DATA
¶ filter the packets with type of WIFI_PKT_DATA
-
WIFI_PROMIS_FILTER_MASK_MISC
¶ filter the packets with type of WIFI_PKT_MISC
-
WIFI_PROMIS_CTRL_FILTER_MASK_ALL
¶ filter all control packets
-
WIFI_PROMIS_CTRL_FILTER_MASK_WRAPPER
¶ filter the control packets with subtype of Control Wrapper
-
WIFI_PROMIS_CTRL_FILTER_MASK_BAR
¶ filter the control packets with subtype of Block Ack Request
-
WIFI_PROMIS_CTRL_FILTER_MASK_BA
¶ filter the control packets with subtype of Block Ack
-
WIFI_PROMIS_CTRL_FILTER_MASK_PSPOLL
¶ filter the control packets with subtype of PS-Poll
-
WIFI_PROMIS_CTRL_FILTER_MASK_RTS
¶ filter the control packets with subtype of RTS
-
WIFI_PROMIS_CTRL_FILTER_MASK_CTS
¶ filter the control packets with subtype of CTS
-
WIFI_PROMIS_CTRL_FILTER_MASK_ACK
¶ filter the control packets with subtype of ACK
-
WIFI_PROMIS_CTRL_FILTER_MASK_CFEND
¶ filter the control packets with subtype of CF-END
-
WIFI_PROMIS_CTRL_FILTER_MASK_CFENDACK
¶ filter the control packets with subtype of CF-END+CF-ACK
-
WIFI_EVENT_MASK_ALL
¶ mask all WiFi events
-
WIFI_EVENT_MASK_NONE
¶ mask none of the WiFi events
-
WIFI_EVENT_MASK_AP_PROBEREQRECVED
¶ mask SYSTEM_EVENT_AP_PROBEREQRECVED event
-
MAX_SSID_LEN
¶
-
MAX_PASSPHRASE_LEN
¶
-
MAX_WPS_AP_CRED
¶
Enumerations¶
-
enum
wifi_mode_t
¶ Values:
-
WIFI_MODE_NULL
= 0¶ null mode
-
WIFI_MODE_STA
¶ WiFi station mode
-
WIFI_MODE_AP
¶ WiFi soft-AP mode
-
WIFI_MODE_APSTA
¶ WiFi station + soft-AP mode
-
WIFI_MODE_MAX
¶
-
-
enum
wifi_country_policy_t
¶ Values:
-
WIFI_COUNTRY_POLICY_AUTO
¶ Country policy is auto, use the country info of AP to which the station is connected
-
WIFI_COUNTRY_POLICY_MANUAL
¶ Country policy is manual, always use the configured country info
-
-
enum
wifi_auth_mode_t
¶ Values:
-
WIFI_AUTH_OPEN
= 0¶ authenticate mode : open
-
WIFI_AUTH_WEP
¶ authenticate mode : WEP
-
WIFI_AUTH_WPA_PSK
¶ authenticate mode : WPA_PSK
-
WIFI_AUTH_WPA2_PSK
¶ authenticate mode : WPA2_PSK
-
WIFI_AUTH_WPA_WPA2_PSK
¶ authenticate mode : WPA_WPA2_PSK
-
WIFI_AUTH_WPA2_ENTERPRISE
¶ authenticate mode : WPA2_ENTERPRISE
-
WIFI_AUTH_WPA3_PSK
¶ authenticate mode : WPA3_PSK
-
WIFI_AUTH_WPA2_WPA3_PSK
¶ authenticate mode : WPA2_WPA3_PSK
-
WIFI_AUTH_MAX
¶
-
-
enum
wifi_err_reason_t
¶ Values:
-
WIFI_REASON_UNSPECIFIED
= 1¶
-
WIFI_REASON_AUTH_EXPIRE
= 2¶
-
WIFI_REASON_AUTH_LEAVE
= 3¶
-
WIFI_REASON_ASSOC_EXPIRE
= 4¶
-
WIFI_REASON_ASSOC_TOOMANY
= 5¶
-
WIFI_REASON_NOT_AUTHED
= 6¶
-
WIFI_REASON_NOT_ASSOCED
= 7¶
-
WIFI_REASON_ASSOC_LEAVE
= 8¶
-
WIFI_REASON_ASSOC_NOT_AUTHED
= 9¶
-
WIFI_REASON_DISASSOC_PWRCAP_BAD
= 10¶
-
WIFI_REASON_DISASSOC_SUPCHAN_BAD
= 11¶
-
WIFI_REASON_IE_INVALID
= 13¶
-
WIFI_REASON_MIC_FAILURE
= 14¶
-
WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT
= 15¶
-
WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT
= 16¶
-
WIFI_REASON_IE_IN_4WAY_DIFFERS
= 17¶
-
WIFI_REASON_GROUP_CIPHER_INVALID
= 18¶
-
WIFI_REASON_PAIRWISE_CIPHER_INVALID
= 19¶
-
WIFI_REASON_AKMP_INVALID
= 20¶
-
WIFI_REASON_UNSUPP_RSN_IE_VERSION
= 21¶
-
WIFI_REASON_INVALID_RSN_IE_CAP
= 22¶
-
WIFI_REASON_802_1X_AUTH_FAILED
= 23¶
-
WIFI_REASON_CIPHER_SUITE_REJECTED
= 24¶
-
WIFI_REASON_INVALID_PMKID
= 53¶
-
WIFI_REASON_BEACON_TIMEOUT
= 200¶
-
WIFI_REASON_NO_AP_FOUND
= 201¶
-
WIFI_REASON_AUTH_FAIL
= 202¶
-
WIFI_REASON_ASSOC_FAIL
= 203¶
-
WIFI_REASON_HANDSHAKE_TIMEOUT
= 204¶
-
WIFI_REASON_CONNECTION_FAIL
= 205¶
-
WIFI_REASON_AP_TSF_RESET
= 206¶
-
WIFI_REASON_BASIC_RATE_NOT_SUPPORT
= 207¶
-
-
enum
wifi_second_chan_t
¶ Values:
-
WIFI_SECOND_CHAN_NONE
= 0¶ the channel width is HT20
-
WIFI_SECOND_CHAN_ABOVE
¶ the channel width is HT40 and the second channel is above the primary channel
-
WIFI_SECOND_CHAN_BELOW
¶ the channel width is HT40 and the second channel is below the primary channel
-
-
enum
wifi_scan_type_t
¶ Values:
-
WIFI_SCAN_TYPE_ACTIVE
= 0¶ active scan
-
WIFI_SCAN_TYPE_PASSIVE
¶ passive scan
-
-
enum
wifi_cipher_type_t
¶ Values:
-
WIFI_CIPHER_TYPE_NONE
= 0¶ the cipher type is none
-
WIFI_CIPHER_TYPE_WEP40
¶ the cipher type is WEP40
-
WIFI_CIPHER_TYPE_WEP104
¶ the cipher type is WEP104
-
WIFI_CIPHER_TYPE_TKIP
¶ the cipher type is TKIP
-
WIFI_CIPHER_TYPE_CCMP
¶ the cipher type is CCMP
-
WIFI_CIPHER_TYPE_TKIP_CCMP
¶ the cipher type is TKIP and CCMP
-
WIFI_CIPHER_TYPE_AES_CMAC128
¶ the cipher type is AES-CMAC-128
-
WIFI_CIPHER_TYPE_UNKNOWN
¶ the cipher type is unknown
-
-
enum
wifi_ant_t
¶ Values:
-
WIFI_ANT_ANT0
¶ WiFi antenna 0
-
WIFI_ANT_ANT1
¶ WiFi antenna 1
-
WIFI_ANT_MAX
¶ Invalid WiFi antenna
-
-
enum
wifi_scan_method_t
¶ Values:
-
WIFI_FAST_SCAN
= 0¶ Do fast scan, scan will end after find SSID match AP
-
WIFI_ALL_CHANNEL_SCAN
¶ All channel scan, scan will end after scan all the channel
-
-
enum
wifi_sort_method_t
¶ Values:
-
WIFI_CONNECT_AP_BY_SIGNAL
= 0¶ Sort match AP in scan list by RSSI
-
WIFI_CONNECT_AP_BY_SECURITY
¶ Sort match AP in scan list by security mode
-
-
enum
wifi_ps_type_t
¶ Values:
-
WIFI_PS_NONE
¶ No power save
-
WIFI_PS_MIN_MODEM
¶ Minimum modem power saving. In this mode, station wakes up to receive beacon every DTIM period
-
WIFI_PS_MAX_MODEM
¶ Maximum modem power saving. In this mode, interval to receive beacons is determined by the listen_interval parameter in wifi_sta_config_t. Attention: Using this option may cause ping failures. Not recommended
-
-
enum
wifi_storage_t
¶ Values:
-
WIFI_STORAGE_FLASH
¶ all configuration will strore in both memory and flash
-
WIFI_STORAGE_RAM
¶ all configuration will only store in the memory
-
-
enum
wifi_vendor_ie_type_t
¶ Vendor Information Element type.
Determines the frame type that the IE will be associated with.
Values:
-
WIFI_VND_IE_TYPE_BEACON
¶
-
WIFI_VND_IE_TYPE_PROBE_REQ
¶
-
WIFI_VND_IE_TYPE_PROBE_RESP
¶
-
WIFI_VND_IE_TYPE_ASSOC_REQ
¶
-
WIFI_VND_IE_TYPE_ASSOC_RESP
¶
-
-
enum
wifi_vendor_ie_id_t
¶ Vendor Information Element index.
Each IE type can have up to two associated vendor ID elements.
Values:
-
WIFI_VND_IE_ID_0
¶
-
WIFI_VND_IE_ID_1
¶
-
-
enum
wifi_promiscuous_pkt_type_t
¶ Promiscuous frame type.
Passed to promiscuous mode RX callback to indicate the type of parameter in the buffer.
Values:
-
WIFI_PKT_MGMT
¶ Management frame, indicates ‘buf’ argument is wifi_promiscuous_pkt_t
-
WIFI_PKT_CTRL
¶ Control frame, indicates ‘buf’ argument is wifi_promiscuous_pkt_t
-
WIFI_PKT_DATA
¶ Data frame, indiciates ‘buf’ argument is wifi_promiscuous_pkt_t
-
WIFI_PKT_MISC
¶ Other type, such as MIMO etc. ‘buf’ argument is wifi_promiscuous_pkt_t but the payload is zero length.
-
-
enum
wifi_tx_result_t
¶ WIFI hardware TX result code.
Values:
-
TX_STATUS_SUCCESS
= 1¶
-
TX_STATUS_SRC_EXCEED
¶
-
TX_STATUS_LRC_EXCEED
¶
-
TX_STATUS_DISCARD
¶
-
-
enum
wifi_tx_rate_t
¶ WIFI hardware TX rate.
Values:
-
PHY_RATE_1_LONG
¶
-
PHY_RATE_2_LONG
¶
-
PHY_RATE_5_LONG
¶
-
PHY_RATE_11_LONG
¶
-
PHY_RATE_RESERVED
¶
-
PHY_RATE_2_SHORT
¶
-
PHY_RATE_5_SHORT
¶
-
PHY_RATE_11_SHORT
¶
-
PHY_RATE_48
¶
-
PHY_RATE_24
¶
-
PHY_RATE_12
¶
-
PHY_RATE_6
¶
-
PHY_RATE_54
¶
-
PHY_RATE_36
¶
-
PHY_RATE_18
¶
-
PHY_RATE_9
¶
-
-
enum
wifi_event_t
¶ WiFi event declarations
Values:
-
WIFI_EVENT_WIFI_READY
= 0¶ WiFi ready
-
WIFI_EVENT_SCAN_DONE
¶ finish scanning AP
-
WIFI_EVENT_STA_START
¶ station start
-
WIFI_EVENT_STA_STOP
¶ station stop
-
WIFI_EVENT_STA_CONNECTED
¶ station connected to AP
-
WIFI_EVENT_STA_DISCONNECTED
¶ station disconnected from AP
-
WIFI_EVENT_STA_AUTHMODE_CHANGE
¶ the auth mode of AP connected by station changed
-
WIFI_EVENT_STA_BSS_RSSI_LOW
¶ AP’s RSSI crossed configured threshold
-
WIFI_EVENT_STA_WPS_ER_SUCCESS
¶ station wps succeeds in enrollee mode
-
WIFI_EVENT_STA_WPS_ER_FAILED
¶ station wps fails in enrollee mode
-
WIFI_EVENT_STA_WPS_ER_TIMEOUT
¶ station wps timeout in enrollee mode
-
WIFI_EVENT_STA_WPS_ER_PIN
¶ station wps pin code in enrollee mode
-
WIFI_EVENT_AP_START
¶ soft-AP start
-
WIFI_EVENT_AP_STOP
¶ soft-AP stop
-
WIFI_EVENT_AP_STACONNECTED
¶ a station connected to soft-AP
-
WIFI_EVENT_AP_STADISCONNECTED
¶ a station disconnected from soft-AP
-
WIFI_EVENT_AP_PROBEREQRECVED
¶ Receive probe request packet in soft-AP interface
-