mirror of
https://github.com/esphome/esphome.git
synced 2026-05-23 03:06:05 +08:00
[wifi] Fix roaming attempt counter reset on disconnect during scan (#15099)
This commit is contained in:
committed by
Jesse Hills
parent
e261b5de65
commit
f7b410fd0c
@@ -269,11 +269,11 @@ bool CompactString::operator==(const StringRef &other) const {
|
||||
/// │ │ │
|
||||
/// │ ┌──────────────┼──────────────┐ │
|
||||
/// │ ↓ ↓ ↓ │
|
||||
/// │ scan error no better AP +10 dB better AP │
|
||||
/// │ disconnect no better AP +10 dB better AP │
|
||||
/// │ │ │ │ │
|
||||
/// │ ↓ ↓ ↓ │
|
||||
/// │ ┌──────────────────────────────┐ ┌──────────────────────────┐ │
|
||||
/// │ │ → IDLE │ │ CONNECTING │ │
|
||||
/// │ │ → RECONNECTING │ │ CONNECTING │ │
|
||||
/// │ │ (counter preserved) │ │ (process_roaming_scan_) │ │
|
||||
/// │ └──────────────────────────────┘ └────────────┬─────────────┘ │
|
||||
/// │ │ │
|
||||
@@ -296,7 +296,7 @@ bool CompactString::operator==(const StringRef &other) const {
|
||||
/// │ Key behaviors: │
|
||||
/// │ - After 3 checks: attempts >= 3, stop checking │
|
||||
/// │ - Non-roaming disconnect: clear_roaming_state_() resets counter │
|
||||
/// │ - Scan error (SCANNING→IDLE): counter preserved │
|
||||
/// │ - Disconnect during scan (SCANNING→RECONNECTING): counter preserved │
|
||||
/// │ - Roaming success (CONNECTING→IDLE): counter reset (can roam again) │
|
||||
/// │ - Roaming fail (RECONNECTING→IDLE): counter preserved (ping-pong) │
|
||||
/// └──────────────────────────────────────────────────────────────────────┘
|
||||
@@ -2075,9 +2075,10 @@ void WiFiComponent::retry_connect() {
|
||||
ESP_LOGD(TAG, "Roam failed, reconnecting (attempt %u/%u)", this->roaming_attempts_, ROAMING_MAX_ATTEMPTS);
|
||||
this->roaming_state_ = RoamingState::RECONNECTING;
|
||||
} else if (this->roaming_state_ == RoamingState::SCANNING) {
|
||||
// Roam scan failed (e.g., scan error on ESP8266) - go back to idle, keep counter
|
||||
ESP_LOGD(TAG, "Roam scan failed (attempt %u/%u)", this->roaming_attempts_, ROAMING_MAX_ATTEMPTS);
|
||||
this->roaming_state_ = RoamingState::IDLE;
|
||||
// Disconnected during roam scan - transition to RECONNECTING so the attempts
|
||||
// counter is preserved when reconnection succeeds (IDLE would reset it)
|
||||
ESP_LOGD(TAG, "Disconnected during roam scan (attempt %u/%u)", this->roaming_attempts_, ROAMING_MAX_ATTEMPTS);
|
||||
this->roaming_state_ = RoamingState::RECONNECTING;
|
||||
} else if (this->roaming_state_ == RoamingState::IDLE) {
|
||||
// Not a roaming-triggered reconnect, reset state
|
||||
this->clear_roaming_state_();
|
||||
|
||||
Reference in New Issue
Block a user