Wi-Fi Peripheral

The Wi-Fi Peripheral is used to configure Wi-Fi connections, provide APIs to control Wi-Fi connection configuration, as well as monitor the status of Wi-Fi networks.

Application Example

Implementation of this API is demonstrated in player/pipeline_http_mp3 example.

API Reference

Header File

Functions

esp_periph_handle_t periph_wifi_init(periph_wifi_cfg_t *config)

Create the wifi peripheral handle for esp_peripherals.

备注

The handle was created by this function automatically destroy when esp_periph_destroy is called

参数

config – The configuration

返回

The esp peripheral handle

esp_err_t periph_wifi_wait_for_connected(esp_periph_handle_t periph, TickType_t tick_to_wait)

This function will block current thread (in tick_to_wait tick) and wait until ESP32 connected to the Wi-Fi network, and got ip.

参数
  • periph[in] The periph

  • tick_to_wait[in] The tick to wait

返回

  • ESP_OK

  • ESP_FAIL

periph_wifi_state_t periph_wifi_is_connected(esp_periph_handle_t periph)

Check the Wi-Fi connection status.

参数

periph[in] The periph

返回

Wi-Fi network status

esp_err_t esp_wifi_set_listen_interval(esp_periph_handle_t periph, int interval)

Set Wi-Fi listen interval for ESP32 station to receive beacon.

参数
  • periph[in] The wifi periph

  • interval[in] listen interval. units: AP beacon intervals(see BcnInt, default: 100ms)

返回

  • ESP_OK

  • ESP_FAIL

esp_err_t periph_wifi_config_start(esp_periph_handle_t periph, periph_wifi_config_mode_t mode)

Start Wi-Fi network setup in mode

参数
  • periph[in] The periph

  • mode[in] The mode

返回

  • ESP_OK

  • ESP_FAIL

esp_err_t periph_wifi_config_wait_done(esp_periph_handle_t periph, TickType_t tick_to_wait)

Wait for Wi-Fi setup done.

参数
  • periph[in] The periph

  • tick_to_wait[in] The tick to wait

返回

  • ESP_OK

  • ESP_FAIL

Structures

struct periph_wpa2_enterprise_cfg_t

The WPA2 enterprise peripheral configuration.

Public Members

bool diasble_wpa2_e

Disable wpa2 enterprise

int eap_method

TLS: 0, PEAP: 1, TTLS: 2

char *ca_pem_start

binary wpa2 ca pem start

char *ca_pem_end

binary wpa2 ca pem end

char *wpa2_e_cert_start

binary wpa2 cert start

char *wpa2_e_cert_end

binary wpa2 cert end

char *wpa2_e_key_start

binary wpa2 key start

char *wpa2_e_key_end

binary wpa2 key end

const char *eap_id

Identity in phase 1 of EAP procedure

const char *eap_username

Username for EAP method (PEAP and TTLS)

const char *eap_password

Password for EAP method (PEAP and TTLS)

struct periph_wifi_cfg_t

The Wi-Fi peripheral configuration.

Public Members

bool disable_auto_reconnect

Disable Wi-Fi auto reconnect

int reconnect_timeout_ms

The reconnect timeout after disconnected from Wi-Fi network

wifi_config_t wifi_config

Wifi configure

periph_wpa2_enterprise_cfg_t wpa2_e_cfg

wpa2 enterprise config

Enumerations

enum periph_wifi_state_t

Peripheral Wi-Fi event id.

Values:

enumerator PERIPH_WIFI_UNCHANGE
enumerator PERIPH_WIFI_CONNECTING
enumerator PERIPH_WIFI_CONNECTED
enumerator PERIPH_WIFI_DISCONNECTED
enumerator PERIPH_WIFI_SETTING
enumerator PERIPH_WIFI_CONFIG_DONE
enumerator PERIPH_WIFI_CONFIG_ERROR
enumerator PERIPH_WIFI_ERROR
enum periph_wifi_config_mode_t

Wi-Fi setup mode type.

Values:

enumerator WIFI_CONFIG_ESPTOUCH

Using smartconfig with ESPTOUCH protocol

enumerator WIFI_CONFIG_AIRKISS

Using smartconfig with AIRKISS protocol

enumerator WIFI_CONFIG_ESPTOUCH_AIRKISS

Using smartconfig with ESPTOUCH_AIRKISS protocol

enumerator WIFI_CONFIG_WPS

Using WPS (not support)

enumerator WIFI_CONFIG_BLUEFI

Using BLUEFI

enumerator WIFI_CONFIG_WEB

Using HTTP Server (not support)