From 09b42b778bbd3470e07f2c6540a5cb9f4c36dd34 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 20 Jan 2026 20:57:39 -1000 Subject: [PATCH] log scan complete --- esphome/components/wifi/wifi_component_esp8266.cpp | 4 ++++ esphome/components/wifi/wifi_component_libretiny.cpp | 2 ++ esphome/components/wifi/wifi_component_pico_w.cpp | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/esphome/components/wifi/wifi_component_esp8266.cpp b/esphome/components/wifi/wifi_component_esp8266.cpp index 78a301cae7..de07818f59 100644 --- a/esphome/components/wifi/wifi_component_esp8266.cpp +++ b/esphome/components/wifi/wifi_component_esp8266.cpp @@ -760,8 +760,10 @@ void WiFiComponent::wifi_scan_done_callback_(void *arg, STATUS status) { bool needs_full = this->needs_full_scan_results_(); // First pass: count matching networks (linked list is non-destructive) + size_t total = 0; size_t count = 0; for (bss_info *it = head; it != nullptr; it = STAILQ_NEXT(it, next)) { + total++; const char *ssid_cstr = reinterpret_cast(it->ssid); if (needs_full || this->matches_configured_network_(ssid_cstr, it->bssid)) { count++; @@ -781,6 +783,8 @@ void WiFiComponent::wifi_scan_done_callback_(void *arg, STATUS status) { WiFiComponent::log_discarded_scan_result_(ssid_cstr, it->bssid, it->rssi, it->channel); } } + ESP_LOGD(TAG, "Scan complete: %zu found, %zu stored%s", total, this->scan_result_.size(), + needs_full ? "" : " (filtered)"); this->scan_done_ = true; #ifdef USE_WIFI_SCAN_RESULTS_LISTENERS for (auto *listener : global_wifi_component->scan_results_listeners_) { diff --git a/esphome/components/wifi/wifi_component_libretiny.cpp b/esphome/components/wifi/wifi_component_libretiny.cpp index d2ebf267b6..dc89784de2 100644 --- a/esphome/components/wifi/wifi_component_libretiny.cpp +++ b/esphome/components/wifi/wifi_component_libretiny.cpp @@ -695,6 +695,8 @@ void WiFiComponent::wifi_scan_done_callback_() { WiFiComponent::log_discarded_scan_result_(ssid_cstr, ap.bssid.addr, ap.rssi, ap.channel); } } + ESP_LOGD(TAG, "Scan complete: %d found, %zu stored%s", num, this->scan_result_.size(), + needs_full ? "" : " (filtered)"); WiFi.scanDelete(); #ifdef USE_WIFI_SCAN_RESULTS_LISTENERS for (auto *listener : this->scan_results_listeners_) { diff --git a/esphome/components/wifi/wifi_component_pico_w.cpp b/esphome/components/wifi/wifi_component_pico_w.cpp index d6d2ce0948..a626e012a7 100644 --- a/esphome/components/wifi/wifi_component_pico_w.cpp +++ b/esphome/components/wifi/wifi_component_pico_w.cpp @@ -21,6 +21,7 @@ static const char *const TAG = "wifi_pico_w"; // Track previous state for detecting changes static bool s_sta_was_connected = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) static bool s_sta_had_ip = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +static size_t s_scan_result_count = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) bool WiFiComponent::wifi_mode_(optional sta, optional ap) { if (sta.has_value()) { @@ -137,6 +138,7 @@ int WiFiComponent::s_wifi_scan_result(void *env, const cyw43_ev_scan_result_t *r } void WiFiComponent::wifi_scan_result(void *env, const cyw43_ev_scan_result_t *result) { + s_scan_result_count++; const char *ssid_cstr = reinterpret_cast(result->ssid); // Skip networks that don't match any configured network (unless full results needed) @@ -158,6 +160,7 @@ void WiFiComponent::wifi_scan_result(void *env, const cyw43_ev_scan_result_t *re bool WiFiComponent::wifi_scan_start_(bool passive) { this->scan_result_.clear(); this->scan_done_ = false; + s_scan_result_count = 0; cyw43_wifi_scan_options_t scan_options = {0}; scan_options.scan_type = passive ? 1 : 0; int err = cyw43_wifi_scan(&cyw43_state, &scan_options, nullptr, &s_wifi_scan_result); @@ -253,7 +256,9 @@ void WiFiComponent::wifi_loop_() { // Handle scan completion if (this->state_ == WIFI_COMPONENT_STATE_STA_SCANNING && !cyw43_wifi_scan_active(&cyw43_state)) { this->scan_done_ = true; - ESP_LOGV(TAG, "Scan done"); + bool needs_full = this->needs_full_scan_results_(); + ESP_LOGD(TAG, "Scan complete: %zu found, %zu stored%s", s_scan_result_count, this->scan_result_.size(), + needs_full ? "" : " (filtered)"); #ifdef USE_WIFI_SCAN_RESULTS_LISTENERS for (auto *listener : this->scan_results_listeners_) { listener->on_wifi_scan_results(this->scan_result_);