7#if (ESP_IDF_VERSION_MAJOR >= 5 && ESP_IDF_VERSION_MINOR >= 1)
8#include <esp_eap_client.h>
18#include <user_interface.h>
32#ifdef USE_CAPTIVE_PORTAL
42static const char *
const TAG =
"wifi";
146static const LogString *retry_phase_to_log_string(
WiFiRetryPhase phase) {
149 return LOG_STR(
"INITIAL_CONNECT");
150#ifdef USE_WIFI_FAST_CONNECT
152 return LOG_STR(
"FAST_CONNECT_CYCLING");
155 return LOG_STR(
"EXPLICIT_HIDDEN");
157 return LOG_STR(
"SCAN_CONNECTING");
159 return LOG_STR(
"RETRY_HIDDEN");
161 return LOG_STR(
"RESTARTING");
163 return LOG_STR(
"UNKNOWN");
170 return !this->
sta_.empty() && this->
sta_[0].get_hidden();
176 for (
size_t i = 0; i < this->
sta_.size(); i++) {
177 if (!this->
sta_[i].get_hidden()) {
178 return static_cast<int8_t
>(i);
189static constexpr uint8_t WIFI_RETRY_COUNT_PER_BSSID = 2;
193static constexpr uint8_t WIFI_RETRY_COUNT_PER_SSID = 1;
197static constexpr uint8_t WIFI_RETRY_COUNT_PER_AP = 1;
201static constexpr uint32_t WIFI_COOLDOWN_DURATION_MS = 500;
206static constexpr uint32_t WIFI_COOLDOWN_WITH_AP_ACTIVE_MS = 30000;
211static constexpr uint32_t WIFI_SCAN_TIMEOUT_MS = 31000;
221static constexpr uint32_t WIFI_CONNECT_TIMEOUT_MS = 46000;
223static constexpr uint8_t get_max_retries_for_phase(
WiFiRetryPhase phase) {
226#ifdef USE_WIFI_FAST_CONNECT
230 return WIFI_RETRY_COUNT_PER_AP;
233 return WIFI_RETRY_COUNT_PER_SSID;
236 return WIFI_RETRY_COUNT_PER_BSSID;
239 return WIFI_RETRY_COUNT_PER_SSID;
241 return WIFI_RETRY_COUNT_PER_BSSID;
245static void apply_scan_result_to_params(WiFiAP ¶ms,
const WiFiScanResult &scan) {
246 params.set_hidden(
false);
247 params.set_ssid(scan.get_ssid());
248 params.set_bssid(scan.get_bssid());
249 params.set_channel(scan.get_channel());
264 for (
const auto &conf : this->
sta_) {
265 if (conf.get_ssid() == ssid && conf.get_hidden()) {
272 if (scan.get_ssid() == ssid) {
283 for (
size_t i = start_index + 1; i < this->
sta_.size(); i++) {
284 const auto &sta = this->
sta_[i];
289 if (!include_explicit_hidden && sta.get_hidden()) {
291 if (first_non_hidden_idx < 0 ||
static_cast<int8_t
>(i) < first_non_hidden_idx) {
292 ESP_LOGD(TAG,
"Skipping " LOG_SECRET(
"'%s'")
" (explicit hidden, already tried)", sta.get_ssid().c_str());
300 ESP_LOGD(TAG,
"Hidden candidate " LOG_SECRET(
"'%s'")
" at index %d", sta.get_ssid().c_str(),
static_cast<int>(i));
301 return static_cast<int8_t
>(i);
303 ESP_LOGD(TAG,
"Skipping hidden retry for visible network " LOG_SECRET(
"'%s'"), sta.get_ssid().c_str());
312 if (!this->
sta_.empty() && this->sta_[0].get_hidden()) {
313 ESP_LOGI(TAG,
"Starting with explicit hidden network (highest priority)");
319 ESP_LOGI(TAG,
"Starting scan");
324#if defined(USE_ESP32) && defined(USE_WIFI_WPA2_EAP) && ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
325static const char *eap_phase2_to_str(esp_eap_ttls_phase2_types
type) {
327 case ESP_EAP_TTLS_PHASE2_PAP:
329 case ESP_EAP_TTLS_PHASE2_CHAP:
331 case ESP_EAP_TTLS_PHASE2_MSCHAP:
333 case ESP_EAP_TTLS_PHASE2_MSCHAPV2:
335 case ESP_EAP_TTLS_PHASE2_EAP:
348#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
353 ESP_LOGE(TAG,
"Failed semaphore");
381#ifdef USE_WIFI_FAST_CONNECT
387 ESP_LOGD(TAG,
"Loaded settings: %s", save.ssid);
391 sta.set_password(save.password);
398 ESP_LOGV(TAG,
"Setting Output Power Option failed");
401#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
405 if (semaphore_count > 0) {
415 ESP_LOGV(TAG,
"Setting Power Save Option failed");
419#ifdef USE_WIFI_FAST_CONNECT
424 if (loaded_fast_connect) {
425 ESP_LOGI(TAG,
"Starting fast_connect (saved) " LOG_SECRET(
"'%s'"), params.
get_ssid().c_str());
427 }
else if (!this->
sta_.empty() && !this->sta_[0].get_hidden()) {
429 ESP_LOGI(TAG,
"Starting fast_connect (config) " LOG_SECRET(
"'%s'"), this->
sta_[0].get_ssid().c_str());
442 }
else if (this->
has_ap()) {
445 ESP_LOGV(TAG,
"Setting Output Power Option failed");
447#ifdef USE_CAPTIVE_PORTAL
466 ESP_LOGW(TAG,
"Restarting adapter");
496 uint32_t cooldown_duration = portal_active ? WIFI_COOLDOWN_WITH_AP_ACTIVE_MS : WIFI_COOLDOWN_DURATION_MS;
519 ESP_LOGW(TAG,
"Connection lost; reconnecting");
540 ESP_LOGI(TAG,
"Starting fallback AP");
542#ifdef USE_CAPTIVE_PORTAL
563 ESP_LOGE(TAG,
"Can't connect; rebooting");
569#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
577 ESP_LOGV(TAG,
"Switching to high-performance mode (%" PRIu32
" active %s)", (uint32_t) semaphore_count,
578 semaphore_count == 1 ?
"request" :
"requests");
585 ESP_LOGV(TAG,
"Restoring power save mode to configured setting");
600#ifdef USE_WIFI_11KV_SUPPORT
634 if (name.length() > 32) {
637 name.erase(25, name.length() - 32);
650 " AP Password: '%s'\n"
652 this->
ap_.
get_ssid().c_str(), this->ap_.get_password().c_str(), ip_address.c_str());
654#ifdef USE_WIFI_MANUAL_IP
656 if (manual_ip.has_value()) {
658 " AP Static IP: '%s'\n"
659 " AP Gateway: '%s'\n"
661 manual_ip->static_ip.str().c_str(), manual_ip->gateway.str().c_str(),
662 manual_ip->subnet.str().c_str());
694 if (config ==
nullptr) {
695 ESP_LOGE(TAG,
"No valid network config (selected_sta_index_=%d, sta_.size()=%zu)",
705#ifdef USE_WIFI_FAST_CONNECT
723 apply_scan_result_to_params(params, this->
scan_result_[0]);
737 return config ? *config :
WiFiAP{};
741 strncpy(save.ssid, ssid.c_str(),
sizeof(save.ssid) - 1);
742 strncpy(save.password, password.c_str(),
sizeof(save.password) - 1);
749 sta.set_password(password);
759 ESP_LOGD(TAG,
"Exiting cooldown early due to new WiFi credentials");
775 "Connecting to " LOG_SECRET(
"'%s'")
" " LOG_SECRET(
"(%s)")
" (priority %d, attempt %u/%u in phase %s)...",
778 LOG_STR_ARG(retry_phase_to_log_string(this->
retry_phase_)));
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");
904 ESP_LOGCONFIG(TAG,
" IP Address: %s", ip.str().c_str());
909 " SSID: " LOG_SECRET(
"'%s'")
"\n"
910 " BSSID: " LOG_SECRET(
"%s")
"\n"
912 " Signal strength: %d dB %s\n"
913 " Channel: %" PRId32
"\n"
921#ifdef ESPHOME_LOG_HAS_VERBOSE
923 ESP_LOGV(TAG,
" Priority: %d", this->
get_sta_priority(*config->get_bssid()));
926#ifdef USE_WIFI_11KV_SUPPORT
930 this->
btm_ ?
"enabled" :
"disabled", this->
rrm_ ?
"enabled" :
"disabled");
938 ESP_LOGD(TAG,
"Enabling");
948 ESP_LOGD(TAG,
"Disabling");
958 ESP_LOGD(TAG,
"Starting scan");
1017template<
typename VectorType>
static void insertion_sort_scan_results(VectorType &results) {
1018 const size_t size = results.size();
1019 for (
size_t i = 1; i < size; i++) {
1021 WiFiScanResult key = results[i];
1026 while (j >= 0 && wifi_scan_result_is_better(key, results[j])) {
1027 results[j + 1] = results[j];
1030 results[j + 1] = key;
1041 ESP_LOGI(TAG,
"- '%s' %s" LOG_SECRET(
"(%s) ")
"%s", res.
get_ssid().c_str(),
1042 res.
get_is_hidden() ? LOG_STR_LITERAL(
"(HIDDEN) ") : LOG_STR_LITERAL(
""), bssid_s,
1046 ESP_LOGD(TAG,
"- " LOG_SECRET(
"'%s'")
" " LOG_SECRET(
"(%s) ")
"%s", res.
get_ssid().c_str(), bssid_s,
1054 ESP_LOGE(TAG,
"Scan timeout");
1063 ESP_LOGW(TAG,
"No networks found");
1068 ESP_LOGD(TAG,
"Found networks:");
1070 for (
auto &ap : this->
sta_) {
1071 if (res.matches(ap)) {
1072 res.set_matches(
true);
1074 const bssid_t &bssid = res.get_bssid();
1085 insertion_sort_scan_results(this->scan_result_);
1087 for (
auto &res : this->scan_result_) {
1088 log_scan_result(res);
1096 bool found_match =
false;
1098 for (
size_t i = 0; i < this->
sta_.size(); i++) {
1099 if (scan_res.
matches(this->sta_[i])) {
1110 ESP_LOGW(TAG,
"No matching network found");
1144 ESP_LOGW(TAG,
"Connection incomplete");
1149 ESP_LOGI(TAG,
"Connected");
1155 ESP_LOGW(TAG, LOG_SECRET(
"'%s'")
" should be marked hidden", config->get_ssid().c_str());
1168#ifdef USE_CAPTIVE_PORTAL
1173 ESP_LOGD(TAG,
"Disabling AP");
1188#ifdef USE_WIFI_FAST_CONNECT
1203 ESP_LOGW(TAG,
"Connection timeout, aborting connection attempt");
1210 ESP_LOGW(TAG,
"Connecting to network failed (callback)");
1220 ESP_LOGW(TAG,
"Network no longer found");
1226 ESP_LOGW(TAG,
"Connecting to network failed");
1231 ESP_LOGW(TAG,
"Unknown connection status %d", (
int)
status);
1244#ifdef USE_WIFI_FAST_CONNECT
1253 if (!this->
sta_.empty() && this->sta_[0].get_hidden()) {
1261 if (this->
num_retried_ + 1 < WIFI_RETRY_COUNT_PER_SSID) {
1268 if (next_index < this->
sta_.size() && this->sta_[next_index].get_hidden()) {
1284 if (this->
scan_result_.empty() || !this->scan_result_[0].get_matches()) {
1288 if (this->
num_retried_ + 1 < WIFI_RETRY_COUNT_PER_BSSID) {
1307 if (this->
num_retried_ + 1 < WIFI_RETRY_COUNT_PER_SSID) {
1357 if (old_phase == new_phase) {
1361 ESP_LOGD(TAG,
"Retry phase: %s → %s", LOG_STR_ARG(retry_phase_to_log_string(old_phase)),
1362 LOG_STR_ARG(retry_phase_to_log_string(new_phase)));
1368 switch (new_phase) {
1369#ifdef USE_WIFI_FAST_CONNECT
1384#ifdef USE_WIFI_FAST_CONNECT
1386 ESP_LOGI(TAG,
"Fast connect exhausted, falling back to scan");
1413 ESP_LOGD(TAG,
"All SSIDs visible or already tried, skipping hidden mode");
1457 if (first_priority != std::numeric_limits<int8_t>::min()) {
1462 if (pri.priority != first_priority) {
1468 ESP_LOGD(TAG,
"Clearing BSSID priorities (all at minimum)");
1469 this->sta_priorities_.clear();
1470 this->sta_priorities_.shrink_to_fit();
1500 failed_bssid = *config->get_bssid();
1512 ssid = config->get_ssid();
1517 uint8_t max_retries = get_max_retries_for_phase(this->
retry_phase_);
1518 bool is_last_attempt = (this->
num_retried_ + 1 >= max_retries);
1522 int8_t new_priority = old_priority;
1524 if (is_last_attempt) {
1527 (old_priority > std::numeric_limits<int8_t>::min()) ? (old_priority - 1) : std::numeric_limits<int8_t>::min();
1532 ESP_LOGD(TAG,
"Failed " LOG_SECRET(
"'%s'")
" " LOG_SECRET(
"(%s)")
", priority %d → %d", ssid.c_str(), bssid_s,
1533 old_priority, new_priority);
1554#ifdef USE_WIFI_FAST_CONNECT
1559 ESP_LOGD(TAG,
"Next AP in %s", LOG_STR_ARG(retry_phase_to_log_string(this->
retry_phase_)));
1568 if (next_index < this->
sta_.size() && this->sta_[next_index].get_hidden()) {
1571 ESP_LOGD(TAG,
"Next explicit hidden network at index %d",
static_cast<int>(next_index));
1583 if (next_index != -1) {
1603 ESP_LOGD(TAG,
"Retry attempt %u/%u in phase %s", this->
num_retried_ + 1,
1619 if (next_phase == current_phase) {
1656#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
1664#ifdef USE_CAPTIVE_PORTAL
1678#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
1710#ifdef USE_WIFI_FAST_CONNECT
1716 if (fast_connect_save.ap_index < 0 ||
static_cast<size_t>(fast_connect_save.ap_index) >= this->sta_.size()) {
1717 ESP_LOGW(TAG,
"AP index out of bounds");
1725 params = this->
sta_[fast_connect_save.ap_index];
1729 std::copy(fast_connect_save.bssid, fast_connect_save.bssid + 6, bssid.begin());
1735 ESP_LOGD(TAG,
"Loaded fast_connect settings");
1751 if (this->
fast_connect_pref_.
load(&previous_save) && memcmp(previous_save.bssid, bssid.data(), 6) == 0 &&
1752 previous_save.channel == channel && previous_save.ap_index == ap_index) {
1757 memcpy(fast_connect_save.bssid, bssid.data(), 6);
1758 fast_connect_save.channel = channel;
1759 fast_connect_save.ap_index = ap_index;
1763 ESP_LOGD(TAG,
"Saved fast_connect settings");
1771#ifdef USE_WIFI_WPA2_EAP
1775#ifdef USE_WIFI_MANUAL_IP
1782#ifdef USE_WIFI_WPA2_EAP
1786#ifdef USE_WIFI_MANUAL_IP
1796 ssid_(std::move(ssid)),
1797 with_auth_(with_auth),
1798 is_hidden_(is_hidden) {}
1805 }
else if (!config.
get_ssid().empty()) {
1807 if (config.
get_ssid() != this->ssid_)
1816#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().
StringRef get_compilation_time_ref() const
Get the compilation time as StringRef (for API usage)
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
constexpr const char * c_str() const
void trigger(const Ts &...x)
Inform the parent automation that the event has triggered.
value_type const & value() const
const optional< bssid_t > & get_bssid() const
const std::string & get_ssid() const
void set_ssid(const std::string &ssid)
const optional< uint8_t > & get_channel() const
const optional< EAPAuth > & get_eap() const
void set_channel(optional< uint8_t > channel)
const std::string & get_password() const
void set_bssid(bssid_t bssid)
optional< uint8_t > channel_
optional< bssid_t > bssid_
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)
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()
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
optional< float > output_power_
bool release_high_performance()
Release a high-performance mode request.
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)
ESPPreferences * global_preferences
uint32_t fnv1_hash(const char *str)
Calculate a FNV-1 hash of str.
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.