From bbc26d40d3e5a55a13d81eb286deca501d8d87bc Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Fri, 10 Apr 2026 10:45:26 +0700 Subject: [PATCH 1/2] Added Power Saving for NRF52 companions --- examples/companion_radio/MyMesh.cpp | 8 ++++++++ examples/companion_radio/MyMesh.h | 3 +++ examples/companion_radio/main.cpp | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 60a5a75fe..dbc2dd67b 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -2144,3 +2144,11 @@ bool MyMesh::advert() { return false; } } + +// To check if there is pending work +bool MyMesh::hasPendingWork() const { +#if defined(WITH_BRIDGE) + if (bridge.isRunning()) return true; // bridge needs WiFi radio, can't sleep +#endif + return _mgr->getOutboundTotal() > 0; +} diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index 3b02f5f69..af5e030ba 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -174,6 +174,9 @@ class MyMesh : public BaseChatMesh, public DataStoreHost { sensors.setSettingValue("gps_interval", interval_str); } } + + // To check if there is pending work + bool hasPendingWork() const; #endif private: diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 876dc9c33..0c6aa55f9 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -229,4 +229,10 @@ void loop() { ui_task.loop(); #endif rtc_clock.tick(); + + if (!the_mesh.hasPendingWork()) { +#if defined(NRF52_PLATFORM) + board.sleep(0); // nrf ignores seconds param, sleeps whenever possible +#endif + } } From e586be9f1ca0efec1d3ed6daf27432ee1dad4a45 Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Fri, 10 Apr 2026 20:42:23 +0700 Subject: [PATCH 2/2] Fixed to put hasPendingWork out of ENV_INCLUDE_GPS --- examples/companion_radio/MyMesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index af5e030ba..3164d93d9 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -174,10 +174,10 @@ class MyMesh : public BaseChatMesh, public DataStoreHost { sensors.setSettingValue("gps_interval", interval_str); } } +#endif // To check if there is pending work bool hasPendingWork() const; -#endif private: void writeOKFrame();