From f3c9ab7cb463b66c4b7fd567f224b3f39315f8e1 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 6 Nov 2025 18:06:10 -0600 Subject: [PATCH] address final bot comments --- esphome/components/wifi/wifi_component.cpp | 9 +++++---- esphome/components/wifi/wifi_component.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index a47cba169a2..789c22bae10 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -350,11 +350,11 @@ WiFiAP WiFiComponent::build_wifi_ap_from_selected_() const { assert(config != nullptr); WiFiAP params = *config; - // SYNCHRONIZATION: selected_sta_index_ and scan_result_[0] are kept in sync: + // SYNCHRONIZATION: selected_sta_index_ and scan_result_[0] are kept in sync after wifi_scan_done(): // - wifi_scan_done() sorts all scan results by priority/RSSI (best first) // - It then finds which sta_[i] config matches scan_result_[0] // - Sets selected_sta_index_ = i to record that matching config - // Therefore scan_result_[0] is guaranteed to match sta_[selected_sta_index_] + // This sync holds until scan_result_ is cleared (e.g., after connection or in reset_for_next_ap_attempt_()) if (!this->scan_result_.empty()) { // Override with scan data - network is visible const WiFiScanResult &scan = this->scan_result_[0]; @@ -901,12 +901,13 @@ bool WiFiComponent::load_fast_connect_settings_(WiFiAP ¶ms) { // Copy entire config, then override with fast connect data params = this->sta_[fast_connect_save.ap_index]; - // Override with saved BSSID/channel from fast connect (SSID/password/hidden/etc already copied) + // Override with saved BSSID/channel from fast connect (SSID/password/etc already copied from config) bssid_t bssid{}; std::copy(fast_connect_save.bssid, fast_connect_save.bssid + 6, bssid.begin()); params.set_bssid(bssid); params.set_channel(fast_connect_save.channel); - // Network was found before, so not hidden (already false in default-constructed WiFiAP) + // Fast connect uses specific BSSID+channel, not hidden network probe (even if config has hidden: true) + params.set_hidden(false); ESP_LOGD(TAG, "Loaded fast_connect settings"); return true; diff --git a/esphome/components/wifi/wifi_component.h b/esphome/components/wifi/wifi_component.h index 394f00fd57d..228894076e1 100644 --- a/esphome/components/wifi/wifi_component.h +++ b/esphome/components/wifi/wifi_component.h @@ -218,7 +218,7 @@ class WiFiComponent : public Component { WiFiComponent(); void set_sta(const WiFiAP &ap); - // Returns a copy of the currently selected AP configuration (88 bytes) + // Returns a copy of the currently selected AP configuration WiFiAP get_sta() const; void init_sta(size_t count); void add_sta(const WiFiAP &ap);