mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 23:37:34 +00:00
[wifi] Review fixes: clear grace period on reconnect, log BSSID, fix layout
- Clear roaming_scan_end_ on successful reconnect to prevent grace period from incorrectly applying to a second disconnect - Log target BSSID in "Roam successful (via retry)" message - Move bssid_t roaming_target_bssid_ to 1-byte section to avoid 2 bytes struct padding before ap_timeout_
This commit is contained in:
@@ -1591,7 +1591,9 @@ void WiFiComponent::check_connecting_finished(uint32_t now) {
|
||||
// (e.g., first connect failed but scan-based retry found and connected to the same better AP)
|
||||
bssid_t current_bssid = this->wifi_bssid();
|
||||
if (this->roaming_target_bssid_ != bssid_t{} && current_bssid == this->roaming_target_bssid_) {
|
||||
ESP_LOGD(TAG, "Roam successful (via retry)");
|
||||
char bssid_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
|
||||
format_mac_addr_upper(current_bssid.data(), bssid_buf);
|
||||
ESP_LOGD(TAG, "Roam successful (via retry) to %s", bssid_buf);
|
||||
this->roaming_attempts_ = 0;
|
||||
} else {
|
||||
// Failed roam, reconnected to different AP - keep attempts to prevent ping-pong
|
||||
@@ -1603,6 +1605,7 @@ void WiFiComponent::check_connecting_finished(uint32_t now) {
|
||||
}
|
||||
this->roaming_state_ = RoamingState::IDLE;
|
||||
this->roaming_target_bssid_ = {};
|
||||
this->roaming_scan_end_ = 0;
|
||||
|
||||
// Clear all priority penalties - the next reconnect will happen when an AP disconnects,
|
||||
// which means the landscape has likely changed and previous tracked failures are stale
|
||||
|
||||
@@ -790,8 +790,7 @@ class WiFiComponent final : public Component {
|
||||
uint32_t last_connected_{0};
|
||||
uint32_t reboot_timeout_{};
|
||||
uint32_t roaming_last_check_{0};
|
||||
uint32_t roaming_scan_end_{0}; // Timestamp when last roaming scan completed
|
||||
bssid_t roaming_target_bssid_{}; // BSSID of the AP we're trying to roam to
|
||||
uint32_t roaming_scan_end_{0}; // Timestamp when last roaming scan completed
|
||||
#ifdef USE_WIFI_AP
|
||||
uint32_t ap_timeout_{};
|
||||
#endif
|
||||
@@ -816,6 +815,7 @@ class WiFiComponent final : public Component {
|
||||
bool error_from_callback_{false};
|
||||
RetryHiddenMode retry_hidden_mode_{RetryHiddenMode::BLIND_RETRY};
|
||||
RoamingState roaming_state_{RoamingState::IDLE};
|
||||
bssid_t roaming_target_bssid_{}; // BSSID of the AP we're trying to roam to
|
||||
#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
|
||||
WiFiPowerSaveMode configured_power_save_{WIFI_POWER_SAVE_NONE};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user