From 5becaebdda0903558f0d3227c78c9bc7391e9d81 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sun, 17 Nov 2019 23:25:04 +0100 Subject: [PATCH] Improve WiFi disconnect messages (#857) * Improve WiFi disconnect messages * Fix * Update wifi_component_esp32.cpp --- esphome/components/wifi/wifi_component_esp32.cpp | 8 ++++++-- esphome/components/wifi/wifi_component_esp8266.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/esphome/components/wifi/wifi_component_esp32.cpp b/esphome/components/wifi/wifi_component_esp32.cpp index 862db7a9de..e345ab1671 100644 --- a/esphome/components/wifi/wifi_component_esp32.cpp +++ b/esphome/components/wifi/wifi_component_esp32.cpp @@ -329,8 +329,12 @@ void WiFiComponent::wifi_event_callback_(system_event_id_t event, system_event_i char buf[33]; memcpy(buf, it.ssid, it.ssid_len); buf[it.ssid_len] = '\0'; - ESP_LOGW(TAG, "Event: Disconnected ssid='%s' bssid=" LOG_SECRET("%s") " reason=%s", buf, - format_mac_addr(it.bssid).c_str(), get_disconnect_reason_str(it.reason)); + if (it.reason == WIFI_REASON_NO_AP_FOUND) { + ESP_LOGW(TAG, "Event: Disconnected ssid='%s' reason='Probe Request Unsuccessful'", buf); + } else { + ESP_LOGW(TAG, "Event: Disconnected ssid='%s' bssid=" LOG_SECRET("%s") " reason='%s'", buf, + format_mac_addr(it.bssid).c_str(), get_disconnect_reason_str(it.reason)); + } break; } case SYSTEM_EVENT_STA_AUTHMODE_CHANGE: { diff --git a/esphome/components/wifi/wifi_component_esp8266.cpp b/esphome/components/wifi/wifi_component_esp8266.cpp index ee67fd36df..88bcb03450 100644 --- a/esphome/components/wifi/wifi_component_esp8266.cpp +++ b/esphome/components/wifi/wifi_component_esp8266.cpp @@ -330,8 +330,12 @@ void WiFiComponent::wifi_event_callback(System_Event_t *event) { char buf[33]; memcpy(buf, it.ssid, it.ssid_len); buf[it.ssid_len] = '\0'; - ESP_LOGW(TAG, "Event: Disconnected ssid='%s' bssid=%s reason='%s'", buf, format_mac_addr(it.bssid).c_str(), - get_disconnect_reason_str(it.reason)); + if (it.reason == REASON_NO_AP_FOUND) { + ESP_LOGW(TAG, "Event: Disconnected ssid='%s' reason='Probe Request Unsuccessful'", buf); + } else { + ESP_LOGW(TAG, "Event: Disconnected ssid='%s' bssid=" LOG_SECRET("%s") " reason='%s'", buf, + format_mac_addr(it.bssid).c_str(), get_disconnect_reason_str(it.reason)); + } break; } case EVENT_STAMODE_AUTHMODE_CHANGE: {