From 1077331e3162e8e80c76b900a0c8275d4fed2465 Mon Sep 17 00:00:00 2001 From: Blake Latchford Date: Tue, 8 Sep 2026 16:57:12 -0400 Subject: [PATCH] Extend WiFi disconnect logging to specify reason Today if a user builds firmware with an incorrect WiFi SSID or password, they get a generic `WiFi disconnected.` error message. Extend logging to descirbe the reason that WiFi was disconnected. I gathered the updated logs for the 3 scenarios below. ``` WiFi: Attempting manual WiFi reconnect... WiFi: WiFi disconnected (reason=ASSOC_LEAVE). Flagging for reconnect... WiFi: WiFi disconnected (reason=4WAY_HANDSHAKE_TIMEOUT). Flagging for reconnect... WiFi: WiFi disconnected (reason=4WAY_HANDSHAKE_TIMEOUT). Flagging for reconnect... WiFi: WiFi disconnected (reason=4WAY_HANDSHAKE_TIMEOUT). Flagging for reconnect... ``` ``` WiFi: WiFi disconnected (reason=NO_AP_FOUND). Flagging for reconnect... ``` ``` WiFi: WiFi connected successfully! WiFi: Got connection ``` --- examples/companion_radio/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 6dc9acdc3..0e9899992 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -229,7 +229,8 @@ void setup() { WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info){ if (event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED) { - WIFI_DEBUG_PRINTLN("WiFi disconnected. Flagging for reconnect..."); + WIFI_DEBUG_PRINTLN("WiFi disconnected (reason=%s). Flagging for reconnect...", + WiFi.disconnectReasonName((wifi_err_reason_t)info.wifi_sta_disconnected.reason)); wifi_needs_reconnect = true; } else if (event == ARDUINO_EVENT_WIFI_STA_GOT_IP) { WIFI_DEBUG_PRINTLN("WiFi connected successfully!");