|
HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
|
Advanced ESP32 implementation of unified BaseWifi with ESP-IDF v5.5+ features. More...
#include <EspWifi.h>
Public Member Functions | |
| EspWifi (const EspWifiAdvancedConfig *advanced_config=nullptr) | |
| Constructor with optional advanced configuration. | |
| virtual | ~EspWifi () |
| Destructor - ensures proper cleanup. | |
| hf_wifi_err_t | Initialize (hf_wifi_mode_t mode) noexcept override |
| Initialize the WiFi subsystem. | |
| hf_wifi_err_t | Deinitialize () noexcept override |
| Deinitialize the WiFi subsystem. | |
| bool | IsInitialized () const noexcept override |
| Check if WiFi is initialized. | |
| hf_wifi_err_t | SetMode (hf_wifi_mode_t mode) noexcept override |
| Set WiFi operating mode. | |
| hf_wifi_mode_t | GetMode () const noexcept override |
| Get current WiFi operating mode. | |
| hf_wifi_err_t | ConfigureStation (const hf_wifi_station_config_t &config) noexcept override |
| Configure station parameters. | |
| hf_wifi_err_t | Connect (uint32_t timeout_ms=0) noexcept override |
| Connect to a WiFi network (station mode) | |
| hf_wifi_err_t | Disconnect () noexcept override |
| Disconnect from WiFi network. | |
| bool | IsConnected () const noexcept override |
| Check if connected to a network. | |
| int8_t | GetRssi () const noexcept override |
| Get signal strength (RSSI) | |
| hf_wifi_err_t | GetIpInfo (hf_wifi_ip_info_t &ip_info) const noexcept override |
| Get current IP information. | |
| hf_wifi_err_t | ConfigureAccessPoint (const hf_wifi_ap_config_t &config) noexcept override |
| Configure Access Point parameters. | |
| hf_wifi_err_t | StartAccessPoint () noexcept override |
| Start Access Point. | |
| hf_wifi_err_t | StopAccessPoint () noexcept override |
| Stop Access Point. | |
| bool | IsAccessPointActive () const noexcept override |
| Check if Access Point is running. | |
| int | GetConnectedStationCount () const noexcept override |
| Get number of connected stations. | |
| hf_wifi_err_t | StartScan (bool show_hidden=false, bool passive=false, uint32_t max_scan_time_ms=0) noexcept override |
| Start network scan. | |
| hf_wifi_err_t | GetScanResults (std::vector< hf_wifi_network_info_t > &networks, uint16_t max_networks=0) noexcept override |
| Get scan results. | |
| bool | IsScanning () const noexcept override |
| Check if scan is in progress. | |
| hf_wifi_state_t | GetState () const noexcept override |
| Get current WiFi state. | |
| std::string | GetConnectedSsid () const noexcept override |
| Get connected network SSID. | |
| hf_wifi_err_t | GetConnectedBssid (uint8_t bssid[6]) const noexcept override |
| Get connected network BSSID. | |
| hf_wifi_err_t | SetPowerSave (hf_wifi_power_save_t mode) noexcept override |
| Set power save mode. | |
| hf_wifi_power_save_t | GetPowerSave () const noexcept override |
| Get current power save mode. | |
| hf_wifi_err_t | RegisterEventCallback (hf_wifi_event_callback_t callback) noexcept override |
| Register event callback. | |
| hf_wifi_err_t | UnregisterEventCallback () noexcept override |
| Unregister event callback. | |
| hf_wifi_err_t | GetMacAddress (uint8_t mac[6], uint8_t interface=0) const noexcept override |
| Get MAC address. | |
| hf_wifi_err_t | SetMacAddress (const uint8_t mac[6], uint8_t interface=0) noexcept override |
| Set MAC address. | |
| uint8_t | GetChannel () const noexcept override |
| Get WiFi channel. | |
| hf_wifi_err_t | SetChannel (uint8_t channel) noexcept override |
| Set WiFi channel. | |
| hf_wifi_err_t | SetAdvancedConfig (const EspWifiAdvancedConfig &config) |
| Set advanced ESP32-specific configuration. | |
| hf_wifi_err_t | GetAdvancedConfig (EspWifiAdvancedConfig &config) const |
| Get current advanced configuration. | |
| hf_wifi_err_t | EnableWpa3Transition (bool enable) |
| Enable WPA3 transition mode (WPA2/WPA3 mixed) | |
| hf_wifi_err_t | ConfigureRoaming (bool enable_11k, bool enable_11r, bool enable_11v) |
| Configure 802.11k/r/v roaming features. | |
| hf_wifi_err_t | ConfigureEnterprise (const std::string &username, const std::string &password, const std::string &ca_cert="", const std::string &client_cert="", const std::string &client_key="") |
| Configure WPA2/WPA3 Enterprise authentication. | |
| hf_wifi_err_t | StartSmartConfig (smartconfig_type_t type=SC_TYPE_ESPTOUCH, uint32_t timeout_ms=60000) |
| Start SmartConfig provisioning. | |
| hf_wifi_err_t | StopSmartConfig () |
| Stop SmartConfig provisioning. | |
| hf_wifi_err_t | InitMesh (const uint8_t mesh_id[6], uint8_t max_layer=6, uint16_t max_connection=10) |
| Initialize ESP-MESH networking. | |
| hf_wifi_err_t | StartMeshRoot () |
| Start ESP-MESH as root node. | |
| hf_wifi_err_t | StartMeshChild () |
| Start ESP-MESH as child node. | |
| hf_wifi_err_t | StopMesh () |
| Stop ESP-MESH networking. | |
| hf_wifi_err_t | GetStatistics (wifi_pkt_rx_ctrl_t &stats) const |
| Get WiFi statistics. | |
| hf_wifi_err_t | SetTxPower (uint8_t power) |
| Set WiFi TX power. | |
| int8_t | GetTxPower () const |
| Get WiFi TX power. | |
| hf_wifi_err_t | SetBandwidth (wifi_bandwidth_t bandwidth) |
| Set WiFi channel bandwidth. | |
| wifi_bandwidth_t | GetBandwidth () const |
| Get WiFi channel bandwidth. | |
| hf_wifi_err_t | PerformCalibration () |
| Perform WiFi calibration. | |
| hf_wifi_err_t | GetConnectionInfo (wifi_ap_record_t &info) const |
| Get detailed connection information. | |
Public Member Functions inherited from BaseWifi | |
| virtual | ~BaseWifi () noexcept=default |
| Virtual destructor for proper cleanup of derived classes. | |
Private Member Functions | |
| hf_wifi_err_t | InitNetif () |
| Initialize ESP-IDF network interface. | |
| hf_wifi_err_t | DeinitNetif () |
| Deinitialize ESP-IDF network interface. | |
| hf_wifi_err_t | RegisterEventHandlers () |
| Register ESP-IDF event handlers. | |
| hf_wifi_err_t | UnregisterEventHandlers () |
| Unregister ESP-IDF event handlers. | |
| wifi_mode_t | ConvertToEspMode (hf_wifi_mode_t mode) const |
| Convert HardFOC WiFi mode to ESP-IDF mode. | |
| hf_wifi_mode_t | ConvertFromEspMode (wifi_mode_t mode) const |
| Convert ESP-IDF WiFi mode to HardFOC mode. | |
| wifi_auth_mode_t | ConvertToEspAuthMode (hf_wifi_security_t security) const |
| Convert HardFOC security to ESP-IDF auth mode. | |
| hf_wifi_security_t | ConvertFromEspAuthMode (wifi_auth_mode_t auth_mode) const |
| Convert ESP-IDF auth mode to HardFOC security. | |
| hf_wifi_err_t | ConvertEspError (esp_err_t esp_err) const |
| Convert ESP-IDF error to HardFOC error. | |
| void | handleWifiEvent (int32_t event_id, void *event_data) |
| Handle WiFi events internally. | |
| void | handleIpEvent (int32_t event_id, void *event_data) |
| Handle IP events internally. | |
| void | handleSmartconfigEvent (int32_t event_id, void *event_data) |
| Handle SmartConfig events internally. | |
| void | NotifyEventCallback (hf_wifi_event_t event, void *event_data) |
| Notify user event callback. | |
| void | UpdateState (hf_wifi_state_t new_state) |
| Update internal state. | |
| hf_wifi_err_t | ApplyAdvancedConfig () |
| Apply advanced configuration settings. | |
| bool | ValidateConfig (const hf_wifi_station_config_t &config) const |
| Validate configuration parameters. | |
| bool | ValidateApConfig (const hf_wifi_ap_config_t &config) const |
| Validate AP configuration parameters. | |
| EspWifi (const EspWifi &)=delete | |
| EspWifi & | operator= (const EspWifi &)=delete |
Static Private Member Functions | |
| static void | wifiEventHandler (void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) |
| Static WiFi event handler for ESP-IDF. | |
| static void | ipEventHandler (void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) |
| Static IP event handler for ESP-IDF. | |
| static void | smartconfigEventHandler (void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) |
| Static SmartConfig event handler for ESP-IDF. | |
Additional Inherited Members | |
Static Public Member Functions inherited from BaseWifi | |
| static std::string_view | GetErrorString (hf_wifi_err_t error) |
| Get error description string. | |
Protected Member Functions inherited from BaseWifi | |
| BaseWifi ()=default | |
| Protected constructor - only derived classes can instantiate. | |
| BaseWifi (const BaseWifi &)=delete | |
| Copy constructor - deleted to prevent copying. | |
| BaseWifi & | operator= (const BaseWifi &)=delete |
| Assignment operator - deleted to prevent copying. | |
Advanced ESP32 implementation of unified BaseWifi with ESP-IDF v5.5+ features.
This class provides a comprehensive implementation of BaseWifi for ESP32 microcontrollers with support for both basic and advanced features including:
Basic Features:
Advanced Features (ESP-IDF v5.5+):
Performance Optimizations:
Thread Safety:
|
explicit |
Constructor with optional advanced configuration.
| advanced_config | Advanced ESP32-specific configuration (optional) |
|
virtual |
Destructor - ensures proper cleanup.
|
privatedelete |
|
private |
Apply advanced configuration settings.
|
overridevirtualnoexcept |
Configure Access Point parameters.
| config | AP configuration |
Implements BaseWifi.
| hf_wifi_err_t EspWifi::ConfigureEnterprise | ( | const std::string & | username, |
| const std::string & | password, | ||
| const std::string & | ca_cert = "", | ||
| const std::string & | client_cert = "", | ||
| const std::string & | client_key = "" ) |
Configure WPA2/WPA3 Enterprise authentication.
| username | Enterprise username |
| password | Enterprise password |
| ca_cert | CA certificate (optional) |
| client_cert | Client certificate (optional) |
| client_key | Client private key (optional) |
| hf_wifi_err_t EspWifi::ConfigureRoaming | ( | bool | enable_11k, |
| bool | enable_11r, | ||
| bool | enable_11v ) |
Configure 802.11k/r/v roaming features.
| enable_11k | Enable 802.11k Radio Resource Management |
| enable_11r | Enable 802.11r Fast BSS Transition |
| enable_11v | Enable 802.11v BSS Transition Management |
|
overridevirtualnoexcept |
Configure station parameters.
| config | Station configuration |
Implements BaseWifi.
|
overridevirtualnoexcept |
Connect to a WiFi network (station mode)
| timeout_ms | Connection timeout in milliseconds (0 for default) |
Implements BaseWifi.
|
private |
Convert ESP-IDF error to HardFOC error.
| esp_err | ESP-IDF error code |
|
private |
Convert ESP-IDF auth mode to HardFOC security.
| auth_mode | ESP-IDF auth mode |
|
private |
Convert ESP-IDF WiFi mode to HardFOC mode.
| mode | ESP-IDF WiFi mode |
|
private |
Convert HardFOC security to ESP-IDF auth mode.
| security | HardFOC security type |
|
private |
Convert HardFOC WiFi mode to ESP-IDF mode.
| mode | HardFOC WiFi mode |
|
overridevirtualnoexcept |
Deinitialize the WiFi subsystem.
Implements BaseWifi.
|
private |
Deinitialize ESP-IDF network interface.
|
overridevirtualnoexcept |
Disconnect from WiFi network.
Implements BaseWifi.
| hf_wifi_err_t EspWifi::EnableWpa3Transition | ( | bool | enable | ) |
Enable WPA3 transition mode (WPA2/WPA3 mixed)
| enable | True to enable transition mode |
| hf_wifi_err_t EspWifi::GetAdvancedConfig | ( | EspWifiAdvancedConfig & | config | ) | const |
Get current advanced configuration.
| config | Reference to store current configuration |
| wifi_bandwidth_t EspWifi::GetBandwidth | ( | ) | const |
Get WiFi channel bandwidth.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Get connected network BSSID.
| bssid | Buffer to store BSSID (6 bytes) |
Implements BaseWifi.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Get number of connected stations.
Implements BaseWifi.
| hf_wifi_err_t EspWifi::GetConnectionInfo | ( | wifi_ap_record_t & | info | ) | const |
Get detailed connection information.
| info | Reference to store connection information |
|
overridevirtualnoexcept |
Get current IP information.
| ip_info | Reference to store IP information |
Implements BaseWifi.
|
overridevirtualnoexcept |
Get MAC address.
| mac | Buffer to store MAC address (6 bytes) |
| interface | WiFi interface (0 for station, 1 for AP) |
Implements BaseWifi.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Get scan results.
| networks | Vector to store found networks |
| max_networks | Maximum number of networks to return (0 for all) |
Implements BaseWifi.
|
overridevirtualnoexcept |
| hf_wifi_err_t EspWifi::GetStatistics | ( | wifi_pkt_rx_ctrl_t & | stats | ) | const |
Get WiFi statistics.
| stats | Reference to store WiFi statistics |
| int8_t EspWifi::GetTxPower | ( | ) | const |
Get WiFi TX power.
|
private |
Handle IP events internally.
| event_id | ESP-IDF event ID |
| event_data | Event data |
|
private |
Handle SmartConfig events internally.
| event_id | ESP-IDF event ID |
| event_data | Event data |
|
private |
Handle WiFi events internally.
| event_id | ESP-IDF event ID |
| event_data | Event data |
|
overridevirtualnoexcept |
Initialize the WiFi subsystem.
| mode | WiFi operating mode |
Implements BaseWifi.
| hf_wifi_err_t EspWifi::InitMesh | ( | const uint8_t | mesh_id[6], |
| uint8_t | max_layer = 6, | ||
| uint16_t | max_connection = 10 ) |
Initialize ESP-MESH networking.
| mesh_id | Mesh network ID |
| max_layer | Maximum mesh layers |
| max_connection | Maximum connections per node |
|
private |
Initialize ESP-IDF network interface.
|
staticprivate |
Static IP event handler for ESP-IDF.
| arg | User argument (EspWifi instance) |
| event_base | Event base |
| event_id | Event ID |
| event_data | Event data |
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
|
private |
Notify user event callback.
| event | HardFOC WiFi event |
| event_data | Event data |
| hf_wifi_err_t EspWifi::PerformCalibration | ( | ) |
Perform WiFi calibration.
|
overridevirtualnoexcept |
Register event callback.
| callback | Event callback function |
Implements BaseWifi.
|
private |
Register ESP-IDF event handlers.
| hf_wifi_err_t EspWifi::SetAdvancedConfig | ( | const EspWifiAdvancedConfig & | config | ) |
Set advanced ESP32-specific configuration.
| config | Advanced configuration structure |
| hf_wifi_err_t EspWifi::SetBandwidth | ( | wifi_bandwidth_t | bandwidth | ) |
Set WiFi channel bandwidth.
| bandwidth | Channel bandwidth |
|
overridevirtualnoexcept |
Set WiFi channel.
| channel | Channel number (1-14) |
Implements BaseWifi.
|
overridevirtualnoexcept |
Set MAC address.
| mac | MAC address to set (6 bytes) |
| interface | WiFi interface (0 for station, 1 for AP) |
Implements BaseWifi.
|
overridevirtualnoexcept |
Set WiFi operating mode.
| mode | WiFi operating mode |
Implements BaseWifi.
|
overridevirtualnoexcept |
Set power save mode.
| mode | Power save mode |
Implements BaseWifi.
| hf_wifi_err_t EspWifi::SetTxPower | ( | uint8_t | power | ) |
Set WiFi TX power.
| power | TX power in dBm (0-20) |
|
staticprivate |
Static SmartConfig event handler for ESP-IDF.
| arg | User argument (EspWifi instance) |
| event_base | Event base |
| event_id | Event ID |
| event_data | Event data |
|
overridevirtualnoexcept |
Start Access Point.
Implements BaseWifi.
| hf_wifi_err_t EspWifi::StartMeshChild | ( | ) |
Start ESP-MESH as child node.
| hf_wifi_err_t EspWifi::StartMeshRoot | ( | ) |
Start ESP-MESH as root node.
|
overridevirtualnoexcept |
Start network scan.
| show_hidden | Include hidden networks in scan |
| passive | Use passive scanning |
| max_scan_time_ms | Maximum scan time per channel |
Implements BaseWifi.
| hf_wifi_err_t EspWifi::StartSmartConfig | ( | smartconfig_type_t | type = SC_TYPE_ESPTOUCH, |
| uint32_t | timeout_ms = 60000 ) |
Start SmartConfig provisioning.
| type | SmartConfig type |
| timeout_ms | Provisioning timeout in milliseconds |
|
overridevirtualnoexcept |
Stop Access Point.
Implements BaseWifi.
| hf_wifi_err_t EspWifi::StopMesh | ( | ) |
Stop ESP-MESH networking.
| hf_wifi_err_t EspWifi::StopSmartConfig | ( | ) |
Stop SmartConfig provisioning.
|
overridevirtualnoexcept |
Unregister event callback.
Implements BaseWifi.
|
private |
Unregister ESP-IDF event handlers.
|
private |
Update internal state.
| new_state | New WiFi state |
|
private |
Validate AP configuration parameters.
| config | AP configuration to validate |
|
private |
Validate configuration parameters.
| config | Configuration to validate |
|
staticprivate |
Static WiFi event handler for ESP-IDF.
| arg | User argument (EspWifi instance) |
| event_base | Event base |
| event_id | Event ID |
| event_data | Event data |
|
private |
Advanced configuration
|
private |
AP active state
|
private |
AP configuration
|
private |
AP network interface
|
private |
Current channel
|
private |
Connection state
|
private |
WiFi enabled state
|
private |
User event callback
|
private |
FreeRTOS event group for WiFi events
|
mutableprivate |
Event queue mutex
|
private |
Event queue
|
private |
User data for event callback
|
private |
Initialization state
|
private |
IP event handler
|
private |
Mesh active
|
private |
Current WiFi mode
|
mutableprivate |
Main synchronization mutex
|
private |
Current RSSI
|
private |
User scan callback
|
mutableprivate |
Scan results mutex
|
private |
Last scan results
|
private |
User data for scan callback
|
private |
Scanning state
|
private |
SmartConfig active
|
private |
Station configuration
|
private |
Station network interface
|
private |
Current WiFi state
|
private |
WiFi event handler