Chapter 4. API Guides
4.33.11 ESP32-S2 Wi-Fi Station Connecting When Multiple APs Are Found
This scenario is similar as ESP32-S2 Wi-Fi Station Connecting Scenario, the difference is the station will not raise the
event WIFI_EVENT_STA_DISCONNECTED unless it fails to connect all of the found APs.
4.33.12 Wi-Fi Reconnect
The station may disconnect due to many reasons, e.g. the connected AP is restarted etc. It’s the application’s
responsibility to do the reconnect. The recommended reconnect strategy is to call esp_wifi_connect() on
receiving event WIFI_EVENT_STA_DISCONNECTED.
Sometimes the application needs more complex reconnect strategy:
• If the disconnect event is raised because the esp_wifi_disconnect() is called, the application may not
want to do reconnect.
• If the esp_wifi_scan_start() may be called at anytime, a better reconnect strategy is necessary, refer
to Scan When Wi-Fi is Connecting.
Another thing we need to consider is the reconnect may not connect the same AP if there are more than one APs
with the same SSID. The reconnect always select current best APs to connect.
4.33.13 Wi-Fi Beacon Timeout
The beacon timeout mechanism is used by ESP32-S2 station to detect whether the AP is alive or not. If the station
continuously loses 60 beacons of the connected AP, the beacon timeout happens.
After the beacon timeout happens, the station sends 5 probe requests to AP, it disconnects the AP and raises the event
WIFI_EVENT_STA_DISCONNECTED if still no probe response or beacon is received from AP.
4.33.14 ESP32-S2 Wi-Fi Configuration
All configurations will be stored into flash when the Wi-Fi NVS is enabled; otherwise, refer to Wi-Fi NVS Flash.
Wi-Fi Mode
Call esp_wifi_set_mode() to set the Wi-Fi mode.
Mode Description
WIFI_MODE_NULLNULL mode: in this mode, the internal data struct is not allocated to the station and the AP,
while both the station and AP interfaces are not initialized for RX/TX Wi-Fi data. Generally, this
mode is used for Sniffer, or when you only want to stop both the STA and the AP without calling
esp_wifi_deinit() to unload the whole Wi-Fi driver.
WIFI_MODE_STAStation mode: in this mode, esp_wifi_start() will init the internal station data, while the station’
s interface is ready for the RX and TX Wi-Fi data. After esp_wifi_connect() is called, the STA
will connect to the target target AP.
WIFI_MODE_APAP mode: in this mode, esp_wifi_start() will init the internal AP data, while the AP’s interface
is ready for RX/TX Wi-Fi data. Then, the Wi-Fi driver starts broad- casting beacons, and the AP is
ready to get connected to other stations.
WIFI_MODE_APSTAStation-AP coexistence mode: in this mode, esp_wifi_start() will simultaneously init both the
station and the AP.This is done in station mode and AP mode. Please note that the channel of the
external AP, which the ESP Station is connected to, has higher priority over the ESP AP channel.
Espressif Systems 1532
Submit Document Feedback
Release v4.4