PowerSaving for room servers

This commit is contained in:
Kevin Le committed 2026-08-14 23:36:52 +07:00
1 parent 594d770968
commit be6f3599e2
3 files changed
+18

No files matched your search

+5
View File
@@ -1077,3 +1077,8 @@ void MyMesh::loop() {
uptime_millis += now - last_millis;
last_millis = now;
}
// To check if there is pending work
bool MyMesh::hasPendingWork() const {
return _mgr->getOutboundTotal() > 0;
}
+3
View File
@@ -229,4 +229,7 @@ public:
void clearStats() override;
void handleCommand(uint32_t sender_timestamp, char* command, char* reply);
void loop();
// To check if there is pending work
bool hasPendingWork() const;
};
+10
View File
@@ -157,4 +157,14 @@ void loop() {
#ifdef HAS_EXTERNAL_WATCHDOG
external_watchdog.loop();
#endif
if (the_mesh.getNodePrefs()->powersaving_enabled && !the_mesh.hasPendingWork()) {
#if defined(NRF52_PLATFORM)
board.sleep(0); // nrf ignores seconds param, sleeps whenever possible
#else
if (the_mesh.millisHasNowPassed(POWERSAVING_FIRSTSLEEP_SECS * 1000)) { // To check if it is time to sleep
board.sleep(30); // Sleep. Wake up after a while or when receiving a LoRa packet
}
#endif
}
}