From 31d9925b05d92e3c802942df3720d4383d0edbe9 Mon Sep 17 00:00:00 2001 From: agessaman Date: Wed, 9 Sep 2026 16:26:54 -0700 Subject: [PATCH] feat(mqtt): log the Wi-Fi power-save mode read back from the SDK The applied mode had no observable trace on a running node, which is how the CLI and the reconnect path could disagree about what `min` means for as long as they did. Log it at the one place that applies it, reading the value back with esp_wifi_get_ps() rather than printing what was requested. Used to confirm F11 on hardware: with `min` stored, a Heltec V4 now reports "WiFi power save: min (mode=1)" on association, where the old mapping applied WIFI_PS_NONE (mode=0). --- src/helpers/bridges/MQTTBridge.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/helpers/bridges/MQTTBridge.cpp b/src/helpers/bridges/MQTTBridge.cpp index c2deeaed9..0f8e1e33d 100644 --- a/src/helpers/bridges/MQTTBridge.cpp +++ b/src/helpers/bridges/MQTTBridge.cpp @@ -444,7 +444,15 @@ void MQTTBridge::applyWifiPowerSave() { static_assert((int)WifiPowerSavePolicy::kModeMinModem == (int)WIFI_PS_MIN_MODEM, "wifi_ps_type_t drift"); static_assert((int)WifiPowerSavePolicy::kModeMaxModem == (int)WIFI_PS_MAX_MODEM, "wifi_ps_type_t drift"); if (!_obs) return; - esp_wifi_set_ps((wifi_ps_type_t)WifiPowerSavePolicy::modeFor(_obs->wifi_power_save)); + const uint8_t stored = _obs->wifi_power_save; + esp_wifi_set_ps((wifi_ps_type_t)WifiPowerSavePolicy::modeFor(stored)); + // Read back rather than logging what we asked for: this is the only place the + // mode is observable on a running node, and the setting used to change + // meaning between the CLI and this path. + wifi_ps_type_t applied = WIFI_PS_NONE; + esp_wifi_get_ps(&applied); + MQTT_DEBUG_PRINTLN("WiFi power save: %s (mode=%d)", + WifiPowerSavePolicy::nameFor(stored), (int)applied); #endif }