1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-15 06:15:47 +00:00

only need to check next

This commit is contained in:
J. Nick Koston
2025-11-09 19:39:07 -06:00
parent 4e6627a4f5
commit cb98263d34
2 changed files with 12 additions and 4 deletions

View File

@@ -151,6 +151,12 @@ static const LogString *retry_phase_to_log_string(WiFiRetryPhase phase) {
}
}
bool WiFiComponent::went_through_explicit_hidden_phase_() const {
// If first configured network is marked hidden, we went through EXPLICIT_HIDDEN phase
// This means those networks were already tried and should be skipped in RETRY_HIDDEN
return !this->sta_.empty() && this->sta_[0].get_hidden();
}
// 2 attempts per BSSID in SCAN_CONNECTING phase
// Rationale: This is the ONLY phase where we decrease BSSID priority, so we must be very sure.
// Auth failures are common immediately after scan due to WiFi stack state transitions.
@@ -1217,8 +1223,7 @@ bool WiFiComponent::transition_to_phase_(WiFiRetryPhase new_phase) {
// If first network is marked hidden, we went through EXPLICIT_HIDDEN phase
// In that case, skip networks marked hidden:true (already tried)
// Otherwise, include them (they haven't been tried yet)
bool went_through_explicit_hidden = !this->sta_.empty() && this->sta_[0].get_hidden();
this->selected_sta_index_ = this->find_next_hidden_sta_(-1, !went_through_explicit_hidden);
this->selected_sta_index_ = this->find_next_hidden_sta_(-1, !this->went_through_explicit_hidden_phase_());
if (this->selected_sta_index_ == -1) {
ESP_LOGD(TAG, "All SSIDs visible or already tried, skipping hidden mode");
@@ -1326,8 +1331,8 @@ void WiFiComponent::advance_to_next_target_or_increment_retry_() {
// If first network is marked hidden, we went through EXPLICIT_HIDDEN phase
// In that case, skip networks marked hidden:true (already tried)
// Otherwise, include them (they haven't been tried yet)
bool went_through_explicit_hidden = !this->sta_.empty() && this->sta_[0].get_hidden();
int8_t next_index = this->find_next_hidden_sta_(this->selected_sta_index_, !went_through_explicit_hidden);
int8_t next_index =
this->find_next_hidden_sta_(this->selected_sta_index_, !this->went_through_explicit_hidden_phase_());
if (next_index != -1) {
// Found another potentially hidden SSID
this->selected_sta_index_ = next_index;

View File

@@ -369,6 +369,9 @@ class WiFiComponent : public Component {
/// Check if we need valid scan results for the current phase but don't have any
/// Returns true if the phase requires scan results but they're missing or don't match
bool needs_scan_results_() const;
/// Check if we went through EXPLICIT_HIDDEN phase (first network is marked hidden)
/// Used in RETRY_HIDDEN to determine whether to skip explicitly hidden networks
bool went_through_explicit_hidden_phase_() const;
/// Check if an SSID was seen in the most recent scan results
/// Used to skip hidden mode for SSIDs we know are visible
bool ssid_was_seen_in_scan_(const std::string &ssid) const;