diff --git a/lib/hal/HalPowerManager.cpp b/lib/hal/HalPowerManager.cpp index 790c7c05..78f0018f 100644 --- a/lib/hal/HalPowerManager.cpp +++ b/lib/hal/HalPowerManager.cpp @@ -66,6 +66,15 @@ void HalPowerManager::startDeepSleep(HalGPIO& gpio) const { delay(50); gpio.update(); } + +#ifdef ENABLE_SERIAL_LOG + // Tear down HWCDC so the host sees a clean disconnect and the peripheral + // doesn't hold power domains that interfere with USB-powered GPIO wake. + // logSerial is the raw HWCDC reference; Serial is the MySerialImpl proxy + // (which doesn't expose end()). + logSerial.end(); +#endif + // Pre-sleep routines from the original firmware // GPIO13 is connected to battery latch MOSFET, we need to make sure it's low during sleep // Note that this means the MCU will be completely powered off during sleep, including RTC diff --git a/src/main.cpp b/src/main.cpp index 6c601ab9..3b7e7c9e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -214,6 +215,13 @@ void enterDeepSleep() { activityManager.goToSleep(); + // Tear down WiFi so the modem power domain isn't held alive across deep sleep. + // Wake from deep sleep is effectively a chip reset, so no state needs to survive. + if (WiFi.getMode() != WIFI_MODE_NULL) { + WiFi.disconnect(true); + WiFi.mode(WIFI_OFF); + } + halTiltSensor.deepSleep(); display.deepSleep(); LOG_DBG("MAIN", "Entering deep sleep");