HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
EspWifi.cpp File Reference

Advanced ESP32 implementation of the unified BaseWifi class with ESP-IDF v5.5+ features. More...

#include "mcu/esp32/EspWifi.h"
#include "esp_log.h"
#include "esp_mac.h"
#include "esp_system.h"
#include "esp_timer.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "freertos/task.h"
#include <algorithm>
#include <cstring>
Include dependency graph for EspWifi.cpp:

Macros

#define WIFI_CONNECTED_BIT   BIT0
 
#define WIFI_FAIL_BIT   BIT1
 
#define WIFI_SCAN_DONE_BIT   BIT2
 
#define WIFI_AP_STARTED_BIT   BIT3
 
#define WIFI_SMARTCONFIG_BIT   BIT4
 

Functions

static hf_wifi_err_t ensureDefaultNetifs ()
 Ensure default network interfaces are created only once globally.
 
static wifi_mode_t ConvertToEspMode (hf_wifi_mode_t mode)
 Convert HardFOC WiFi mode to ESP-IDF WiFi mode.
 
static hf_wifi_mode_t ConvertFromEspMode (wifi_mode_t mode)
 Convert ESP-IDF WiFi mode to HardFOC WiFi mode.
 
static wifi_auth_mode_t ConvertToEspAuthMode (hf_wifi_security_t security)
 Convert HardFOC WiFi security to ESP-IDF auth mode.
 
static hf_wifi_security_t ConvertFromEspAuthMode (wifi_auth_mode_t auth_mode)
 Convert ESP-IDF auth mode to HardFOC WiFi security.
 

Variables

static const char * TAG = "EspWifi"
 
static std::atomic< bool > g_wifi_initialized {false}
 
static std::atomic< bool > g_sta_netif_created {false}
 
static std::atomic< bool > g_ap_netif_created {false}
 
static const EspWifiAdvancedConfig DEFAULT_ADVANCED_CONFIG
 

Detailed Description

Advanced ESP32 implementation of the unified BaseWifi class with ESP-IDF v5.5+ features.

This file provides concrete implementations of the unified BaseWifi class for ESP32 microcontrollers with full ESP-IDF v5.5+ API support including WPA3 security, mesh networking, enterprise authentication, and advanced power management features.

Author
Nebiyu Tadesse
Date
2025
Note
Requires ESP-IDF v5.5 or higher for full feature support
Thread-safe implementation with proper synchronization

Macro Definition Documentation

◆ WIFI_AP_STARTED_BIT

#define WIFI_AP_STARTED_BIT   BIT3

◆ WIFI_CONNECTED_BIT

#define WIFI_CONNECTED_BIT   BIT0

◆ WIFI_FAIL_BIT

#define WIFI_FAIL_BIT   BIT1

◆ WIFI_SCAN_DONE_BIT

#define WIFI_SCAN_DONE_BIT   BIT2

◆ WIFI_SMARTCONFIG_BIT

#define WIFI_SMARTCONFIG_BIT   BIT4

Function Documentation

◆ ConvertFromEspAuthMode()

static hf_wifi_security_t ConvertFromEspAuthMode ( wifi_auth_mode_t auth_mode)
static

Convert ESP-IDF auth mode to HardFOC WiFi security.

◆ ConvertFromEspMode()

static hf_wifi_mode_t ConvertFromEspMode ( wifi_mode_t mode)
static

Convert ESP-IDF WiFi mode to HardFOC WiFi mode.

◆ ConvertToEspAuthMode()

static wifi_auth_mode_t ConvertToEspAuthMode ( hf_wifi_security_t security)
static

Convert HardFOC WiFi security to ESP-IDF auth mode.

◆ ConvertToEspMode()

static wifi_mode_t ConvertToEspMode ( hf_wifi_mode_t mode)
static

Convert HardFOC WiFi mode to ESP-IDF WiFi mode.

◆ ensureDefaultNetifs()

static hf_wifi_err_t ensureDefaultNetifs ( )
static

Ensure default network interfaces are created only once globally.

Returns
hf_wifi_err_t::WIFI_SUCCESS on success, error code otherwise

Variable Documentation

◆ DEFAULT_ADVANCED_CONFIG

const EspWifiAdvancedConfig DEFAULT_ADVANCED_CONFIG
static
Initial value:
= {.enable_power_save = false,
.power_save_type = WIFI_PS_NONE,
.listen_interval = 3,
.tx_power = 20,
.bandwidth = WIFI_BW_HT20,
.enable_ampdu_rx = true,
.enable_ampdu_tx = true,
.enable_fast_connect = false,
.enable_pmf_required = false,
.enable_wpa3_transition = true,
.enable_11r = false,
.enable_11k = false,
.enable_11v = false,
.enable_enterprise = false,
.enterprise_username = "",
.enterprise_password = "",
.enterprise_ca_cert = "",
.enterprise_client_cert = "",
.enterprise_client_key = "",
.enable_mesh = false,
.mesh_max_layer = 6,
.mesh_max_connection = 10,
.enable_smartconfig = false,
.smartconfig_type = SC_TYPE_ESPTOUCH}

◆ g_ap_netif_created

std::atomic<bool> g_ap_netif_created {false}
static

◆ g_sta_netif_created

std::atomic<bool> g_sta_netif_created {false}
static

◆ g_wifi_initialized

std::atomic<bool> g_wifi_initialized {false}
static

◆ TAG

const char* TAG = "EspWifi"
static