|
ESPHome 2026.2.1
|
This component is responsible for managing the ESP WiFi interface. More...
#include <wifi_component.h>
Public Member Functions | |
| WiFiComponent () | |
| Construct a WiFiComponent. | |
| void | set_sta (const WiFiAP &ap) |
| WiFiAP | get_sta () const |
| void | init_sta (size_t count) |
| void | add_sta (const WiFiAP &ap) |
| void | clear_sta () |
| void | set_ap (const WiFiAP &ap) |
| Setup an Access Point that should be created if no connection to a station can be made. | |
| WiFiAP | get_ap () |
| void | set_ap_timeout (uint32_t ap_timeout) |
| void | enable () |
| void | disable () |
| bool | is_disabled () |
| void | start_scanning () |
| void | check_scanning_finished () |
| void | start_connecting (const WiFiAP &ap) |
| void | start_connecting (const WiFiAP &ap, bool) |
| void | check_connecting_finished (uint32_t now) |
| void | retry_connect () |
| bool | can_proceed () override |
| void | set_reboot_timeout (uint32_t reboot_timeout) |
| bool | is_connected () |
| void | set_power_save_mode (WiFiPowerSaveMode power_save) |
| void | set_min_auth_mode (WifiMinAuthMode min_auth_mode) |
| void | set_output_power (float output_power) |
| void | set_passive_scan (bool passive) |
| void | save_wifi_sta (const std::string &ssid, const std::string &password) |
| void | save_wifi_sta (const char *ssid, const char *password) |
| void | save_wifi_sta (StringRef ssid, StringRef password) |
| void | setup () override |
| Setup WiFi interface. | |
| void | start () |
| void | dump_config () override |
| void | restart_adapter () |
| float | get_setup_priority () const override |
| WIFI setup_priority. | |
| float | get_loop_priority () const override |
| void | loop () override |
| Reconnect WiFi if required. | |
| bool | has_sta () const |
| bool | has_ap () const |
| bool | is_ap_active () const |
| void | set_btm (bool btm) |
| void | set_rrm (bool rrm) |
| network::IPAddress | get_dns_address (int num) |
| network::IPAddresses | get_ip_addresses () |
| const char * | get_use_address () const |
| void | set_use_address (const char *use_address) |
| const wifi_scan_vector_t< WiFiScanResult > & | get_scan_result () const |
| network::IPAddress | wifi_soft_ap_ip () |
| bool | has_sta_priority (const bssid_t &bssid) |
| int8_t | get_sta_priority (const bssid_t bssid) |
| void | set_sta_priority (const bssid_t bssid, int8_t priority) |
| network::IPAddresses | wifi_sta_ip_addresses () |
| std::string | wifi_ssid () |
| const char * | wifi_ssid_to (std::span< char, SSID_BUFFER_SIZE > buffer) |
| Write SSID to buffer without heap allocation. | |
| bssid_t | wifi_bssid () |
| int8_t | wifi_rssi () |
| void | set_enable_on_boot (bool enable_on_boot) |
| void | set_keep_scan_results (bool keep_scan_results) |
| void | set_post_connect_roaming (bool enabled) |
| Trigger * | get_connect_trigger () |
| Trigger * | get_disconnect_trigger () |
| int32_t | get_wifi_channel () |
| void | add_ip_state_listener (WiFiIPStateListener *listener) |
| Add a listener for IP state changes. | |
| void | add_scan_results_listener (WiFiScanResultsListener *listener) |
| Add a listener for WiFi scan results. | |
| void | add_connect_state_listener (WiFiConnectStateListener *listener) |
| Add a listener for WiFi connection state changes. | |
| void | add_power_save_listener (WiFiPowerSaveListener *listener) |
| Add a listener for WiFi power save mode changes. | |
| bool | request_high_performance () |
| Request high-performance mode (no power saving) for improved WiFi latency. | |
| bool | release_high_performance () |
| Release a high-performance mode request. | |
Public Member Functions inherited from esphome::Component | |
| float | get_actual_setup_priority () const |
| void | set_setup_priority (float priority) |
| void | call () |
| virtual void | on_shutdown () |
| virtual void | on_safe_shutdown () |
| virtual bool | teardown () |
| Called during teardown to allow component to gracefully finish operations. | |
| virtual void | on_powerdown () |
| Called after teardown is complete to power down hardware. | |
| uint8_t | get_component_state () const |
| void | reset_to_construction_state () |
| Reset this component back to the construction state to allow setup to run again. | |
| bool | is_in_loop_state () const |
| Check if this component has completed setup and is in the loop state. | |
| bool | is_idle () const |
| Check if this component is idle. | |
| virtual void | mark_failed () |
| Mark this component as failed. | |
| ESPDEPRECATED ("Use mark_failed(LOG_STR(\"static string literal\")) instead. Do NOT use .c_str() from temporary " "strings. Will stop working in 2026.6.0", "2025.12.0") void mark_failed(const char *message) | |
| void | mark_failed (const LogString *message) |
| void | disable_loop () |
| Disable this component's loop. | |
| void | enable_loop () |
| Enable this component's loop. | |
| void | enable_loop_soon_any_context () |
| Thread and ISR-safe version of enable_loop() that can be called from any context. | |
| bool | is_failed () const |
| bool | is_ready () const |
| bool | status_has_warning () const |
| bool | status_has_error () const |
| void | status_set_warning (const char *message=nullptr) |
| void | status_set_warning (const LogString *message) |
| void | status_set_error () |
| ESPDEPRECATED ("Use status_set_error(LOG_STR(\"static string literal\")) instead. Do NOT use .c_str() from temporary " "strings. Will stop working in 2026.6.0", "2025.12.0") void status_set_error(const char *message) | |
| void | status_set_error (const LogString *message) |
| void | status_clear_warning () |
| void | status_clear_error () |
| void | status_momentary_warning (const char *name, uint32_t length=5000) |
| Set warning status flag and automatically clear it after a timeout. | |
| void | status_momentary_error (const char *name, uint32_t length=5000) |
| Set error status flag and automatically clear it after a timeout. | |
| bool | has_overridden_loop () const |
| void | set_component_source (const LogString *source) |
| Set where this component was loaded from for some debug messages. | |
| const LogString * | get_component_log_str () const |
| Get the integration where this component was declared as a LogString for logging. | |
| bool | should_warn_of_blocking (uint32_t blocking_time) |
Protected Member Functions | |
| void | setup_ap_config_ () |
| void | print_connect_params_ () |
| WiFiAP | build_params_for_current_phase_ () |
| WiFiRetryPhase | determine_next_phase_ () |
| Determine next retry phase based on current state and failure conditions. | |
| 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), false otherwise. | |
| 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 phase requires scan results but they're missing or don't match. | |
| bool | went_through_explicit_hidden_phase_ () const |
| Check if we went through EXPLICIT_HIDDEN phase (first network is marked hidden) Used in RETRY_HIDDEN to determine whether to skip explicitly hidden networks. | |
| 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, or -1 if all networks are hidden. | |
| bool | ssid_was_seen_in_scan_ (const CompactString &ssid) const |
| Check if an SSID was seen in the most recent scan results Used to skip hidden mode for SSIDs we know are visible. | |
| bool | needs_full_scan_results_ () const |
| Check if full scan results are needed (captive portal active, improv, listeners) | |
| bool | matches_configured_network_ (const char *ssid, const uint8_t *bssid) const |
| Check if network matches any configured network (for scan result filtering) Matches by SSID when configured, or by BSSID for BSSID-only configs. | |
| void | log_discarded_scan_result_ (const char *ssid, const uint8_t *bssid, int8_t rssi, uint8_t channel) |
| Log a discarded scan result at VERBOSE level (skipped during roaming scans to avoid log overflow) | |
| 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 SSID, or -1 if none found. | |
| void | log_and_adjust_priority_for_failed_connect_ () |
| Log failed connection and decrease BSSID priority to avoid repeated attempts. | |
| void | clear_all_bssid_priorities_ () |
| Clear all BSSID priority penalties after successful connection (stale after disconnect) | |
| void | clear_priorities_if_all_min_ () |
| Clear BSSID priority tracking if all priorities are at minimum (saves memory) | |
| void | advance_to_next_target_or_increment_retry_ () |
| Advance to next target (AP/SSID) within current phase, or increment retry counter Called when staying in the same phase after a failed connection attempt. | |
| void | start_initial_connection_ () |
| Start initial connection - either scan or connect directly to hidden networks. | |
| const WiFiAP * | get_selected_sta_ () const |
| void | reset_selected_ap_to_first_if_invalid_ () |
| bool | all_networks_hidden_ () const |
| void | connect_soon_ () |
| void | wifi_loop_ () |
| void | process_pending_callbacks_ () |
| bool | wifi_mode_ (optional< bool > sta, optional< bool > ap) |
| bool | wifi_sta_pre_setup_ () |
| bool | wifi_apply_output_power_ (float output_power) |
| bool | wifi_apply_power_save_ () |
| bool | wifi_sta_ip_config_ (const optional< ManualIP > &manual_ip) |
| bool | wifi_apply_hostname_ () |
| bool | wifi_sta_connect_ (const WiFiAP &ap) |
| void | wifi_pre_setup_ () |
| WiFiSTAConnectStatus | wifi_sta_connect_status_ () |
| bool | wifi_scan_start_ (bool passive) |
| bool | wifi_ap_ip_config_ (const optional< ManualIP > &manual_ip) |
| bool | wifi_start_ap_ (const WiFiAP &ap) |
| bool | wifi_disconnect_ () |
| network::IPAddress | wifi_subnet_mask_ () |
| network::IPAddress | wifi_gateway_ip_ () |
| network::IPAddress | wifi_dns_ip_ (int num) |
| bool | is_captive_portal_active_ () |
| bool | is_esp32_improv_active_ () |
| bool | load_fast_connect_settings_ (WiFiAP ¶ms) |
| void | save_fast_connect_settings_ () |
| void | check_roaming_ (uint32_t now) |
| void | process_roaming_scan_ () |
| void | clear_roaming_state_ () |
| void | release_scan_results_ () |
| Free scan results memory unless a component needs them. | |
| void | notify_connect_state_listeners_ () |
| Notify connect state listeners (called after state machine reaches STA_CONNECTED) | |
| void | notify_disconnect_state_listeners_ () |
| Notify connect state listeners of disconnection. | |
| void | notify_ip_state_listeners_ () |
| Notify IP state listeners with current addresses. | |
| void | notify_scan_results_listeners_ () |
| Notify scan results listeners with current scan results. | |
| void | wifi_scan_done_callback_ (void *arg, STATUS status) |
| void | wifi_process_event_ (IDFWiFiEvent *data) |
| void | wifi_scan_result (void *env, const cyw43_ev_scan_result_t *result) |
| void | wifi_event_callback_ (arduino_event_id_t event, arduino_event_info_t info) |
| void | wifi_process_event_ (LTWiFiEvent *event) |
| void | wifi_scan_done_callback_ () |
Protected Member Functions inherited from esphome::Component | |
| virtual void | call_loop () |
| virtual void | call_setup () |
| virtual void | call_dump_config () |
| void | set_component_state_ (uint8_t state) |
| Helper to set component state (clears state bits and sets new state) | |
| void | set_interval (uint32_t id, uint32_t interval, std::function< void()> &&f) |
| Set an interval function with a numeric ID (zero heap allocation). | |
| void | set_interval (InternalSchedulerID id, uint32_t interval, std::function< void()> &&f) |
| void | set_interval (uint32_t interval, std::function< void()> &&f) |
| bool | cancel_interval (uint32_t id) |
| bool | cancel_interval (InternalSchedulerID id) |
| ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std | ESPDEPRECATED ("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const char *name |
| ESPDEPRECATED ("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(uint32_t id | |
| ESPDEPRECATED ("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(uint32_t initial_wait_time | |
| ESPDEPRECATED("cancel_retry is deprecated and will be removed in 2026.8.0.", "2026.2.0") bool cancel_retry(const std | ESPDEPRECATED ("cancel_retry is deprecated and will be removed in 2026.8.0.", "2026.2.0") bool cancel_retry(const char *name) |
| ESPDEPRECATED ("cancel_retry is deprecated and will be removed in 2026.8.0.", "2026.2.0") bool cancel_retry(uint32_t id) | |
| void | set_timeout (uint32_t id, uint32_t timeout, std::function< void()> &&f) |
| Set a timeout function with a numeric ID (zero heap allocation). | |
| void | set_timeout (InternalSchedulerID id, uint32_t timeout, std::function< void()> &&f) |
| void | set_timeout (uint32_t timeout, std::function< void()> &&f) |
| bool | cancel_timeout (uint32_t id) |
| bool | cancel_timeout (InternalSchedulerID id) |
| void | defer (std::function< void()> &&f) |
| Defer a callback to the next loop() call. | |
| void | defer (uint32_t id, std::function< void()> &&f) |
| Defer a callback with a numeric ID (zero heap allocation) | |
| bool | cancel_defer (uint32_t id) |
Static Protected Member Functions | |
| static void | wifi_event_callback (System_Event_t *event) |
| static void | s_wifi_scan_done_callback (void *arg, STATUS status) |
| static int | s_wifi_scan_result (void *env, const cyw43_ev_scan_result_t *result) |
Protected Attributes | ||
| FixedVector< WiFiAP > | sta_ | |
| std::vector< WiFiSTAPriority > | sta_priorities_ | |
| wifi_scan_vector_t< WiFiScanResult > | scan_result_ | |
| WiFiAP | ap_ | |
| StaticVector< WiFiIPStateListener *, ESPHOME_WIFI_IP_STATE_LISTENERS > | ip_state_listeners_ | |
| StaticVector< WiFiScanResultsListener *, ESPHOME_WIFI_SCAN_RESULTS_LISTENERS > | scan_results_listeners_ | |
| StaticVector< WiFiConnectStateListener *, ESPHOME_WIFI_CONNECT_STATE_LISTENERS > | connect_state_listeners_ | |
| StaticVector< WiFiPowerSaveListener *, ESPHOME_WIFI_POWER_SAVE_LISTENERS > | power_save_listeners_ | |
| ESPPreferenceObject | pref_ | |
| ESPPreferenceObject | fast_connect_pref_ | |
| Trigger | connect_trigger_ | |
| Trigger | disconnect_trigger_ | |
| SemaphoreHandle_t | high_performance_semaphore_ {nullptr} | |
| float | output_power_ {NAN} | |
| uint32_t | action_started_ | |
| uint32_t | last_connected_ {0} | |
| uint32_t | reboot_timeout_ {} | |
| uint32_t | roaming_last_check_ {0} | |
| uint32_t | ap_timeout_ {} | |
| WiFiComponentState | state_ {WIFI_COMPONENT_STATE_OFF} | |
| WiFiPowerSaveMode | power_save_ {WIFI_POWER_SAVE_NONE} | |
| WifiMinAuthMode | min_auth_mode_ {WIFI_MIN_AUTH_MODE_WPA2} | |
| WiFiRetryPhase | retry_phase_ {WiFiRetryPhase::INITIAL_CONNECT} | |
| uint8_t | num_retried_ {0} | |
| int8_t | selected_sta_index_ {-1} | |
| uint8_t | roaming_attempts_ {0} | |
| uint8_t | num_ipv6_addresses_ {0} | |
| bool | error_from_callback_ {false} | |
| RetryHiddenMode | retry_hidden_mode_ {RetryHiddenMode::BLIND_RETRY} | |
| RoamingState | roaming_state_ {RoamingState::IDLE} | |
| WiFiPowerSaveMode | configured_power_save_ {WIFI_POWER_SAVE_NONE} | |
| struct { | ||
| bool connect_state: 1 | ||
| bool disconnect: 1 | ||
| bool got_ip: 1 | ||
| bool scan_complete: 1 | ||
| } | pending_ | |
| bool | has_ap_ {false} | |
| bool | handled_connected_state_ {false} | |
| bool | scan_done_ {false} | |
| bool | ap_setup_ {false} | |
| bool | ap_started_ {false} | |
| bool | passive_scan_ {false} | |
| bool | has_saved_wifi_settings_ {false} | |
| bool | btm_ {false} | |
| bool | rrm_ {false} | |
| bool | enable_on_boot_ {true} | |
| bool | got_ipv4_address_ {false} | |
| bool | keep_scan_results_ {false} | |
| bool | has_completed_scan_after_captive_portal_start_ | |
| bool | skip_cooldown_next_cycle_ {false} | |
| bool | post_connect_roaming_ {true} | |
| bool | is_high_performance_mode_ {false} | |
Protected Attributes inherited from esphome::Component | ||
| ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_interval(const std voi | set_interval )(const char *name, uint32_t interval, std::function< void()> &&f) | |
| Set an interval function with a unique name. | ||
| ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_interval(const std boo | cancel_interval )(const char *name) | |
| Cancel an interval function. | ||
| ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t | initial_wait_time | |
| ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t | max_attempts | |
| ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t std::function< RetryResult(uint8_t)> && | f | |
| ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t std::function< RetryResult(uint8_t)> float | backoff_increase_factor = 1.0f) | |
| uint32_t | initial_wait_time | |
| uint32_t uint8_t | max_attempts | |
| uint32_t uint8_t std::function< RetryResult(uint8_t)> && | f | |
| uint32_t uint8_t std::function< RetryResult(uint8_t)> float | backoff_increase_factor = 1.0f) | |
| uint8_t | max_attempts | |
| uint8_t std::function< RetryResult(uint8_t)> && | f | |
| uint8_t std::function< RetryResult(uint8_t)> float | backoff_increase_factor = 1.0f) | |
| ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_timeout(const std voi | set_timeout )(const char *name, uint32_t timeout, std::function< void()> &&f) | |
| Set a timeout function with a unique name. | ||
| ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_timeout(const std boo | cancel_timeout )(const char *name) | |
| Cancel a timeout function. | ||
| ESPDEPRECATED("Use const char* overload instead. Removed in 2026.7.0", "2026.1.0") void defer(const std voi | defer )(const char *name, std::function< void()> &&f) | |
| Defer a callback to the next loop() call. | ||
| ESPDEPRECATED("Use const char* overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_defer(const std boo | cancel_defer )(const char *name) | |
| Cancel a defer callback using the specified name, name must not be empty. | ||
| const LogString * | component_source_ {nullptr} | |
| uint16_t | warn_if_blocking_over_ {WARN_IF_BLOCKING_OVER_MS} | |
| Warn if blocked for this many ms (max 65.5s) | ||
| uint8_t | component_state_ {0x00} | |
| State of this component - each bit has a purpose: Bits 0-2: Component state (0x00=CONSTRUCTION, 0x01=SETUP, 0x02=LOOP, 0x03=FAILED, 0x04=LOOP_DONE) Bit 3: STATUS_LED_WARNING Bit 4: STATUS_LED_ERROR Bits 5-7: Unused - reserved for future expansion. | ||
| volatile bool | pending_enable_loop_ {false} | |
| ISR-safe flag for enable_loop_soon_any_context. | ||
Static Protected Attributes | |
| static constexpr uint32_t | ROAMING_CHECK_INTERVAL = 5 * 60 * 1000 |
| static constexpr int8_t | ROAMING_MIN_IMPROVEMENT = 10 |
| static constexpr int8_t | ROAMING_GOOD_RSSI = -49 |
| static constexpr uint8_t | ROAMING_MAX_ATTEMPTS = 3 |
This component is responsible for managing the ESP WiFi interface.
Definition at line 389 of file wifi_component.h.
| esphome::wifi::WiFiComponent::WiFiComponent | ( | ) |
Construct a WiFiComponent.
Definition at line 857 of file wifi_component.cpp.
|
inline |
Add a listener for WiFi connection state changes.
Listener receives: SSID, BSSID
Definition at line 542 of file wifi_component.h.
|
inline |
Add a listener for IP state changes.
Listener receives: IP addresses, DNS address 1, DNS address 2
Definition at line 530 of file wifi_component.h.
|
inline |
Add a listener for WiFi power save mode changes.
Listener receives: WiFiPowerSaveMode
Definition at line 550 of file wifi_component.h.
|
inline |
Add a listener for WiFi scan results.
Definition at line 534 of file wifi_component.h.
| void esphome::wifi::WiFiComponent::add_sta | ( | const WiFiAP & | ap | ) |
Definition at line 963 of file wifi_component.cpp.
|
protected |
Advance to next target (AP/SSID) within current phase, or increment retry counter Called when staying in the same phase after a failed connection attempt.
Handle target advancement or retry counter increment when staying in the same phase This function is called when a connection attempt fails and determine_next_phase_() indicates we should stay in the current phase.
It decides whether to:
Phase-specific behavior:
Definition at line 1937 of file wifi_component.cpp.
|
inlineprotected |
Definition at line 644 of file wifi_component.h.
|
protected |
Definition at line 979 of file wifi_component.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 2042 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::check_connecting_finished | ( | uint32_t | now | ) |
Definition at line 1464 of file wifi_component.cpp.
|
protected |
Definition at line 2308 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::check_scanning_finished | ( | ) |
Definition at line 1363 of file wifi_component.cpp.
|
protected |
Clear all BSSID priority penalties after successful connection (stale after disconnect)
Definition at line 1827 of file wifi_component.cpp.
|
protected |
Clear BSSID priority tracking if all priorities are at minimum (saves memory)
Clear BSSID priority tracking if all priorities are at minimum (saves memory) At minimum priority, all BSSIDs are equally bad, so priority tracking is useless Called after failed connection attempts.
Definition at line 1836 of file wifi_component.cpp.
|
protected |
Definition at line 2252 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::clear_sta | ( | ) |
Definition at line 964 of file wifi_component.cpp.
|
protected |
Definition at line 1046 of file wifi_component.cpp.
|
protected |
Determine next retry phase based on current state and failure conditions.
Determine the next retry phase based on current state and failure conditions This function examines the current retry phase, number of retries, and failure reasons to decide what phase to move to next.
It does not modify any state - it only returns the recommended next phase.
Definition at line 1592 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::disable | ( | ) |
Definition at line 1249 of file wifi_component.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 1448 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::enable | ( | ) |
Definition at line 1240 of file wifi_component.cpp.
|
protected |
Find the index of the first non-hidden network Returns where EXPLICIT_HIDDEN phase would have stopped, or -1 if all networks are hidden.
Definition at line 328 of file wifi_component.cpp.
|
protected |
Find next SSID that wasn't in scan results (might be hidden) Returns index of next potentially hidden SSID, or -1 if none found.
| start_index | Start searching from index after this (-1 to start from beginning) |
Definition at line 503 of file wifi_component.cpp.
|
inline |
Definition at line 410 of file wifi_component.h.
|
inline |
Definition at line 518 of file wifi_component.h.
|
inline |
Definition at line 521 of file wifi_component.h.
| network::IPAddress esphome::wifi::WiFiComponent::get_dns_address | ( | int | num | ) |
Definition at line 877 of file wifi_component.cpp.
| network::IPAddresses esphome::wifi::WiFiComponent::get_ip_addresses | ( | ) |
Definition at line 866 of file wifi_component.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 958 of file wifi_component.cpp.
|
inline |
Definition at line 473 of file wifi_component.h.
|
inlineprotected |
Definition at line 631 of file wifi_component.h.
|
overridevirtual |
WIFI setup_priority.
Reimplemented from esphome::Component.
Definition at line 582 of file wifi_component.cpp.
| WiFiAP esphome::wifi::WiFiComponent::get_sta | ( | ) | const |
Definition at line 1022 of file wifi_component.cpp.
|
inline |
Definition at line 484 of file wifi_component.h.
| const char * esphome::wifi::WiFiComponent::get_use_address | ( | ) | const |
Definition at line 884 of file wifi_component.cpp.
| int32_t esphome::wifi::WiFiComponent::get_wifi_channel | ( | ) |
Definition at line 919 of file wifi_component_esp8266.cpp.
| bool esphome::wifi::WiFiComponent::has_ap | ( | ) | const |
Definition at line 859 of file wifi_component.cpp.
| bool esphome::wifi::WiFiComponent::has_sta | ( | ) | const |
Definition at line 861 of file wifi_component.cpp.
|
inline |
Definition at line 477 of file wifi_component.h.
| void esphome::wifi::WiFiComponent::init_sta | ( | size_t | count | ) |
Definition at line 962 of file wifi_component.cpp.
| bool esphome::wifi::WiFiComponent::is_ap_active | ( | ) | const |
Definition at line 860 of file wifi_component.cpp.
|
protected |
Definition at line 2064 of file wifi_component.cpp.
| bool esphome::wifi::WiFiComponent::is_connected | ( | ) |
Definition at line 2051 of file wifi_component.cpp.
| bool esphome::wifi::WiFiComponent::is_disabled | ( | ) |
Definition at line 1259 of file wifi_component.cpp.
|
protected |
Definition at line 2071 of file wifi_component.cpp.
|
protected |
Definition at line 2112 of file wifi_component.cpp.
|
protected |
Log failed connection and decrease BSSID priority to avoid repeated attempts.
Log failed connection attempt and decrease BSSID priority to avoid repeated failures This function identifies which BSSID was attempted (from scan results or config), decreases its priority by 1.0 to discourage future attempts, and logs the change.
The priority degradation system ensures that failed BSSIDs are automatically sorted lower in subsequent scans, naturally cycling through different APs without explicit BSSID tracking within a scan cycle.
Priority sources:
If no BSSID is available (SSID-only connection), priority adjustment is skipped.
IMPORTANT: Priority is only decreased on the LAST attempt for a BSSID in SCAN_CONNECTING phase. This prevents false positives from transient WiFi stack state issues after scanning. Single failures don't necessarily mean the AP is bad - two genuine failures provide higher confidence before degrading priority and skipping the BSSID in future scans.
Definition at line 1878 of file wifi_component.cpp.
|
protected |
Log a discarded scan result at VERBOSE level (skipped during roaming scans to avoid log overflow)
Definition at line 490 of file wifi_component.cpp.
|
overridevirtual |
Reconnect WiFi if required.
Reimplemented from esphome::Component.
Definition at line 711 of file wifi_component.cpp.
|
protected |
Check if network matches any configured network (for scan result filtering) Matches by SSID when configured, or by BSSID for BSSID-only configs.
Definition at line 465 of file wifi_component.cpp.
|
protected |
Check if full scan results are needed (captive portal active, improv, listeners)
Definition at line 434 of file wifi_component.cpp.
|
protected |
Check if we need valid scan results for the current phase but don't have any Returns true if the phase requires scan results but they're missing or don't match.
Definition at line 407 of file wifi_component.cpp.
|
protected |
Notify connect state listeners (called after state machine reaches STA_CONNECTED)
Definition at line 2271 of file wifi_component.cpp.
|
protected |
Notify connect state listeners of disconnection.
Definition at line 2284 of file wifi_component.cpp.
|
protected |
Notify IP state listeners with current addresses.
Definition at line 2293 of file wifi_component.cpp.
|
protected |
Notify scan results listeners with current scan results.
Definition at line 2301 of file wifi_component.cpp.
|
protected |
Definition at line 1194 of file wifi_component.cpp.
|
protected |
Definition at line 933 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 2332 of file wifi_component.cpp.
| bool esphome::wifi::WiFiComponent::release_high_performance | ( | ) |
Release a high-performance mode request.
Should be called when a component no longer needs maximum WiFi latency. When all requests are released (semaphore count reaches zero), WiFi power saving is restored to the YAML-configured mode.
Note: Only supported on ESP32.
Definition at line 2095 of file wifi_component.cpp.
|
protected |
Free scan results memory unless a component needs them.
Definition at line 2258 of file wifi_component.cpp.
| bool esphome::wifi::WiFiComponent::request_high_performance | ( | ) |
Request high-performance mode (no power saving) for improved WiFi latency.
Components that need maximum WiFi performance (e.g., audio streaming, large data transfers) can call this method to temporarily disable WiFi power saving. Multiple components can request high performance simultaneously using a counting semaphore.
Power saving will be restored to the YAML-configured mode when all components have called release_high_performance().
Note: Only supported on ESP32.
Definition at line 2080 of file wifi_component.cpp.
|
inlineprotected |
Definition at line 638 of file wifi_component.h.
| void esphome::wifi::WiFiComponent::restart_adapter | ( | ) |
Definition at line 700 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::retry_connect | ( | ) |
Definition at line 1994 of file wifi_component.cpp.
|
staticprotected |
Definition at line 697 of file wifi_component_esp8266.cpp.
|
staticprotected |
Definition at line 135 of file wifi_component_pico_w.cpp.
|
protected |
Definition at line 2143 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::save_wifi_sta | ( | const char * | ssid, |
| const char * | password ) |
Definition at line 1029 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::save_wifi_sta | ( | const std::string & | ssid, |
| const std::string & | password ) |
Definition at line 1026 of file wifi_component.cpp.
Definition at line 443 of file wifi_component.h.
| void esphome::wifi::WiFiComponent::set_ap | ( | const WiFiAP & | ap | ) |
Setup an Access Point that should be created if no connection to a station can be made.
This can also be used without set_sta(). Then the AP will always be active.
If both STA and AP are defined, then both will be enabled at startup, but if a connection to a station can be made, the AP will be turned off again.
Definition at line 952 of file wifi_component.cpp.
|
inline |
Definition at line 411 of file wifi_component.h.
| void esphome::wifi::WiFiComponent::set_btm | ( | bool | btm | ) |
Definition at line 863 of file wifi_component.cpp.
|
inline |
Definition at line 513 of file wifi_component.h.
|
inline |
Definition at line 514 of file wifi_component.h.
|
inline |
Definition at line 436 of file wifi_component.h.
|
inline |
Definition at line 437 of file wifi_component.h.
| void esphome::wifi::WiFiComponent::set_passive_scan | ( | bool | passive | ) |
Definition at line 2062 of file wifi_component.cpp.
|
inline |
Definition at line 515 of file wifi_component.h.
| void esphome::wifi::WiFiComponent::set_power_save_mode | ( | WiFiPowerSaveMode | power_save | ) |
Definition at line 2055 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::set_reboot_timeout | ( | uint32_t | reboot_timeout | ) |
Definition at line 2050 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::set_rrm | ( | bool | rrm | ) |
Definition at line 864 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::set_sta | ( | const WiFiAP & | ap | ) |
Definition at line 970 of file wifi_component.cpp.
|
inline |
Definition at line 491 of file wifi_component.h.
| void esphome::wifi::WiFiComponent::set_use_address | ( | const char * | use_address | ) |
Definition at line 885 of file wifi_component.cpp.
|
overridevirtual |
Setup WiFi interface.
Reimplemented from esphome::Component.
Definition at line 584 of file wifi_component.cpp.
|
protected |
Definition at line 888 of file wifi_component.cpp.
|
protected |
Check if an SSID was seen in the most recent scan results Used to skip hidden mode for SSIDs we know are visible.
Definition at line 416 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::start | ( | ) |
Definition at line 609 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::start_connecting | ( | const WiFiAP & | ap | ) |
Definition at line 1054 of file wifi_component.cpp.
|
inline |
Definition at line 421 of file wifi_component.h.
|
protected |
Start initial connection - either scan or connect directly to hidden networks.
Definition at line 549 of file wifi_component.cpp.
| void esphome::wifi::WiFiComponent::start_scanning | ( | ) |
Definition at line 1261 of file wifi_component.cpp.
|
protected |
Transition to a new retry phase with logging Returns true if a scan was started (caller should wait), false otherwise.
Transition from current retry phase to a new phase with logging and phase-specific setup This function handles the actual state change, including:
| new_phase | The phase we're transitioning TO |
Definition at line 1731 of file wifi_component.cpp.
|
protected |
Check if we went through EXPLICIT_HIDDEN phase (first network is marked hidden) Used in RETRY_HIDDEN to determine whether to skip explicitly hidden networks.
Definition at line 322 of file wifi_component.cpp.
|
protected |
Definition at line 749 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 212 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 599 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 93 of file wifi_component_esp8266.cpp.
| bssid_t esphome::wifi::WiFiComponent::wifi_bssid | ( | ) |
Definition at line 882 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 685 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 930 of file wifi_component_esp8266.cpp.
|
staticprotected |
Definition at line 477 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 343 of file wifi_component_libretiny.cpp.
|
protected |
Definition at line 925 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 931 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 52 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 622 of file wifi_component_esp8266.cpp.
|
protected |
|
protected |
Definition at line 430 of file wifi_component_libretiny.cpp.
| int8_t esphome::wifi::WiFiComponent::wifi_rssi | ( | ) |
Definition at line 912 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 659 of file wifi_component_libretiny.cpp.
|
protected |
Definition at line 701 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 140 of file wifi_component_pico_w.cpp.
|
protected |
Definition at line 641 of file wifi_component_esp8266.cpp.
| network::IPAddress esphome::wifi::WiFiComponent::wifi_soft_ap_ip | ( | ) |
Definition at line 875 of file wifi_component_esp8266.cpp.
| std::string esphome::wifi::WiFiComponent::wifi_ssid | ( | ) |
Definition at line 890 of file wifi_component_esp8266.cpp.
| const char * esphome::wifi::WiFiComponent::wifi_ssid_to | ( | std::span< char, SSID_BUFFER_SIZE > | buffer | ) |
Write SSID to buffer without heap allocation.
Returns pointer to buffer, or empty string if not connected.
Definition at line 900 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 234 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 629 of file wifi_component_esp8266.cpp.
| network::IPAddresses esphome::wifi::WiFiComponent::wifi_sta_ip_addresses | ( | ) |
Definition at line 202 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 131 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 604 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 822 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 920 of file wifi_component_esp8266.cpp.
|
protected |
Definition at line 775 of file wifi_component.h.
|
protected |
Definition at line 739 of file wifi_component.h.
|
protected |
Definition at line 828 of file wifi_component.h.
|
protected |
Definition at line 829 of file wifi_component.h.
|
protected |
Definition at line 780 of file wifi_component.h.
|
protected |
Definition at line 833 of file wifi_component.h.
|
protected |
Definition at line 801 of file wifi_component.h.
| bool esphome::wifi::WiFiComponent::connect_state |
Definition at line 810 of file wifi_component.h.
|
protected |
Definition at line 748 of file wifi_component.h.
|
protected |
Definition at line 758 of file wifi_component.h.
| bool esphome::wifi::WiFiComponent::disconnect |
Definition at line 813 of file wifi_component.h.
|
protected |
Definition at line 761 of file wifi_component.h.
|
protected |
Definition at line 836 of file wifi_component.h.
|
protected |
Definition at line 797 of file wifi_component.h.
|
protected |
Definition at line 755 of file wifi_component.h.
| bool esphome::wifi::WiFiComponent::got_ip |
Definition at line 817 of file wifi_component.h.
|
protected |
Definition at line 837 of file wifi_component.h.
|
protected |
Definition at line 825 of file wifi_component.h.
|
protected |
Definition at line 823 of file wifi_component.h.
|
protected |
Definition at line 839 of file wifi_component.h.
|
protected |
Definition at line 831 of file wifi_component.h.
|
protected |
Definition at line 764 of file wifi_component.h.
|
protected |
Definition at line 742 of file wifi_component.h.
|
protected |
Definition at line 844 of file wifi_component.h.
|
protected |
Definition at line 838 of file wifi_component.h.
|
protected |
Definition at line 776 of file wifi_component.h.
|
protected |
Definition at line 786 of file wifi_component.h.
|
protected |
Definition at line 795 of file wifi_component.h.
|
protected |
Definition at line 788 of file wifi_component.h.
|
protected |
Definition at line 774 of file wifi_component.h.
|
protected |
Definition at line 830 of file wifi_component.h.
| struct { ... } esphome::wifi::WiFiComponent::pending_ |
|
protected |
Definition at line 842 of file wifi_component.h.
|
protected |
Definition at line 785 of file wifi_component.h.
|
protected |
Definition at line 751 of file wifi_component.h.
|
protected |
Definition at line 753 of file wifi_component.h.
|
protected |
Definition at line 777 of file wifi_component.h.
|
protected |
Definition at line 798 of file wifi_component.h.
|
protected |
Definition at line 787 of file wifi_component.h.
|
protected |
Definition at line 793 of file wifi_component.h.
|
staticconstexprprotected |
Definition at line 768 of file wifi_component.h.
|
staticconstexprprotected |
Definition at line 770 of file wifi_component.h.
|
protected |
Definition at line 778 of file wifi_component.h.
|
staticconstexprprotected |
Definition at line 771 of file wifi_component.h.
|
staticconstexprprotected |
Definition at line 769 of file wifi_component.h.
|
protected |
Definition at line 799 of file wifi_component.h.
|
protected |
Definition at line 834 of file wifi_component.h.
| bool esphome::wifi::WiFiComponent::scan_complete |
Definition at line 820 of file wifi_component.h.
|
protected |
Definition at line 827 of file wifi_component.h.
|
protected |
Definition at line 737 of file wifi_component.h.
|
protected |
Definition at line 745 of file wifi_component.h.
|
protected |
Definition at line 792 of file wifi_component.h.
|
protected |
Definition at line 841 of file wifi_component.h.
|
protected |
Definition at line 735 of file wifi_component.h.
|
protected |
Definition at line 736 of file wifi_component.h.
|
protected |
Definition at line 784 of file wifi_component.h.