8#if (ESP_IDF_VERSION_MAJOR >= 5 && ESP_IDF_VERSION_MINOR >= 1)
9#include <esp_eap_client.h>
19#include <user_interface.h>
33#ifdef USE_CAPTIVE_PORTAL
43static const char *
const TAG =
"wifi";
147static const LogString *retry_phase_to_log_string(
WiFiRetryPhase phase) {
150 return LOG_STR(
"INITIAL_CONNECT");
151#ifdef USE_WIFI_FAST_CONNECT
153 return LOG_STR(
"FAST_CONNECT_CYCLING");
156 return LOG_STR(
"EXPLICIT_HIDDEN");
158 return LOG_STR(
"SCAN_CONNECTING");
160 return LOG_STR(
"RETRY_HIDDEN");
162 return LOG_STR(
"RESTARTING");
164 return LOG_STR(
"UNKNOWN");
171 return !this->
sta_.empty() && this->
sta_[0].get_hidden();
177 for (
size_t i = 0; i < this->
sta_.size(); i++) {
178 if (!this->
sta_[i].get_hidden()) {
179 return static_cast<int8_t
>(i);
190static constexpr uint8_t WIFI_RETRY_COUNT_PER_BSSID = 2;
194static constexpr uint8_t WIFI_RETRY_COUNT_PER_SSID = 1;
198static constexpr uint8_t WIFI_RETRY_COUNT_PER_AP = 1;
202static constexpr uint32_t WIFI_COOLDOWN_DURATION_MS = 500;
207static constexpr uint32_t WIFI_COOLDOWN_WITH_AP_ACTIVE_MS = 30000;
212static constexpr uint32_t WIFI_SCAN_TIMEOUT_MS = 31000;
222static constexpr uint32_t WIFI_CONNECT_TIMEOUT_MS = 46000;
224static constexpr uint8_t get_max_retries_for_phase(
WiFiRetryPhase phase) {
227#ifdef USE_WIFI_FAST_CONNECT
231 return WIFI_RETRY_COUNT_PER_AP;
234 return WIFI_RETRY_COUNT_PER_SSID;
237 return WIFI_RETRY_COUNT_PER_BSSID;
240 return WIFI_RETRY_COUNT_PER_SSID;
242 return WIFI_RETRY_COUNT_PER_BSSID;
246static void apply_scan_result_to_params(WiFiAP ¶ms,
const WiFiScanResult &scan) {
247 params.set_hidden(
false);
248 params.set_ssid(scan.get_ssid());
249 params.set_bssid(scan.get_bssid());
250 params.set_channel(scan.get_channel());
265 for (
const auto &conf : this->
sta_) {
266 if (conf.get_ssid() == ssid && conf.get_hidden()) {
273 if (scan.get_ssid() == ssid) {
284 for (
size_t i = start_index + 1; i < this->
sta_.size(); i++) {
285 const auto &sta = this->
sta_[i];
290 if (!include_explicit_hidden && sta.get_hidden()) {
292 if (first_non_hidden_idx < 0 ||
static_cast<int8_t
>(i) < first_non_hidden_idx) {
293 ESP_LOGD(TAG,
"Skipping " LOG_SECRET(
"'%s'")
" (explicit hidden, already tried)", sta.get_ssid().c_str());
301 ESP_LOGD(TAG,
"Hidden candidate " LOG_SECRET(
"'%s'")
" at index %d", sta.get_ssid().c_str(),
static_cast<int>(i));
302 return static_cast<int8_t
>(i);
304 ESP_LOGD(TAG,
"Skipping hidden retry for visible network " LOG_SECRET(
"'%s'"), sta.get_ssid().c_str());
313 if (!this->
sta_.empty() && this->sta_[0].get_hidden()) {
314 ESP_LOGI(TAG,
"Starting with explicit hidden network (highest priority)");
320 ESP_LOGI(TAG,
"Starting scan");
325#if defined(USE_ESP32) && defined(USE_WIFI_WPA2_EAP) && ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
326static const char *eap_phase2_to_str(esp_eap_ttls_phase2_types
type) {
328 case ESP_EAP_TTLS_PHASE2_PAP:
330 case ESP_EAP_TTLS_PHASE2_CHAP:
332 case ESP_EAP_TTLS_PHASE2_MSCHAP:
334 case ESP_EAP_TTLS_PHASE2_MSCHAPV2:
336 case ESP_EAP_TTLS_PHASE2_EAP:
349#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
354 ESP_LOGE(TAG,
"Failed semaphore");
382#ifdef USE_WIFI_FAST_CONNECT
388 ESP_LOGD(TAG,
"Loaded settings: %s", save.ssid);
392 sta.set_password(save.password);
399 ESP_LOGV(TAG,
"Setting Output Power Option failed");
402#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
406 if (semaphore_count > 0) {
416 ESP_LOGV(TAG,
"Setting Power Save Option failed");
420#ifdef USE_WIFI_FAST_CONNECT
425 if (loaded_fast_connect) {
426 ESP_LOGI(TAG,
"Starting fast_connect (saved) " LOG_SECRET(
"'%s'"), params.
get_ssid().c_str());
428 }
else if (!this->
sta_.empty() && !this->sta_[0].get_hidden()) {
430 ESP_LOGI(TAG,
"Starting fast_connect (config) " LOG_SECRET(
"'%s'"), this->
sta_[0].get_ssid().c_str());
443 }
else if (this->
has_ap()) {
446 ESP_LOGV(TAG,
"Setting Output Power Option failed");
448#ifdef USE_CAPTIVE_PORTAL
467 ESP_LOGW(TAG,
"Restarting adapter");
497 uint32_t cooldown_duration = portal_active ? WIFI_COOLDOWN_WITH_AP_ACTIVE_MS : WIFI_COOLDOWN_DURATION_MS;
520 ESP_LOGW(TAG,
"Connection lost; reconnecting");
541 ESP_LOGI(TAG,
"Starting fallback AP");
543#ifdef USE_CAPTIVE_PORTAL
564 ESP_LOGE(TAG,
"Can't connect; rebooting");
570#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
578 ESP_LOGV(TAG,
"Switching to high-performance mode (%" PRIu32
" active %s)", (uint32_t) semaphore_count,
579 semaphore_count == 1 ?
"request" :
"requests");
586 ESP_LOGV(TAG,
"Restoring power save mode to configured setting");
601#ifdef USE_WIFI_11KV_SUPPORT
635 if (name.length() > 32) {
638 name.erase(25, name.length() - 32);
651 " AP Password: '%s'\n"
653 this->
ap_.
get_ssid().c_str(), this->ap_.get_password().c_str(), ip_address.c_str());
655#ifdef USE_WIFI_MANUAL_IP
657 if (manual_ip.has_value()) {
659 " AP Static IP: '%s'\n"
660 " AP Gateway: '%s'\n"
662 manual_ip->static_ip.str().c_str(), manual_ip->gateway.str().c_str(),
663 manual_ip->subnet.str().c_str());
695 if (config ==
nullptr) {
696 ESP_LOGE(TAG,
"No valid network config (selected_sta_index_=%d, sta_.size()=%zu)",
706#ifdef USE_WIFI_FAST_CONNECT
724 apply_scan_result_to_params(params, this->
scan_result_[0]);
738 return config ? *config :
WiFiAP{};
742 strncpy(save.ssid, ssid.c_str(),
sizeof(save.ssid) - 1);
743 strncpy(save.password, password.c_str(),
sizeof(save.password) - 1);
750 sta.set_password(password);
760 ESP_LOGD(TAG,
"Exiting cooldown early due to new WiFi credentials");
776 "Connecting to " LOG_SECRET(
"'%s'")
" " LOG_SECRET(
"(%s)")
" (priority %d, attempt %u/%u in phase %s)...",
780#ifdef ESPHOME_LOG_HAS_VERBOSE
781 ESP_LOGV(TAG,
"Connection Params:");
782 ESP_LOGV(TAG,
" SSID: '%s'", ap.
get_ssid().c_str());
784 ESP_LOGV(TAG,
" BSSID: %s", bssid_s);
786 ESP_LOGV(TAG,
" BSSID: Not Set");
789#ifdef USE_WIFI_WPA2_EAP
790 if (ap.
get_eap().has_value()) {
791 ESP_LOGV(TAG,
" WPA2 Enterprise authentication configured:");
793 ESP_LOGV(TAG,
" Identity: " LOG_SECRET(
"'%s'"), eap_config.
identity.c_str());
794 ESP_LOGV(TAG,
" Username: " LOG_SECRET(
"'%s'"), eap_config.
username.c_str());
795 ESP_LOGV(TAG,
" Password: " LOG_SECRET(
"'%s'"), eap_config.
password.c_str());
796#if defined(USE_ESP32) && defined(USE_WIFI_WPA2_EAP) && ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
797 ESP_LOGV(TAG,
" TTLS Phase 2: " LOG_SECRET(
"'%s'"), eap_phase2_to_str(eap_config.
ttls_phase_2));
799 bool ca_cert_present = eap_config.
ca_cert !=
nullptr && strlen(eap_config.
ca_cert);
802 ESP_LOGV(TAG,
" CA Cert: %s", ca_cert_present ?
"present" :
"not present");
803 ESP_LOGV(TAG,
" Client Cert: %s", client_cert_present ?
"present" :
"not present");
804 ESP_LOGV(TAG,
" Client Key: %s", client_key_present ?
"present" :
"not present");
807 ESP_LOGV(TAG,
" Password: " LOG_SECRET(
"'%s'"), ap.
get_password().c_str());
808#ifdef USE_WIFI_WPA2_EAP
814 ESP_LOGV(TAG,
" Channel not set");
816#ifdef USE_WIFI_MANUAL_IP
819 ESP_LOGV(TAG,
" Manual IP: Static IP=%s Gateway=%s Subnet=%s DNS1=%s DNS2=%s",
m.static_ip.str().c_str(),
820 m.gateway.str().c_str(),
m.subnet.str().c_str(),
m.dns1.str().c_str(),
m.dns2.str().c_str());
824 ESP_LOGV(TAG,
" Using DHCP IP");
826 ESP_LOGV(TAG,
" Hidden: %s", YESNO(ap.
get_hidden()));
830 ESP_LOGE(TAG,
"wifi_sta_connect_ failed");
842 if (rssi == WIFI_RSSI_DISCONNECTED) {
845 return LOG_STR(
"\033[0;31m"
846 "\xc3\x97\xc3\x97\xc3\x97\xc3\x97"
858 return LOG_STR(
"\033[0;32m"
864 }
else if (rssi >= -65) {
865 return LOG_STR(
"\033[0;33m"
872 }
else if (rssi >= -85) {
873 return LOG_STR(
"\033[0;33m"
881 return LOG_STR(
"\033[0;31m"
899 ESP_LOGCONFIG(TAG,
" Disabled");
903 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
906 ESP_LOGCONFIG(TAG,
" IP Address: %s", ip.str_to(ip_buf));
911 char ssid_buf[SSID_BUFFER_SIZE];
912 char subnet_buf[network::IP_ADDRESS_BUFFER_SIZE];
913 char gateway_buf[network::IP_ADDRESS_BUFFER_SIZE];
914 char dns1_buf[network::IP_ADDRESS_BUFFER_SIZE];
915 char dns2_buf[network::IP_ADDRESS_BUFFER_SIZE];
917 " SSID: " LOG_SECRET(
"'%s'")
"\n"
918 " BSSID: " LOG_SECRET(
"%s")
"\n"
920 " Signal strength: %d dB %s\n"
921 " Channel: %" PRId32
"\n"
929#ifdef ESPHOME_LOG_HAS_VERBOSE
931 ESP_LOGV(TAG,
" Priority: %d", this->
get_sta_priority(config->get_bssid()));
934#ifdef USE_WIFI_11KV_SUPPORT
938 this->
btm_ ?
"enabled" :
"disabled", this->
rrm_ ?
"enabled" :
"disabled");
946 ESP_LOGD(TAG,
"Enabling");
956 ESP_LOGD(TAG,
"Disabling");
966 ESP_LOGD(TAG,
"Starting scan");
1025template<
typename VectorType>
static void insertion_sort_scan_results(VectorType &results) {
1026 const size_t size = results.size();
1027 for (
size_t i = 1; i < size; i++) {
1029 WiFiScanResult key = results[i];
1034 while (j >= 0 && wifi_scan_result_is_better(key, results[j])) {
1035 results[j + 1] = results[j];
1038 results[j + 1] = key;
1048 ESP_LOGI(TAG,
"- '%s' %s" LOG_SECRET(
"(%s) ")
"%s", res.
get_ssid().c_str(),
1049 res.
get_is_hidden() ? LOG_STR_LITERAL(
"(HIDDEN) ") : LOG_STR_LITERAL(
""), bssid_s,
1054#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
1056__attribute__((noinline))
static void log_scan_result_non_matching(
const WiFiScanResult &res) {
1058 auto bssid = res.get_bssid();
1061 ESP_LOGV(TAG,
"- " LOG_SECRET(
"'%s'")
" " LOG_SECRET(
"(%s) ")
"%s", res.get_ssid().c_str(), bssid_s,
1069 ESP_LOGE(TAG,
"Scan timeout");
1078 ESP_LOGW(TAG,
"No networks found");
1083 ESP_LOGD(TAG,
"Found networks:");
1085 for (
auto &ap : this->
sta_) {
1086 if (res.matches(ap)) {
1087 res.set_matches(
true);
1089 const bssid_t &bssid = res.get_bssid();
1100 insertion_sort_scan_results(this->scan_result_);
1102 size_t non_matching_count = 0;
1103 for (
auto &res : this->scan_result_) {
1104 if (res.get_matches()) {
1105 log_scan_result(res);
1107#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
1108 log_scan_result_non_matching(res);
1110 non_matching_count++;
1114 if (non_matching_count > 0) {
1115 ESP_LOGD(TAG,
"- %zu non-matching (VERBOSE to show)", non_matching_count);
1123 bool found_match =
false;
1125 for (
size_t i = 0; i < this->
sta_.size(); i++) {
1126 if (scan_res.
matches(this->sta_[i])) {
1137 ESP_LOGW(TAG,
"No matching network found");
1171 ESP_LOGW(TAG,
"Connection incomplete");
1176 ESP_LOGI(TAG,
"Connected");
1182 ESP_LOGW(TAG, LOG_SECRET(
"'%s'")
" should be marked hidden", config->get_ssid().c_str());
1195#ifdef USE_CAPTIVE_PORTAL
1200 ESP_LOGD(TAG,
"Disabling AP");
1215#ifdef USE_WIFI_FAST_CONNECT
1230 ESP_LOGW(TAG,
"Connection timeout, aborting connection attempt");
1237 ESP_LOGW(TAG,
"Connecting to network failed (callback)");
1247 ESP_LOGW(TAG,
"Network no longer found");
1253 ESP_LOGW(TAG,
"Connecting to network failed");
1258 ESP_LOGW(TAG,
"Unknown connection status %d", (
int)
status);
1271#ifdef USE_WIFI_FAST_CONNECT
1280 if (!this->
sta_.empty() && this->sta_[0].get_hidden()) {
1288 if (this->
num_retried_ + 1 < WIFI_RETRY_COUNT_PER_SSID) {
1295 if (next_index < this->
sta_.size() && this->sta_[next_index].get_hidden()) {
1311 if (this->
scan_result_.empty() || !this->scan_result_[0].get_matches()) {
1315 if (this->
num_retried_ + 1 < WIFI_RETRY_COUNT_PER_BSSID) {
1334 if (this->
num_retried_ + 1 < WIFI_RETRY_COUNT_PER_SSID) {
1384 if (old_phase == new_phase) {
1388 ESP_LOGD(TAG,
"Retry phase: %s → %s", LOG_STR_ARG(retry_phase_to_log_string(old_phase)),
1389 LOG_STR_ARG(retry_phase_to_log_string(new_phase)));
1395 switch (new_phase) {
1396#ifdef USE_WIFI_FAST_CONNECT
1411#ifdef USE_WIFI_FAST_CONNECT
1413 ESP_LOGI(TAG,
"Fast connect exhausted, falling back to scan");
1440 ESP_LOGD(TAG,
"All SSIDs visible or already tried, skipping hidden mode");
1484 if (first_priority != std::numeric_limits<int8_t>::min()) {
1489 if (pri.priority != first_priority) {
1495 ESP_LOGD(TAG,
"Clearing BSSID priorities (all at minimum)");
1496 this->sta_priorities_.clear();
1497 this->sta_priorities_.shrink_to_fit();
1527 failed_bssid = config->get_bssid();
1535 const std::string *ssid =
nullptr;
1539 ssid = &config->get_ssid();
1544 uint8_t max_retries = get_max_retries_for_phase(this->
retry_phase_);
1545 bool is_last_attempt = (this->
num_retried_ + 1 >= max_retries);
1549 int8_t new_priority = old_priority;
1551 if (is_last_attempt) {
1554 (old_priority > std::numeric_limits<int8_t>::min()) ? (old_priority - 1) : std::numeric_limits<int8_t>::min();
1559 ESP_LOGD(TAG,
"Failed " LOG_SECRET(
"'%s'")
" " LOG_SECRET(
"(%s)")
", priority %d → %d",
1560 ssid !=
nullptr ? ssid->c_str() :
"", bssid_s, old_priority, new_priority);
1581#ifdef USE_WIFI_FAST_CONNECT
1586 ESP_LOGD(TAG,
"Next AP in %s", LOG_STR_ARG(retry_phase_to_log_string(this->
retry_phase_)));
1595 if (next_index < this->
sta_.size() && this->sta_[next_index].get_hidden()) {
1598 ESP_LOGD(TAG,
"Next explicit hidden network at index %d",
static_cast<int>(next_index));
1610 if (next_index != -1) {
1630 ESP_LOGD(TAG,
"Retry attempt %u/%u in phase %s", this->
num_retried_ + 1,
1646 if (next_phase == current_phase) {
1683#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
1691#ifdef USE_CAPTIVE_PORTAL
1705#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
1737#ifdef USE_WIFI_FAST_CONNECT
1743 if (fast_connect_save.ap_index < 0 ||
static_cast<size_t>(fast_connect_save.ap_index) >= this->sta_.size()) {
1744 ESP_LOGW(TAG,
"AP index out of bounds");
1752 params = this->
sta_[fast_connect_save.ap_index];
1756 std::copy(fast_connect_save.bssid, fast_connect_save.bssid + 6, bssid.begin());
1762 ESP_LOGD(TAG,
"Loaded fast_connect settings");
1778 if (this->
fast_connect_pref_.
load(&previous_save) && memcmp(previous_save.bssid, bssid.data(), 6) == 0 &&
1779 previous_save.channel == channel && previous_save.ap_index == ap_index) {
1784 memcpy(fast_connect_save.bssid, bssid.data(), 6);
1785 fast_connect_save.channel = channel;
1786 fast_connect_save.ap_index = ap_index;
1790 ESP_LOGD(TAG,
"Saved fast_connect settings");
1798#ifdef USE_WIFI_WPA2_EAP
1803#ifdef USE_WIFI_MANUAL_IP
1811#ifdef USE_WIFI_WPA2_EAP
1816#ifdef USE_WIFI_MANUAL_IP
1826 ssid_(std::move(ssid)),
1827 with_auth_(with_auth),
1828 is_hidden_(is_hidden) {}
1835 }
else if (!config.
get_ssid().empty()) {
1837 if (config.
get_ssid() != this->ssid_)
1846#ifdef USE_WIFI_WPA2_EAP
bool is_name_add_mac_suffix_enabled() const
const std::string & get_name() const
Get the name of this Application set by pre_setup().
constexpr uint32_t get_config_version_hash()
Get the config hash extended with ESPHome version.
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
void status_set_warning(const char *message=nullptr)
void status_clear_warning()
virtual bool sync()=0
Commit pending writes to flash.
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
void trigger(const Ts &...x)
Inform the parent automation that the event has triggered.
value_type const & value() const
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< 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
void set_hidden(bool hidden)
const bssid_t & get_bssid() const
This component is responsible for managing the ESP WiFi interface.
bool is_captive_portal_active_()
bool did_scan_this_cycle_
bool error_from_callback_
void add_sta(const WiFiAP &ap)
bool load_fast_connect_settings_(WiFiAP ¶ms)
bool wifi_apply_power_save_()
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.
ESPPreferenceObject pref_
void set_sta(const WiFiAP &ap)
WiFiPowerSaveMode power_save_
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 init_sta(size_t count)
void check_connecting_finished()
void save_wifi_sta(const std::string &ssid, const std::string &password)
WiFiComponentState state_
wifi_scan_vector_t< WiFiScanResult > scan_result_
bool skip_cooldown_next_cycle_
WiFiPowerSaveMode configured_power_save_
void set_sta_priority(const bssid_t bssid, int8_t priority)
void print_connect_params_()
void loop() override
Reconnect WiFi if required.
void start_connecting(const WiFiAP &ap)
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 check_scanning_finished()
SemaphoreHandle_t high_performance_semaphore_
network::IPAddress get_dns_address(int num)
WiFiComponent()
Construct a WiFiComponent.
std::vector< WiFiSTAPriority > sta_priorities_
int8_t selected_sta_index_
void save_fast_connect_settings_()
bool wifi_start_ap_(const WiFiAP &ap)
int32_t get_wifi_channel()
const char * wifi_ssid_to(std::span< char, SSID_BUFFER_SIZE > buffer)
Write SSID to buffer without heap allocation.
network::IPAddress wifi_subnet_mask_()
network::IPAddress wifi_soft_ap_ip()
void set_passive_scan(bool passive)
network::IPAddress wifi_gateway_ip_()
void set_power_save_mode(WiFiPowerSaveMode power_save)
bool is_ap_active() const
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...
Trigger * connect_trigger_
ESPPreferenceObject fast_connect_pref_
void clear_priorities_if_all_min_()
Clear BSSID priority tracking if all priorities are at minimum (saves memory)
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
bool wifi_apply_hostname_()
bool wifi_sta_pre_setup_()
network::IPAddresses get_ip_addresses()
Trigger * disconnect_trigger_
float get_setup_priority() const override
WIFI setup_priority.
bool is_esp32_improv_active_()
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...
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 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...
WiFiRetryPhase retry_phase_
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),...
WiFiAP build_params_for_current_phase_()
bool is_high_performance_mode_
void dump_config() override
bool release_high_performance()
Release a high-performance mode request.
bool wifi_apply_output_power_(float output_power)
const char * get_use_address() const
WiFiSTAConnectStatus wifi_sta_connect_status_()
bool wifi_sta_connect_(const WiFiAP &ap)
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)
bool can_proceed() override
network::IPAddresses wifi_sta_ip_addresses()
void start_initial_connection_()
Start initial connection - either scan or connect directly to hidden networks.
bool wifi_scan_start_(bool passive)
bool handled_connected_state_
void setup() override
Setup WiFi interface.
void set_use_address(const char *use_address)
const std::string & get_ssid() const
int8_t get_priority() const
uint8_t get_channel() const
bool get_with_auth() 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_matches(bool matches)
bool get_is_hidden() const
bool operator==(const WiFiScanResult &rhs) const
struct @65::@66 __attribute__
CaptivePortal * global_captive_portal
ESP32ImprovComponent * global_improv_component
std::array< IPAddress, 5 > IPAddresses
std::array< uint8_t, 6 > bssid_t
const LogString * get_signal_bars(int8_t rssi)
@ ERROR_NETWORK_NOT_FOUND
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
@ 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.
void format_mac_addr_upper(const uint8_t *mac, char *output)
Format MAC address as XX:XX:XX:XX:XX:XX (uppercase, colon separators)
ESPPreferences * global_preferences
void IRAM_ATTR HOT yield()
const char * get_mac_address_pretty_into_buffer(std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf)
Get the device MAC address into the given buffer, in colon-separated uppercase hex notation.
uint32_t IRAM_ATTR HOT millis()
Application App
Global storage of Application pointer - only one Application can exist.
esp_eap_ttls_phase2_types ttls_phase_2
Struct for setting static IPs in WiFiComponent.