esp_iot_framework  v0.1.0-alpha
© 2026 AmakeSasha, distributed under a license Apache-2.0
Wi-Fi Configuration

Pre-initialization tuning and profile management for the Wi-Fi stack. More...

Functions

esp_err_t eif_set_wifi_config (const wifi_init_config_t *wifi_driver_config, wifi_ps_type_t wifi_power_mode, uint32_t wifi_attempt_delay_ms)
 Configure Wi-Fi driver and power management policies. More...
 
esp_err_t eif_set_wifi_profiles_count (uint8_t wifi_profiles_count)
 Set the number of additional user Wi-Fi profiles. More...
 
esp_err_t eif_wifi_initialize (void)
 Launch the Wi-Fi subsystem and automated network services. More...
 

Detailed Description

This module provides fine-grained control over the Wi-Fi stack behavior, including power management and connection recovery policies.

Function Documentation

◆ eif_set_wifi_config()

esp_err_t eif_set_wifi_config ( const wifi_init_config_t *  wifi_driver_config,
wifi_ps_type_t  wifi_power_mode,
uint32_t  wifi_attempt_delay_ms 
)

Overrides the default low-level driver settings. These parameters are applied globally and define the performance and energy profile of the device.

Note
This function must be called after eif_core_initialize() but before eif_wifi_initialize().
Warning
The function does not validate incoming data, which may result in unexpected behavior (UB), memory leaks, or Wi-Fi crashes. Always validate the data you send.
Parameters
wifi_driver_configLow-level ESP-IDF Wi-Fi driver configuration Use WIFI_INIT_CONFIG_DEFAULT() as a base.
wifi_power_modeWi-Fi Modem-sleep policy. Defines the trade-off between power consumption and network responsiveness/latency.
wifi_attempt_delay_msDelay in milliseconds before switching to the next profile after a failed connection.
Returns
  • ESP_OK: Settings saved successfully.
  • ESP_ERR_INVALID_ARG: The wifi_driver_config pointer is NULL.

Example of use:

#include <esp_err.h>
#include <esp_wifi.h>
#include <esp_iot_framework_core.h>
void app_main(void) {
ESP_ERROR_CHECK(eif_core_initialize());
ESP_ERROR_CHECK(eif_nvs_initialize());
// Creating default Wi-Fi settings
wifi_init_config_t cfg_wifi = WIFI_INIT_CONFIG_DEFAULT();
// Changing Wi-Fi settings
cfg_wifi.dynamic_rx_buf_num = 64;
cfg_wifi.csi_enable = false;
ESP_ERROR_CHECK(eif_set_wifi_config(&cfg_wifi, WIFI_PS_MIN_MODEM, 1000));
// Further code...
}
esp_err_t eif_nvs_initialize(void)
Initialize Non-Volatile Storage (NVS) and framework data.
esp_err_t eif_core_initialize(void)
Initializes the CORE of the framework.
esp_err_t eif_set_wifi_config(const wifi_init_config_t *wifi_driver_config, wifi_ps_type_t wifi_power_mode, uint32_t wifi_attempt_delay_ms)
Configure Wi-Fi driver and power management policies.

◆ eif_set_wifi_profiles_count()

esp_err_t eif_set_wifi_profiles_count ( uint8_t  wifi_profiles_count)

Defines how many additional user-defined slots are available in NVS.

Note
This function must be called after eif_core_initialize() but before eif_nvs_initialize().

Profile - configuration for a specific Wi-Fi network (SSID and Password). Profiles are managed in a circular (ring) list: if a connection attempt fails or if the active connection is broken, the framework automatically rotates to the next available slot. Upon reaching the end of the list, it wraps around to the first profile. This cycle continues indefinitely until a stable connection is re-established.

Note
The total number of managed profiles is equal to (wifi_profiles_count + 1). If set to 0, only the system default profile (index 0) will be used. The default profile is hardcoded and cannot be changed. The default value is EIF_WIFI_PROFILES_DEFAULT_COUNT.
Parameters
wifi_profiles_countNumber of extra slots (0 to EIF_WIFI_PROFILES_MAX_COUNT).
Returns

Example of use:

#include <esp_err.h>
#include <esp_iot_framework_core.h>
void app_main(void) {
ESP_ERROR_CHECK(eif_core_initialize());
ESP_ERROR_CHECK(eif_set_wifi_profiles_count(5));
ESP_ERROR_CHECK(eif_nvs_initialize());
// Further code...
}
esp_err_t eif_set_wifi_profiles_count(uint8_t wifi_profiles_count)
Set the number of additional user Wi-Fi profiles.

◆ eif_wifi_initialize()

esp_err_t eif_wifi_initialize ( void  )

Initializes the Wi-Fi stack, registers event handlers for automatic profile failover, and starts mDNS/Web Server once an IP is obtained. In case of IP loss, the Web Server and mDNS services are gracefully stopped to save resources and prevent invalid states. Once a new IP address is obtained, the framework automatically resumes these services.

Note
This function should come after any other eif_* functions (like URI registration or Wi-Fi connectivity). This function is mandatory for the framework to work.
Warning
Otherwise, there is a chance that the settings will not be applied immediately or unexpected behavior (UB) will occur.
Returns
  • ESP_OK: Subsystem initialized successfully.
  • ESP_ERR_NO_MEM: Failed to allocate memory for network interface.
  • ESP_ERR_*: Internal driver errors. Look at the logs to understand the cause of the errors.

Example of use:

#include <esp_err.h>
#include <esp_iot_framework_core.h>
void app_main(void) {
ESP_ERROR_CHECK(eif_core_initialize());
ESP_ERROR_CHECK(eif_nvs_initialize());
ESP_ERROR_CHECK(eif_wifi_initialize());
// Necessary to keep the flow alive
while (1) {
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
esp_err_t eif_wifi_initialize(void)
Launch the Wi-Fi subsystem and automated network services.