From 73bcefb928bf1edd1ae82be575efecce7756a7c4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 9 Nov 2025 15:56:50 -0600 Subject: [PATCH] wip --- esphome/components/wifi/wifi_component.cpp | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index db50dfd127..9a41fe249f 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -509,20 +509,21 @@ void WiFiComponent::save_wifi_sta(const std::string &ssid, const std::string &pa void WiFiComponent::start_connecting(const WiFiAP &ap, bool two) { // Log connection attempt at INFO level with priority + const char *bssid_str = LOG_STR_LITERAL("any"); + std::string bssid_formatted; + float priority = 0.0f; + if (ap.get_bssid().has_value()) { - float priority = this->get_sta_priority(ap.get_bssid().value()); - ESP_LOGI( - TAG, - "Connecting to " LOG_SECRET("'%s'") " " LOG_SECRET("(%s)") " (priority %.1f, attempt %u/%u in phase %s)...", - ap.get_ssid().c_str(), format_mac_address_pretty(ap.get_bssid().value().data()).c_str(), priority, - this->num_retried_ + 1, get_max_retries_for_phase(this->retry_phase_), - LOG_STR_ARG(retry_phase_to_log_string(this->retry_phase_))); - } else { - ESP_LOGI(TAG, "Connecting to " LOG_SECRET("'%s'") " (attempt %u/%u in phase %s)...", ap.get_ssid().c_str(), - this->num_retried_ + 1, get_max_retries_for_phase(this->retry_phase_), - LOG_STR_ARG(retry_phase_to_log_string(this->retry_phase_))); + bssid_formatted = format_mac_address_pretty(ap.get_bssid().value().data()); + bssid_str = bssid_formatted.c_str(); + priority = this->get_sta_priority(ap.get_bssid().value()); } + ESP_LOGI(TAG, + "Connecting to " LOG_SECRET("'%s'") " " LOG_SECRET("(%s)") " (priority %.1f, attempt %u/%u in phase %s)...", + ap.get_ssid().c_str(), bssid_str, priority, this->num_retried_ + 1, + get_max_retries_for_phase(this->retry_phase_), LOG_STR_ARG(retry_phase_to_log_string(this->retry_phase_))); + #ifdef ESPHOME_LOG_HAS_VERBOSE ESP_LOGV(TAG, "Connection Params:"); ESP_LOGV(TAG, " SSID: '%s'", ap.get_ssid().c_str());