Chapter 2
API Reference
2.1 Networking APIs
2.1.1 Wi-Fi
Wi-Fi
Introduction The Wi-Fi libraries provide support for configuring and monitoring the ESP32-S2 Wi-Fi networking
functionality. This includes configuration for:
• Station mode (aka STA mode or Wi-Fi client mode). ESP32-S2 connects to an access point.
• AP mode (aka Soft-AP mode or Access Point mode). Stations connect to the ESP32-S2.
• Combined AP-STA mode (ESP32-S2 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 for monitoring of IEEE802.11 Wi-Fi packets.
Application Examples The wifi directory of ESP-IDF examples contains the following applications:
Code examples for Wi-Fi are provided in the wifi directory of ESP-IDF examples.
In addition, there is a simple esp-idf-template application to demonstrate a minimal IDF project structure.
API Reference
Header File
• components/esp_wifi/include/esp_wifi.h
Functions
esp_err_t esp_wifi_init(const wifi_init_config_t *config)
Initialize WiFi Allocate resource for WiFi driver, such as WiFi control structure, RX/TX buffer, WiFi NVS
structure etc. This WiFi also starts 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 initialize the configuration to default
values, this can guarantee all the fields get correct value when more fields are added into wifi_init_config_t
in future release. If you want to set your own 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!
87