From bdd107b35db75414fb935762fb2012ac1fb55dfe Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 12 Oct 2026 16:02:47 +0000 Subject: [PATCH] r123: a bench flag that keeps light sleep out of the state machine Light sleep suspends the USB-serial/JTAG console, and a CPU-only reset does not bring it back, so a capture goes dark for as long as the node sleeps - the same thing that cost r120 most of its runs. Nothing in r123 needs light sleep: the fix under test is on the deep-sleep path. MESHTASTIC_NO_LIGHT_SLEEP leaves the two timed transitions into stateLS out of PowerFSM, so no config can put the capture back in the dark. It is not an early return from doLightSleep(): lsIdle() reads an immediate ESP_SLEEP_WAKEUP_TIMER as a completed sleep chunk, so that shape would churn through ls_secs at loop speed instead of sleeping. Deep sleep is untouched. Only tbeam-s3-core-r123 defines it. Co-Authored-By: Jonathan Bennett Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01GTiifXrVc4YdonmLRCeWhw --- src/PowerFSM.cpp | 13 ++++++++++++- variants/esp32s3/tbeam-s3-core/platformio.ini | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index b454b71815..8d0839b6bf 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -443,7 +443,18 @@ void PowerFSM_setup() config.device.role == meshtastic_Config_DeviceConfig_Role_TAK_TRACKER || config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR; - if ((isRouter || config.power.is_power_saving) && !isWifiAvailable() && !isTrackerOrSensor) { +#ifdef MESHTASTIC_NO_LIGHT_SLEEP + // Bench flag (r123). Light sleep suspends the USB-serial/JTAG console and a CPU-only reset does not + // bring it back, so a capture goes dark for as long as the node sleeps. Keep the two transitions into + // stateLS out of the machine entirely rather than returning early from doLightSleep(): lsIdle() reads + // an immediate ESP_SLEEP_WAKEUP_TIMER as a completed sleep chunk, so it would churn through ls_secs at + // loop speed instead. Deep sleep is unaffected. + const bool addLightSleepTransitions = false; + LOG_WARN("MESHTASTIC_NO_LIGHT_SLEEP: light sleep is disabled in this build"); +#else + const bool addLightSleepTransitions = true; +#endif + if (addLightSleepTransitions && (isRouter || config.power.is_power_saving) && !isWifiAvailable() && !isTrackerOrSensor) { powerFSM.add_timed_transition(&stateNB, &stateLS, Default::getConfiguredOrDefaultMs(config.power.min_wake_secs, default_min_wake_secs), NULL, "Min wake timeout"); diff --git a/variants/esp32s3/tbeam-s3-core/platformio.ini b/variants/esp32s3/tbeam-s3-core/platformio.ini index fc812662af..ba14b3c3f2 100644 --- a/variants/esp32s3/tbeam-s3-core/platformio.ini +++ b/variants/esp32s3/tbeam-s3-core/platformio.ini @@ -33,3 +33,4 @@ board_level = extra build_flags = ${env:tbeam-s3-core.build_flags} -D MESHTASTIC_WAKE_PIN_PROBE=1 + -D MESHTASTIC_NO_LIGHT_SLEEP=1