Chapter 4. API Guides
4.33.4 ESP32-S2 Wi-Fi API Parameter Initialization
When initializing struct parameters for the API, one of two approaches should be followed:
• explicitly set all fields of the parameter
• use get API to get current configuration first, then set application specific fields
Initializing or getting the entire structure is very important because most of the time the value 0 indicates the default
value is used. More fields may be added to the struct in the future and initializing these to zero ensures the application
will still work correctly after IDF is updated to a new release.
4.33.5 ESP32-S2 Wi-Fi Programming Model
The ESP32-S2 Wi-Fi programming model is depicted as follows:
The Wi-Fi driver can be considered a black box that knows nothing about high-layer code, such as the TCP/IP stack,
application task, event task, etc. The application task (code) generally calls
and handles Wi-Fi events when necessary. Wi-Fi driver receives API calls, handles them, and post events to the
application.
Wi-Fi event handling is based on the
Application may handle these events in callbacks registered using esp_event_handler_register(). Wi-Fi
events are also handled by
esp_netif component
connects to an AP, esp_netif will automatically start the DHCP client (by default).
4.33.6 ESP32-S2 Wi-Fi Event Description
WIFI_EVENT_WIFI_READY
The Wi-Fi driver will never generate this event, which, as a result, can be ignored by the application event callback.
This event may be removed in future releases.
WIFI_EVENT_SCAN_DONE
The scan-done event is triggered by
• The scan is completed, e.g., the target AP is found successfully, or all channels have been scanned.
• The scan is stopped by esp_wifi_scan_stop().
Espressif Systems
Fig. 39: Wi-Fi Programming Model
esp_event
library. Events are sent by the Wi-Fi driver to the
to provide a set of default behaviors. For example, when Wi-Fi station
esp_wifi_scan_start()
1515
Submit Document Feedback
Wi-Fi driver APIs
and will arise in the following scenarios:
to initialize Wi-Fi
default event
loop.
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?