mirror of
https://github.com/esphome/esphome.git
synced 2025-11-18 07:45:56 +00:00
smarter
This commit is contained in:
@@ -1029,27 +1029,25 @@ WiFiRetryPhase WiFiComponent::determine_next_phase_() {
|
|||||||
// Exhausted retries on current BSSID (scan_result_[0])
|
// Exhausted retries on current BSSID (scan_result_[0])
|
||||||
// Its priority has been decreased, so on next scan it will be sorted lower
|
// Its priority has been decreased, so on next scan it will be sorted lower
|
||||||
// and we'll try the next best BSSID.
|
// and we'll try the next best BSSID.
|
||||||
// If we saw this network in scan results, we KNOW it's not hidden - skip hidden mode and rescan
|
// Always try hidden mode first - it will skip visible SSIDs and return to scanning
|
||||||
if (!this->scan_result_.empty() && this->scan_result_[0].get_matches()) {
|
|
||||||
return WiFiRetryPhase::SCAN_CONNECTING; // Rescan to try next BSSID
|
|
||||||
}
|
|
||||||
// Otherwise try hidden mode
|
|
||||||
return WiFiRetryPhase::SCAN_WITH_HIDDEN;
|
return WiFiRetryPhase::SCAN_WITH_HIDDEN;
|
||||||
|
|
||||||
case WiFiRetryPhase::SCAN_WITH_HIDDEN:
|
case WiFiRetryPhase::SCAN_WITH_HIDDEN:
|
||||||
if (this->num_retried_ + 1 < WIFI_RETRY_COUNT_PER_SSID) {
|
// If no hidden SSIDs to try (selected_sta_index_ == -1), skip directly to rescan
|
||||||
return WiFiRetryPhase::SCAN_WITH_HIDDEN; // Keep retrying same SSID
|
if (this->selected_sta_index_ >= 0) {
|
||||||
}
|
if (this->num_retried_ + 1 < WIFI_RETRY_COUNT_PER_SSID) {
|
||||||
|
return WiFiRetryPhase::SCAN_WITH_HIDDEN; // Keep retrying same SSID
|
||||||
|
}
|
||||||
|
|
||||||
// Exhausted retries on current SSID - check if there are more SSIDs to try
|
// Exhausted retries on current SSID - check if there are more potentially hidden SSIDs to try
|
||||||
if (this->selected_sta_index_ < static_cast<int8_t>(this->sta_.size()) - 1) {
|
if (this->selected_sta_index_ < static_cast<int8_t>(this->sta_.size()) - 1) {
|
||||||
// More SSIDs available - stay in SCAN_WITH_HIDDEN, advance will happen in retry_connect()
|
// More SSIDs available - stay in SCAN_WITH_HIDDEN, advance will happen in retry_connect()
|
||||||
return WiFiRetryPhase::SCAN_WITH_HIDDEN;
|
return WiFiRetryPhase::SCAN_WITH_HIDDEN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Exhausted all potentially hidden SSIDs - rescan to try next BSSID
|
||||||
// Exhausted all SSIDs - restart adapter and scan again
|
// If captive portal/improv is active, keep rescanning
|
||||||
// If captive portal/improv is active, loop back to scanning instead of restarting
|
// Otherwise restart adapter to clear any stuck state
|
||||||
// This keeps trying to connect in case WiFi comes back up
|
|
||||||
if (this->is_captive_portal_active_() || this->is_esp32_improv_active_()) {
|
if (this->is_captive_portal_active_() || this->is_esp32_improv_active_()) {
|
||||||
return WiFiRetryPhase::SCAN_CONNECTING;
|
return WiFiRetryPhase::SCAN_CONNECTING;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user