From 31c1d935f2d3138f58eddea037c8286082155765 Mon Sep 17 00:00:00 2001 From: m1nl Date: Fri, 25 Apr 2025 00:24:59 +0200 Subject: [PATCH] use events to stay in idle state --- src/PowerFSM.cpp | 6 ++++-- src/PowerFSM.h | 2 +- src/mesh/RadioLibInterface.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index afd4beaf1..6f7b76cf3 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -130,7 +130,7 @@ static void lsIdle() case ESP_SLEEP_WAKEUP_EXT0: LOG_DEBUG("Wake cause ESP_SLEEP_WAKEUP_EXT0"); - powerFSM.trigger(EVENT_LORA_INTERRUPT); + powerFSM.trigger(EVENT_RADIO_INTERRUPT); return; case ESP_SLEEP_WAKEUP_EXT1: @@ -383,10 +383,12 @@ void PowerFSM_setup() // when we leave, go to ON (which might not be the correct state if we have power connected, we will fix that in onEnter) powerFSM.add_transition(&stateSERIAL, &stateON, EVENT_SERIAL_DISCONNECTED, NULL, "Serial disconnect"); - powerFSM.add_transition(&stateLS, stateIDLE, EVENT_LORA_INTERRUPT, NULL, "LoRa interrupt"); powerFSM.add_transition(&stateLS, stateIDLE, EVENT_WAKE_TIMER, NULL, "Wake timer"); + powerFSM.add_transition(&stateLS, stateIDLE, EVENT_RADIO_INTERRUPT, NULL, "Radio interrupt"); powerFSM.add_transition(stateIDLE, stateIDLE, EVENT_WAKE_TIMER, NULL, "Wake timer"); + powerFSM.add_transition(stateIDLE, stateIDLE, EVENT_WEB_REQUEST, NULL, "Web request"); + powerFSM.add_transition(stateIDLE, stateIDLE, EVENT_RADIO_INTERRUPT, NULL, "Radio interrupt"); #ifdef USE_EINK // Allow E-Ink devices to suppress the screensaver, if screen timeout set to 0 diff --git a/src/PowerFSM.h b/src/PowerFSM.h index 0bfef470e..887c4dccb 100644 --- a/src/PowerFSM.h +++ b/src/PowerFSM.h @@ -21,7 +21,7 @@ #define EVENT_FIRMWARE_UPDATE 15 // We just received a new firmware update packet from the phone #define EVENT_SHUTDOWN 16 // force a full shutdown now (not just sleep) #define EVENT_INPUT 17 // input broker wants something, we need to wake up and enable screen -#define EVENT_LORA_INTERRUPT 18 +#define EVENT_RADIO_INTERRUPT 18 #define EVENT_WEB_REQUEST 19 #if defined(ARCH_ESP32) && !defined(WAKE_TIME_MS) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index c6057231c..ef0f4fc93 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -246,7 +246,7 @@ currently active. */ void RadioLibInterface::onNotify(uint32_t notification) { - powerFSM.trigger(EVENT_LORA_INTERRUPT); + powerFSM.trigger(EVENT_RADIO_INTERRUPT); switch (notification) { case ISR_TX: