1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-19 16:25:50 +00:00
This commit is contained in:
J. Nick Koston
2025-11-06 12:02:18 -06:00
parent 2c110a9e7e
commit 60d6144574

View File

@@ -367,7 +367,11 @@ WiFiAP WiFiComponent::build_selected_ap_() const {
} }
// Overlay scan result data (if available) // Overlay scan result data (if available)
// Scan results are sorted, so index 0 is always the best network // SYNCHRONIZATION: selected_sta_index_ and scan_result_[0] are kept in sync:
// - 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_]
if (!this->scan_result_.empty()) { if (!this->scan_result_.empty()) {
const WiFiScanResult &scan = this->scan_result_[0]; const WiFiScanResult &scan = this->scan_result_[0];