ESPHome 2026.1.3
Loading...
Searching...
No Matches
wifi_component.h
Go to the documentation of this file.
1#pragma once
2
4#ifdef USE_WIFI
10
11#include <span>
12#include <string>
13#include <vector>
14
15#ifdef USE_LIBRETINY
16#include <WiFi.h>
17#endif
18
19#if defined(USE_ESP32) && defined(USE_WIFI_WPA2_EAP)
20#if (ESP_IDF_VERSION_MAJOR >= 5) && (ESP_IDF_VERSION_MINOR >= 1)
21#include <esp_eap_client.h>
22#else
23#include <esp_wpa2.h>
24#endif
25#endif
26
27#ifdef USE_ESP8266
28#include <ESP8266WiFi.h>
29#include <ESP8266WiFiType.h>
30
31#if defined(USE_ESP8266) && USE_ARDUINO_VERSION_CODE < VERSION_CODE(2, 4, 0)
32extern "C" {
33#include <user_interface.h>
34};
35#endif
36#endif
37
38#ifdef USE_RP2040
39extern "C" {
40#include "cyw43.h"
41#include "cyw43_country.h"
42#include "pico/cyw43_arch.h"
43}
44
45#include <WiFi.h>
46#endif
47
48#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
49#include <freertos/FreeRTOS.h>
50#include <freertos/semphr.h>
51#endif
52
53namespace esphome::wifi {
54
56static constexpr int8_t WIFI_RSSI_DISCONNECTED = -127;
57
59static constexpr size_t SSID_BUFFER_SIZE = 33;
60
62 char ssid[33];
63 char password[65];
64} PACKED; // NOLINT
65
67 uint8_t bssid[6];
68 uint8_t channel;
69 int8_t ap_index;
70} PACKED; // NOLINT
71
88
96
98enum class WiFiRetryPhase : uint8_t {
101#ifdef USE_WIFI_FAST_CONNECT
104#endif
113};
114
116enum class RoamingState : uint8_t {
118 IDLE,
120 SCANNING,
125};
126
128enum class RetryHiddenMode : uint8_t {
135};
136
145
146#ifdef USE_WIFI_WPA2_EAP
147struct EAPAuth {
148 std::string identity; // required for all auth types
149 std::string username;
150 std::string password;
151 const char *ca_cert; // optionally verify authentication server
152 // used for EAP-TLS
153 const char *client_cert;
154 const char *client_key;
155// used for EAP-TTLS
156#ifdef USE_ESP32
157 esp_eap_ttls_phase2_types ttls_phase_2;
158#endif
159};
160#endif // USE_WIFI_WPA2_EAP
161
162using bssid_t = std::array<uint8_t, 6>;
163
164// Use std::vector for RP2040 since scan count is unknown (callback-based)
165// Use FixedVector for other platforms where count is queried first
166#ifdef USE_RP2040
167template<typename T> using wifi_scan_vector_t = std::vector<T>;
168#else
169template<typename T> using wifi_scan_vector_t = FixedVector<T>;
170#endif
171
172class WiFiAP {
173 public:
174 void set_ssid(const std::string &ssid);
175 void set_bssid(const bssid_t &bssid);
176 void clear_bssid();
177 void set_password(const std::string &password);
178#ifdef USE_WIFI_WPA2_EAP
179 void set_eap(optional<EAPAuth> eap_auth);
180#endif // USE_WIFI_WPA2_EAP
181 void set_channel(uint8_t channel);
182 void clear_channel();
184#ifdef USE_WIFI_MANUAL_IP
185 void set_manual_ip(optional<ManualIP> manual_ip);
186#endif
187 void set_hidden(bool hidden);
188 const std::string &get_ssid() const;
189 const bssid_t &get_bssid() const;
190 bool has_bssid() const;
191 const std::string &get_password() const;
192#ifdef USE_WIFI_WPA2_EAP
193 const optional<EAPAuth> &get_eap() const;
194#endif // USE_WIFI_WPA2_EAP
195 uint8_t get_channel() const;
196 bool has_channel() const;
197 int8_t get_priority() const { return priority_; }
198#ifdef USE_WIFI_MANUAL_IP
199 const optional<ManualIP> &get_manual_ip() const;
200#endif
201 bool get_hidden() const;
202
203 protected:
204 std::string ssid_;
205 std::string password_;
206#ifdef USE_WIFI_WPA2_EAP
208#endif // USE_WIFI_WPA2_EAP
209#ifdef USE_WIFI_MANUAL_IP
211#endif
212 // Group small types together to minimize padding
213 bssid_t bssid_{}; // 6 bytes, all zeros = any/not set
214 uint8_t channel_{0}; // 1 byte, 0 = auto/not set
215 int8_t priority_{0}; // 1 byte
216 bool hidden_{false}; // 1 byte (+ 3 bytes end padding to 4-byte align)
217};
218
220 public:
221 WiFiScanResult(const bssid_t &bssid, std::string ssid, uint8_t channel, int8_t rssi, bool with_auth, bool is_hidden);
222
223 bool matches(const WiFiAP &config) const;
224
225 bool get_matches() const;
226 void set_matches(bool matches);
227 const bssid_t &get_bssid() const;
228 const std::string &get_ssid() const;
229 uint8_t get_channel() const;
230 int8_t get_rssi() const;
231 bool get_with_auth() const;
232 bool get_is_hidden() const;
233 int8_t get_priority() const { return priority_; }
235
236 bool operator==(const WiFiScanResult &rhs) const;
237
238 protected:
240 uint8_t channel_;
241 int8_t rssi_;
242 std::string ssid_;
243 int8_t priority_{0};
244 bool matches_{false};
247};
248
253
259
265
266#ifdef USE_ESP32
267struct IDFWiFiEvent;
268#endif
269
270#ifdef USE_LIBRETINY
271struct LTWiFiEvent;
272#endif
273
283 public:
284 virtual void on_ip_state(const network::IPAddresses &ips, const network::IPAddress &dns1,
285 const network::IPAddress &dns2) = 0;
286};
287
297 public:
299};
300
310 public:
311 virtual void on_wifi_connect_state(StringRef ssid, std::span<const uint8_t, 6> bssid) = 0;
312};
313
323 public:
325};
326
328class WiFiComponent : public Component {
329 public:
332
333 void set_sta(const WiFiAP &ap);
334 // Returns a copy of the currently selected AP configuration
335 WiFiAP get_sta() const;
336 void init_sta(size_t count);
337 void add_sta(const WiFiAP &ap);
338 void clear_sta();
339
340#ifdef USE_WIFI_AP
348 void set_ap(const WiFiAP &ap);
349 WiFiAP get_ap() { return this->ap_; }
350 void set_ap_timeout(uint32_t ap_timeout) { ap_timeout_ = ap_timeout; }
351#endif // USE_WIFI_AP
352
353 void enable();
354 void disable();
355 bool is_disabled();
356 void start_scanning();
358 void start_connecting(const WiFiAP &ap);
359 // Backward compatibility overload - ignores 'two' parameter
360 void start_connecting(const WiFiAP &ap, bool /* two */) { this->start_connecting(ap); }
361
362 void check_connecting_finished(uint32_t now);
363
364 void retry_connect();
365
366#ifdef USE_RP2040
367 bool can_proceed() override;
368#endif
369
370 void set_reboot_timeout(uint32_t reboot_timeout);
371
372 bool is_connected();
373
374 void set_power_save_mode(WiFiPowerSaveMode power_save);
375 void set_min_auth_mode(WifiMinAuthMode min_auth_mode) { min_auth_mode_ = min_auth_mode; }
376 void set_output_power(float output_power) { output_power_ = output_power; }
377
378 void set_passive_scan(bool passive);
379
380 void save_wifi_sta(const std::string &ssid, const std::string &password);
381
382 // ========== INTERNAL METHODS ==========
383 // (In most use cases you won't need these)
385 void setup() override;
386 void start();
387 void dump_config() override;
388 void restart_adapter();
390 float get_setup_priority() const override;
391 float get_loop_priority() const override;
392
394 void loop() override;
395
396 bool has_sta() const;
397 bool has_ap() const;
398 bool is_ap_active() const;
399
400#ifdef USE_WIFI_11KV_SUPPORT
401 void set_btm(bool btm);
402 void set_rrm(bool rrm);
403#endif
404
407 const char *get_use_address() const;
408 void set_use_address(const char *use_address);
409
411
413
414 bool has_sta_priority(const bssid_t &bssid) {
415 for (auto &it : this->sta_priorities_) {
416 if (it.bssid == bssid)
417 return true;
418 }
419 return false;
420 }
421 int8_t get_sta_priority(const bssid_t bssid) {
422 for (auto &it : this->sta_priorities_) {
423 if (it.bssid == bssid)
424 return it.priority;
425 }
426 return 0;
427 }
428 void set_sta_priority(const bssid_t bssid, int8_t priority) {
429 for (auto &it : this->sta_priorities_) {
430 if (it.bssid == bssid) {
431 it.priority = priority;
432 return;
433 }
434 }
435 this->sta_priorities_.push_back(WiFiSTAPriority{
436 .bssid = bssid,
437 .priority = priority,
438 });
439 }
440
442 std::string wifi_ssid();
445 const char *wifi_ssid_to(std::span<char, SSID_BUFFER_SIZE> buffer);
447
448 int8_t wifi_rssi();
449
450 void set_enable_on_boot(bool enable_on_boot) { this->enable_on_boot_ = enable_on_boot; }
451 void set_keep_scan_results(bool keep_scan_results) { this->keep_scan_results_ = keep_scan_results; }
452 void set_post_connect_roaming(bool enabled) { this->post_connect_roaming_ = enabled; }
453
456
457 int32_t get_wifi_channel();
458
459#ifdef USE_WIFI_IP_STATE_LISTENERS
463 void add_ip_state_listener(WiFiIPStateListener *listener) { this->ip_state_listeners_.push_back(listener); }
464#endif // USE_WIFI_IP_STATE_LISTENERS
465#ifdef USE_WIFI_SCAN_RESULTS_LISTENERS
468 this->scan_results_listeners_.push_back(listener);
469 }
470#endif // USE_WIFI_SCAN_RESULTS_LISTENERS
471#ifdef USE_WIFI_CONNECT_STATE_LISTENERS
476 this->connect_state_listeners_.push_back(listener);
477 }
478#endif // USE_WIFI_CONNECT_STATE_LISTENERS
479#ifdef USE_WIFI_POWER_SAVE_LISTENERS
483 void add_power_save_listener(WiFiPowerSaveListener *listener) { this->power_save_listeners_.push_back(listener); }
484#endif // USE_WIFI_POWER_SAVE_LISTENERS
485
486#ifdef USE_WIFI_RUNTIME_POWER_SAVE
502
515#endif // USE_WIFI_RUNTIME_POWER_SAVE
516
517 protected:
518#ifdef USE_WIFI_AP
519 void setup_ap_config_();
520#endif // USE_WIFI_AP
521
524
529 bool transition_to_phase_(WiFiRetryPhase new_phase);
532 bool needs_scan_results_() const;
538 int8_t find_first_non_hidden_index_() const;
541 bool ssid_was_seen_in_scan_(const std::string &ssid) const;
545 int8_t find_next_hidden_sta_(int8_t start_index);
557 const WiFiAP *get_selected_sta_() const {
558 if (this->selected_sta_index_ >= 0 && static_cast<size_t>(this->selected_sta_index_) < this->sta_.size()) {
559 return &this->sta_[this->selected_sta_index_];
560 }
561 return nullptr;
562 }
563
565 if (this->selected_sta_index_ < 0 || static_cast<size_t>(this->selected_sta_index_) >= this->sta_.size()) {
566 this->selected_sta_index_ = this->sta_.empty() ? -1 : 0;
567 }
568 }
569
570 bool all_networks_hidden_() const {
571 if (this->sta_.empty())
572 return false;
573 for (const auto &ap : this->sta_) {
574 if (!ap.get_hidden())
575 return false;
576 }
577 return true;
578 }
579
580 void connect_soon_();
581
582 void wifi_loop_();
584 bool wifi_sta_pre_setup_();
585 bool wifi_apply_output_power_(float output_power);
587 bool wifi_sta_ip_config_(const optional<ManualIP> &manual_ip);
589 bool wifi_sta_connect_(const WiFiAP &ap);
590 void wifi_pre_setup_();
592 bool wifi_scan_start_(bool passive);
593
594#ifdef USE_WIFI_AP
595 bool wifi_ap_ip_config_(const optional<ManualIP> &manual_ip);
596 bool wifi_start_ap_(const WiFiAP &ap);
597#endif // USE_WIFI_AP
598
599 bool wifi_disconnect_();
600
604
607
608#ifdef USE_WIFI_FAST_CONNECT
611#endif
612
613 // Post-connect roaming methods
614 void check_roaming_(uint32_t now);
617
620
621#ifdef USE_ESP8266
622 static void wifi_event_callback(System_Event_t *event);
623 void wifi_scan_done_callback_(void *arg, STATUS status);
624 static void s_wifi_scan_done_callback(void *arg, STATUS status);
625#endif
626
627#ifdef USE_ESP32
628 void wifi_process_event_(IDFWiFiEvent *data);
629#endif
630
631#ifdef USE_RP2040
632 static int s_wifi_scan_result(void *env, const cyw43_ev_scan_result_t *result);
633 void wifi_scan_result(void *env, const cyw43_ev_scan_result_t *result);
634#endif
635
636#ifdef USE_LIBRETINY
637 void wifi_event_callback_(arduino_event_id_t event, arduino_event_info_t info);
638 void wifi_process_event_(LTWiFiEvent *event);
640#endif
641
643 std::vector<WiFiSTAPriority> sta_priorities_;
645#ifdef USE_WIFI_AP
647#endif
648 float output_power_{NAN};
649#ifdef USE_WIFI_IP_STATE_LISTENERS
651#endif
652#ifdef USE_WIFI_SCAN_RESULTS_LISTENERS
654#endif
655#ifdef USE_WIFI_CONNECT_STATE_LISTENERS
657#endif
658#ifdef USE_WIFI_POWER_SAVE_LISTENERS
660#endif
662#ifdef USE_WIFI_FAST_CONNECT
664#endif
665
666 // Post-connect roaming constants
667 static constexpr uint32_t ROAMING_CHECK_INTERVAL = 5 * 60 * 1000; // 5 minutes
668 static constexpr int8_t ROAMING_MIN_IMPROVEMENT = 10; // dB
669 static constexpr int8_t ROAMING_GOOD_RSSI = -49; // Skip scan if signal is excellent
670 static constexpr uint8_t ROAMING_MAX_ATTEMPTS = 3;
671
672 // Group all 32-bit integers together
674 uint32_t last_connected_{0};
675 uint32_t reboot_timeout_{};
677#ifdef USE_WIFI_AP
678 uint32_t ap_timeout_{};
679#endif
680
681 // Group all 8-bit values together
686 uint8_t num_retried_{0};
687 // Index into sta_ array for the currently selected AP configuration (-1 = none selected)
688 // Used to access password, manual_ip, priority, EAP settings, and hidden flag
689 // int8_t limits to 127 APs (enforced in __init__.py via MAX_WIFI_NETWORKS)
692
693#if USE_NETWORK_IPV6
695#endif /* USE_NETWORK_IPV6 */
696
697 // Group all boolean values together
698 bool has_ap_{false};
701 bool scan_done_{false};
702 bool ap_setup_{false};
703 bool ap_started_{false};
704 bool passive_scan_{false};
706#ifdef USE_WIFI_11KV_SUPPORT
707 bool btm_{false};
708 bool rrm_{false};
709#endif
710 bool enable_on_boot_{true};
711 bool got_ipv4_address_{false};
715 bool post_connect_roaming_{true}; // Enabled by default
717#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
720
721 SemaphoreHandle_t high_performance_semaphore_{nullptr};
722#endif
723
724 // Pointers at the end (naturally aligned)
727
728 private:
729 // Stores a pointer to a string literal (static storage duration).
730 // ONLY set from Python-generated code with string literals - never dynamic strings.
731 const char *use_address_{""};
732};
733
734extern WiFiComponent *global_wifi_component; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
735
736} // namespace esphome::wifi
737#endif
BedjetMode mode
BedJet operating mode.
Fixed-capacity vector - allocates once at runtime, never reallocates This avoids std::vector template...
Definition helpers.h:188
Minimal static vector - saves memory by avoiding std::vector overhead.
Definition helpers.h:132
StringRef is a reference to a string owned by something else.
Definition string_ref.h:26
uint8_t get_channel() const
const std::string & get_ssid() const
void set_ssid(const std::string &ssid)
const optional< EAPAuth > & get_eap() const
const std::string & get_password() const
void set_bssid(const bssid_t &bssid)
void set_channel(uint8_t channel)
optional< EAPAuth > eap_
optional< ManualIP > manual_ip_
void set_eap(optional< EAPAuth > eap_auth)
void set_password(const std::string &password)
void set_manual_ip(optional< ManualIP > manual_ip)
const optional< ManualIP > & get_manual_ip() const
int8_t get_priority() const
void set_hidden(bool hidden)
const bssid_t & get_bssid() const
void set_priority(int8_t priority)
This component is responsible for managing the ESP WiFi interface.
Trigger * get_connect_trigger() const
void add_sta(const WiFiAP &ap)
bool load_fast_connect_settings_(WiFiAP &params)
void add_connect_state_listener(WiFiConnectStateListener *listener)
Add a listener for WiFi connection state changes.
void set_ap(const WiFiAP &ap)
Setup an Access Point that should be created if no connection to a station can be made.
bool request_high_performance()
Request high-performance mode (no power saving) for improved WiFi latency.
void set_sta(const WiFiAP &ap)
bool has_sta_priority(const bssid_t &bssid)
const WiFiAP * get_selected_sta_() const
int8_t get_sta_priority(const bssid_t bssid)
void log_and_adjust_priority_for_failed_connect_()
Log failed connection and decrease BSSID priority to avoid repeated attempts.
void save_wifi_sta(const std::string &ssid, const std::string &password)
wifi_scan_vector_t< WiFiScanResult > scan_result_
WiFiPowerSaveMode configured_power_save_
void set_sta_priority(const bssid_t bssid, int8_t priority)
StaticVector< WiFiScanResultsListener *, ESPHOME_WIFI_SCAN_RESULTS_LISTENERS > scan_results_listeners_
void loop() override
Reconnect WiFi if required.
void start_connecting(const WiFiAP &ap)
void set_enable_on_boot(bool enable_on_boot)
void advance_to_next_target_or_increment_retry_()
Advance to next target (AP/SSID) within current phase, or increment retry counter Called when staying...
void add_power_save_listener(WiFiPowerSaveListener *listener)
Add a listener for WiFi power save mode changes.
bool wifi_sta_ip_config_(const optional< ManualIP > &manual_ip)
static constexpr uint32_t ROAMING_CHECK_INTERVAL
static int s_wifi_scan_result(void *env, const cyw43_ev_scan_result_t *result)
SemaphoreHandle_t high_performance_semaphore_
network::IPAddress get_dns_address(int num)
static void wifi_event_callback(System_Event_t *event)
WiFiComponent()
Construct a WiFiComponent.
void wifi_process_event_(IDFWiFiEvent *data)
std::vector< WiFiSTAPriority > sta_priorities_
static constexpr int8_t ROAMING_GOOD_RSSI
void set_min_auth_mode(WifiMinAuthMode min_auth_mode)
StaticVector< WiFiConnectStateListener *, ESPHOME_WIFI_CONNECT_STATE_LISTENERS > connect_state_listeners_
const char * wifi_ssid_to(std::span< char, SSID_BUFFER_SIZE > buffer)
Write SSID to buffer without heap allocation.
void start_connecting(const WiFiAP &ap, bool)
static constexpr uint8_t ROAMING_MAX_ATTEMPTS
void set_passive_scan(bool passive)
void wifi_event_callback_(arduino_event_id_t event, arduino_event_info_t info)
static void s_wifi_scan_done_callback(void *arg, STATUS status)
void set_power_save_mode(WiFiPowerSaveMode power_save)
int8_t find_next_hidden_sta_(int8_t start_index)
Find next SSID that wasn't in scan results (might be hidden) Returns index of next potentially hidden...
void add_ip_state_listener(WiFiIPStateListener *listener)
Add a listener for IP state changes.
ESPPreferenceObject fast_connect_pref_
void clear_priorities_if_all_min_()
Clear BSSID priority tracking if all priorities are at minimum (saves memory)
void wifi_scan_result(void *env, const cyw43_ev_scan_result_t *result)
WiFiRetryPhase determine_next_phase_()
Determine next retry phase based on current state and failure conditions.
network::IPAddress wifi_dns_ip_(int num)
float get_loop_priority() const override
network::IPAddresses get_ip_addresses()
static constexpr int8_t ROAMING_MIN_IMPROVEMENT
float get_setup_priority() const override
WIFI setup_priority.
void set_output_power(float output_power)
StaticVector< WiFiIPStateListener *, ESPHOME_WIFI_IP_STATE_LISTENERS > ip_state_listeners_
FixedVector< WiFiAP > sta_
int8_t find_first_non_hidden_index_() const
Find the index of the first non-hidden network Returns where EXPLICIT_HIDDEN phase would have stopped...
void release_scan_results_()
Free scan results memory unless a component needs them.
bool ssid_was_seen_in_scan_(const std::string &ssid) const
Check if an SSID was seen in the most recent scan results Used to skip hidden mode for SSIDs we know ...
bool wifi_ap_ip_config_(const optional< ManualIP > &manual_ip)
bool needs_scan_results_() const
Check if we need valid scan results for the current phase but don't have any Returns true if the phas...
void add_scan_results_listener(WiFiScanResultsListener *listener)
Add a listener for WiFi scan results.
bool transition_to_phase_(WiFiRetryPhase new_phase)
Transition to a new retry phase with logging Returns true if a scan was started (caller should wait),...
Trigger * get_disconnect_trigger() const
void set_ap_timeout(uint32_t ap_timeout)
bool release_high_performance()
Release a high-performance mode request.
StaticVector< WiFiPowerSaveListener *, ESPHOME_WIFI_POWER_SAVE_LISTENERS > power_save_listeners_
bool wifi_apply_output_power_(float output_power)
void set_post_connect_roaming(bool enabled)
const char * get_use_address() const
WiFiSTAConnectStatus wifi_sta_connect_status_()
bool went_through_explicit_hidden_phase_() const
Check if we went through EXPLICIT_HIDDEN phase (first network is marked hidden) Used in RETRY_HIDDEN ...
bool wifi_mode_(optional< bool > sta, optional< bool > ap)
void set_reboot_timeout(uint32_t reboot_timeout)
network::IPAddresses wifi_sta_ip_addresses()
void check_connecting_finished(uint32_t now)
void set_keep_scan_results(bool keep_scan_results)
void start_initial_connection_()
Start initial connection - either scan or connect directly to hidden networks.
void setup() override
Setup WiFi interface.
void clear_all_bssid_priorities_()
Clear all BSSID priority penalties after successful connection (stale after disconnect)
void set_use_address(const char *use_address)
const wifi_scan_vector_t< WiFiScanResult > & get_scan_result() const
Listener interface for WiFi connection state changes.
virtual void on_wifi_connect_state(StringRef ssid, std::span< const uint8_t, 6 > bssid)=0
Listener interface for WiFi IP state changes.
virtual void on_ip_state(const network::IPAddresses &ips, const network::IPAddress &dns1, const network::IPAddress &dns2)=0
Listener interface for WiFi power save mode changes.
virtual void on_wifi_power_save(WiFiPowerSaveMode mode)=0
const std::string & get_ssid() const
const bssid_t & get_bssid() const
WiFiScanResult(const bssid_t &bssid, std::string ssid, uint8_t channel, int8_t rssi, bool with_auth, bool is_hidden)
bool matches(const WiFiAP &config) const
void set_priority(int8_t priority)
bool operator==(const WiFiScanResult &rhs) const
Listener interface for WiFi scan results.
virtual void on_wifi_scan_results(const wifi_scan_vector_t< WiFiScanResult > &results)=0
uint8_t priority
std::array< IPAddress, 5 > IPAddresses
Definition ip_address.h:180
std::array< uint8_t, 6 > bssid_t
RetryHiddenMode
Controls how RETRY_HIDDEN phase selects networks to try.
@ BLIND_RETRY
Blind retry mode: scanning disabled (captive portal/improv active), try ALL configured networks seque...
@ SCAN_BASED
Normal mode: scan completed, only try networks NOT visible in scan results (truly hidden networks tha...
std::vector< T > wifi_scan_vector_t
struct esphome::wifi::SavedWifiSettings PACKED
WiFiRetryPhase
Tracks the current retry strategy/phase for WiFi connection attempts.
@ RETRY_HIDDEN
Retry networks not found in scan (might be hidden)
@ RESTARTING_ADAPTER
Restarting WiFi adapter to clear stuck state.
@ INITIAL_CONNECT
Initial connection attempt (varies based on fast_connect setting)
@ EXPLICIT_HIDDEN
Explicitly hidden networks (user marked as hidden, try before scanning)
@ FAST_CONNECT_CYCLING_APS
Fast connect mode: cycling through configured APs (config-only, no scan)
@ SCAN_CONNECTING
Scan-based: connecting to best AP from scan results.
WiFiComponent * global_wifi_component
RoamingState
Tracks post-connect roaming state machine.
@ SCANNING
Scanning for better AP.
@ IDLE
Not roaming, waiting for next check interval.
@ RECONNECTING
Roam connection failed, reconnecting to any available AP.
@ WIFI_COMPONENT_STATE_DISABLED
WiFi is disabled.
@ WIFI_COMPONENT_STATE_AP
WiFi is in AP-only mode and internal AP is already enabled.
@ WIFI_COMPONENT_STATE_STA_CONNECTING
WiFi is in STA(+AP) mode and currently connecting to an AP.
@ WIFI_COMPONENT_STATE_OFF
Nothing has been initialized yet.
@ WIFI_COMPONENT_STATE_STA_SCANNING
WiFi is in STA-only mode and currently scanning for APs.
@ WIFI_COMPONENT_STATE_COOLDOWN
WiFi is in cooldown mode because something went wrong, scanning will begin after a short period of ti...
@ WIFI_COMPONENT_STATE_STA_CONNECTED
WiFi is in STA(+AP) mode and successfully connected.
esp_eap_ttls_phase2_types ttls_phase_2
Struct for setting static IPs in WiFiComponent.
network::IPAddress static_ip
network::IPAddress dns1
The first DNS server. 0.0.0.0 for default.
network::IPAddress gateway
network::IPAddress dns2
The second DNS server. 0.0.0.0 for default.
network::IPAddress subnet