diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index 9a9269b69a..9d2557f56f 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -427,6 +427,11 @@ bool WiFiComponent::matches_configured_network_(const char *ssid, const uint8_t void WiFiComponent::log_discarded_scan_result(const char *ssid, const uint8_t *bssid, int8_t rssi, uint8_t channel) { #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE + // Skip logging during roaming scans to avoid log buffer overflow + // (roaming scans typically find many networks but only care about same-SSID APs) + if (this->roaming_state_ == RoamingState::SCANNING) { + return; + } char bssid_s[MAC_ADDRESS_PRETTY_BUFFER_SIZE]; format_mac_addr_upper(bssid, bssid_s); ESP_LOGV(TAG, "- " LOG_SECRET("'%s'") " " LOG_SECRET("(%s)") " %ddB Ch:%u", ssid, bssid_s, rssi, channel); diff --git a/esphome/components/wifi/wifi_component.h b/esphome/components/wifi/wifi_component.h index 2086cdaebe..7bb13b457f 100644 --- a/esphome/components/wifi/wifi_component.h +++ b/esphome/components/wifi/wifi_component.h @@ -547,8 +547,8 @@ class WiFiComponent : public Component { /// Check if network matches any configured network (for scan result filtering) /// Matches by SSID when configured, or by BSSID for BSSID-only configs bool matches_configured_network_(const char *ssid, const uint8_t *bssid) const; - /// Log a discarded scan result at VERBOSE level - static void log_discarded_scan_result(const char *ssid, const uint8_t *bssid, int8_t rssi, uint8_t channel); + /// Log a discarded scan result at VERBOSE level (skipped during roaming scans to avoid log overflow) + void log_discarded_scan_result(const char *ssid, const uint8_t *bssid, int8_t rssi, uint8_t channel); /// Find next SSID that wasn't in scan results (might be hidden) /// Returns index of next potentially hidden SSID, or -1 if none found /// @param start_index Start searching from index after this (-1 to start from beginning) diff --git a/esphome/components/wifi/wifi_component_esp8266.cpp b/esphome/components/wifi/wifi_component_esp8266.cpp index 2ac1bd4a27..bb9a1a1c4d 100644 --- a/esphome/components/wifi/wifi_component_esp8266.cpp +++ b/esphome/components/wifi/wifi_component_esp8266.cpp @@ -780,7 +780,7 @@ void WiFiComponent::wifi_scan_done_callback_(void *arg, STATUS status) { bssid_t{it->bssid[0], it->bssid[1], it->bssid[2], it->bssid[3], it->bssid[4], it->bssid[5]}, std::string(ssid_cstr, it->ssid_len), it->channel, it->rssi, it->authmode != AUTH_OPEN, it->is_hidden != 0); } else { - WiFiComponent::log_discarded_scan_result(ssid_cstr, it->bssid, it->rssi, it->channel); + this->log_discarded_scan_result(ssid_cstr, it->bssid, it->rssi, it->channel); } } ESP_LOGV(TAG, "Scan complete: %zu found, %zu stored%s", total, this->scan_result_.size(), diff --git a/esphome/components/wifi/wifi_component_esp_idf.cpp b/esphome/components/wifi/wifi_component_esp_idf.cpp index 0eeecab503..a199eb14c7 100644 --- a/esphome/components/wifi/wifi_component_esp_idf.cpp +++ b/esphome/components/wifi/wifi_component_esp_idf.cpp @@ -857,7 +857,7 @@ void WiFiComponent::wifi_process_event_(IDFWiFiEvent *data) { this->scan_result_.emplace_back(bssid, std::move(ssid), record.primary, record.rssi, record.authmode != WIFI_AUTH_OPEN, ssid_cstr[0] == '\0'); } else { - WiFiComponent::log_discarded_scan_result(ssid_cstr, record.bssid, record.rssi, record.primary); + this->log_discarded_scan_result(ssid_cstr, record.bssid, record.rssi, record.primary); } } ESP_LOGV(TAG, "Scan complete: %u found, %zu stored%s", number, this->scan_result_.size(), diff --git a/esphome/components/wifi/wifi_component_libretiny.cpp b/esphome/components/wifi/wifi_component_libretiny.cpp index f287219d32..754d45687a 100644 --- a/esphome/components/wifi/wifi_component_libretiny.cpp +++ b/esphome/components/wifi/wifi_component_libretiny.cpp @@ -692,7 +692,7 @@ void WiFiComponent::wifi_scan_done_callback_() { ssid_cstr[0] == '\0'); } else { auto &ap = scan->ap[i]; - WiFiComponent::log_discarded_scan_result(ssid_cstr, ap.bssid.addr, ap.rssi, ap.channel); + this->log_discarded_scan_result(ssid_cstr, ap.bssid.addr, ap.rssi, ap.channel); } } ESP_LOGV(TAG, "Scan complete: %d found, %zu stored%s", num, this->scan_result_.size(), diff --git a/esphome/components/wifi/wifi_component_pico_w.cpp b/esphome/components/wifi/wifi_component_pico_w.cpp index 288bb98fce..e15fa250f9 100644 --- a/esphome/components/wifi/wifi_component_pico_w.cpp +++ b/esphome/components/wifi/wifi_component_pico_w.cpp @@ -143,7 +143,7 @@ void WiFiComponent::wifi_scan_result(void *env, const cyw43_ev_scan_result_t *re // Skip networks that don't match any configured network (unless full results needed) if (!this->needs_full_scan_results_() && !this->matches_configured_network_(ssid_cstr, result->bssid)) { - WiFiComponent::log_discarded_scan_result(ssid_cstr, result->bssid, result->rssi, result->channel); + this->log_discarded_scan_result(ssid_cstr, result->bssid, result->rssi, result->channel); return; }