[wifi] Use shorter scan dwell time for ESP8266 roaming scans

Use 100-300ms dwell times for roaming scans instead of 400-500ms,
matching the ESP32 IDF scan times. This reduces total off-channel
time from ~6.5s to ~3.9s (13 channels), which reduces the chance
of triggering Beacon Timeout disconnects on aggressive APs.

The longer dwell times are preserved for initial connection scans
where a thorough survey is needed.
This commit is contained in:
J. Nick Koston
2026-03-23 12:40:27 -10:00
parent 332118db56
commit e140092569
@@ -664,11 +664,22 @@ bool WiFiComponent::wifi_scan_start_(bool passive) {
config.show_hidden = 1;
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
config.scan_type = passive ? WIFI_SCAN_TYPE_PASSIVE : WIFI_SCAN_TYPE_ACTIVE;
// Use shorter dwell times for roaming scans - we only need to detect strong
// nearby APs, not do a thorough survey. This also reduces off-channel time
// which can cause Beacon Timeout disconnects on some APs.
// Roaming times match the ESP32 IDF scan defaults.
static constexpr uint32_t SCAN_PASSIVE_DEFAULT = 500;
static constexpr uint32_t SCAN_PASSIVE_ROAMING = 300;
static constexpr uint32_t SCAN_ACTIVE_MIN_DEFAULT = 400;
static constexpr uint32_t SCAN_ACTIVE_MAX_DEFAULT = 500;
static constexpr uint32_t SCAN_ACTIVE_MIN_ROAMING = 100;
static constexpr uint32_t SCAN_ACTIVE_MAX_ROAMING = 300;
bool roaming = this->roaming_state_ == RoamingState::SCANNING;
if (passive) {
config.scan_time.passive = 500;
config.scan_time.passive = roaming ? SCAN_PASSIVE_ROAMING : SCAN_PASSIVE_DEFAULT;
} else {
config.scan_time.active.min = 400;
config.scan_time.active.max = 500;
config.scan_time.active.min = roaming ? SCAN_ACTIVE_MIN_ROAMING : SCAN_ACTIVE_MIN_DEFAULT;
config.scan_time.active.max = roaming ? SCAN_ACTIVE_MAX_ROAMING : SCAN_ACTIVE_MAX_DEFAULT;
}
#endif
bool ret = wifi_station_scan(&config, &WiFiComponent::s_wifi_scan_done_callback);