3.10. esp_wifi — Espressif WiFi

This module is a wrapper for the Espressif WiFi interface.

Configure the WiFi as a Station and an Access Point at the same time. The application tries to connect to a Wifi with SSID ssid and will accept connections to the SSID Simba.

esp_wifi_set_op_mode(esp_wifi_op_mode_station_softap_t);
esp_wifi_softap_init("Simba", NULL);
esp_wifi_station_init("ssid", "password", NULL, NULL);

Configure the WiFi as an Access Point. The application will accept connections to the SSID Simba.

esp_wifi_set_op_mode(esp_wifi_op_mode_softap_t);
esp_wifi_softap_init("Simba", NULL);

Configure the WiFi as a Station. The application tries to connect to a Wifi with SSID ssid.

esp_wifi_set_op_mode(esp_wifi_op_mode_station_t);
esp_wifi_station_init("ssid", "password", NULL, NULL);

Configure the WiFi as a Station specifying the MAC address of the access point. The application tries to connect to a Wifi with a MAC of c8:d7:19:0f:04:66 and SSID ssid.

esp_wifi_set_op_mode(esp_wifi_op_mode_station_t);
esp_wifi_station_init("ssid",
                      "password",
                      (uint8_t[]){0xc8, 0xd7, 0x19, 0x0f, 0x04, 0x66},
                      NULL);

Submodules:


Source code: src/drivers/esp_wifi.h, src/drivers/esp_wifi.c

Test code: tst/drivers/esp_wifi/main.c


Enums

enum esp_wifi_op_mode_t

Values:

esp_wifi_op_mode_null_t = 0
esp_wifi_op_mode_station_t
esp_wifi_op_mode_softap_t
esp_wifi_op_mode_station_softap_t
esp_wifi_op_mode_max_t
enum esp_wifi_phy_mode_t

Physical WiFi mode.

Values:

esp_wifi_phy_mode_11b_t = 1
esp_wifi_phy_mode_11g_t
esp_wifi_phy_mode_11n_t
enum esp_wifi_dhcp_status_t

DHCP status.

Values:

esp_wifi_dhcp_status_stopped_t = 0
esp_wifi_dhcp_status_running_t

Functions

int esp_wifi_module_init(void)

Initialize the Espressif WiFi module. This function must be called before calling any other function in this module.

The module will only be initialized once even if this function is called multiple times.

Return
zero(0) or negative error code.

int esp_wifi_set_op_mode(enum esp_wifi_op_mode_t mode)

Set the WiFi operating mode to None, Station, SoftAP or Station + SoftAP. The default mode is SoftAP.

Return
zero(0) or negative error code.
Parameters
  • mode: Operating mode to set.

enum esp_wifi_op_mode_t esp_wifi_get_op_mode(void)

Get the current WiFi operating mode. The operating mode can be None, Station, SoftAP, or Station + SoftAP.

Return
Current operating mode.

int esp_wifi_set_phy_mode(enum esp_wifi_phy_mode_t mode)

Set the WiFi physical mode (802.11b/g/n).

The SoftAP only supports b/g.

Return
zero(0) or negative error code.
Parameters
  • mode: Physical mode.

enum esp_wifi_phy_mode_t esp_wifi_get_phy_mode(void)

Get the physical mode (802.11b/g/n).

Return
WiFi physical mode.

void esp_wifi_print(void *chout_p)

Print information about the WiFi.