Chapter 4. API Guides
WIFI_EVENT_AP_STOP
Similar to WIFI_EVENT_STA_STOP.
WIFI_EVENT_AP_STACONNECTED
Every time a station is connected to ESP32-S2 AP, the WIFI_EVENT_AP_STACONNECTED will arise. Upon re-
ceiving this event, the event task will do nothing, and the application callback can also ignore it. However, you may
want to do something, for example, to get the info of the connected STA, etc.
WIFI_EVENT_AP_STADISCONNECTED
This event can happen in the following scenarios:
• The application calls esp_wifi_disconnect(), or esp_wifi_deauth_sta(), to manually disconnect the
station.
• The Wi-Fi driver kicks off the station, e.g. because the AP has not received any packets in the past five minutes,
etc. The time can be modified by esp_wifi_set_inactive_time().
• The station kicks off the AP.
When this event happens, the event task will do nothing, but the application event callback needs to do something,
e.g., close the socket which is related to this station, etc.
WIFI_EVENT_AP_PROBEREQRECVED
This event is disabled by default. The application can enable it via API esp_wifi_set_event_mask(). When
this event is enabled, it will be raised each time the AP receives a probe request.
4.33.7 ESP32-S2 Wi-Fi Station General Scenario
Below is a “big scenario”which describes some small scenarios in Station mode:
1. Wi-Fi/LwIP Init Phase
• s1.1: The main task calls esp_netif_init() to create an LwIP core task and initialize LwIP-related
work.
• s1.2: The main task calls esp_event_loop_create() to create a system Event task and initialize an
application event’s callback function. In the scenario above, the application event’s callback function does
nothing but relaying the event to the application task.
• s1.3: The main task calls esp_netif_create_default_wifi_ap() or
esp_netif_create_default_wifi_sta() to create default network interface instance bind-
ing station or AP with TCP/IP stack.
• s1.4: The main task calls esp_wifi_init() to create the Wi-Fi driver task and initialize the Wi-Fi driver.
• s1.5: The main task calls OS API to create the application task.
Step 1.1 ~ 1.5 is a recommended sequence that initializes a Wi-Fi-/LwIP-based application. However, it is NOT a
must-follow sequence, which means that you can create the application task in step 1.1 and put all other initializations
in the application task. Moreover, you may not want to create the application task in the initialization phase if the
application task depends on the sockets. Rather, you can defer the task creation until the IP is obtained.
2. Wi-Fi Configuration Phase
Once the Wi-Fi driver is initialized, you can start configuring the Wi-Fi driver. In this scenario, the mode is Station,
so you may need to call esp_wifi_set_mode() (WIFI_MODE_STA) to configure the Wi-Fi mode as Station.
Espressif Systems 1518
Submit Document Feedback
Release v4.4