Chapter 2. API Reference
• esp_wifi_set_protocol,
• esp_wifi_set_config related
• esp_wifi_set_mode
Return
esp_err_t
esp_wifi_connect(void)
Connect the ESP32 WiFi station to the AP.
Attention 1. This API only impact WIFI_MODE_STA or WIFI_MODE_APSTA mode
Attention 2. If the ESP32 is connected to an AP, call esp_wifi_disconnect to disconnect.
Attention 3. The scanning triggered by esp_wifi_start_scan() will not be effective until connection between
ESP32 and the AP is established. If ESP32 is scanning and connecting at the same time, ESP32 will abort
scanning and return a warning message and error number ESP_ERR_WIFI_STATE. If you want to do re-
connection after ESP32 received disconnect event, remember to add the maximum retry time, otherwise
the called scan will not work. This is especially true when the AP doesn' t exist, and you still try reconnec-
tion after ESP32 received disconnect event with the reason code WIFI_REASON_NO_AP_FOUND.
Return
• ESP_OK: succeed
• 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_wifi_disconnect(void)
Disconnect the ESP32 WiFi station from the AP.
Return
• 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_STARTED: WiFi was not started by esp_wifi_start
• 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
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
Espressif Systems
wifi_scan_config_t
89
Submit Document Feedback
*config, bool block)
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?
Questions and answers