|
|
|
@ -29,6 +29,10 @@ void setup() { |
|
|
|
|
|
|
|
board.begin(); |
|
|
|
|
|
|
|
#ifdef HAS_EX_WATCHDOG |
|
|
|
ex_watchdog.begin(); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(MESH_DEBUG) && defined(NRF52_PLATFORM) |
|
|
|
// give some extra time for serial to settle so
|
|
|
|
// boot debug messages can be seen on terminal
|
|
|
|
@ -134,11 +138,24 @@ void loop() { |
|
|
|
#endif |
|
|
|
rtc_clock.tick(); |
|
|
|
|
|
|
|
#ifdef HAS_EX_WATCHDOG |
|
|
|
ex_watchdog.loop(); |
|
|
|
#endif |
|
|
|
if (the_mesh.getNodePrefs()->powersaving_enabled && !the_mesh.hasPendingWork()) { |
|
|
|
#if defined(NRF52_PLATFORM) |
|
|
|
#if defined(NRF52_PLATFORM) |
|
|
|
#ifdef HAS_EX_WATCHDOG |
|
|
|
uint32_t sleep_interval = ex_watchdog.getIntervalMs()/1000; |
|
|
|
board.sleep((sleep_interval > 1800) ? 1800 : sleep_interval); // To sleep. Wake up after 30 minutes or when receiving a LoRa packet
|
|
|
|
#else |
|
|
|
board.sleep(1800); // To sleep. Wake up after 30 minutes or when receiving a LoRa packet
|
|
|
|
#endif |
|
|
|
board.sleep(1800); // nrf ignores seconds param, sleeps whenever possible
|
|
|
|
#else |
|
|
|
#else |
|
|
|
if (the_mesh.millisHasNowPassed(lastActive + nextSleepinSecs * 1000)) { // To check if it is time to sleep
|
|
|
|
#ifdef HAS_EX_WATCHDOG |
|
|
|
uint32_t sleep_interval = ex_watchdog.getIntervalMs()/1000; |
|
|
|
board.sleep((sleep_interval > 1800) ? 1800 : sleep_interval); // To sleep. Wake up after 30 minutes or when receiving a LoRa packet
|
|
|
|
#else |
|
|
|
board.sleep(1800); // To sleep. Wake up after 30 minutes or when receiving a LoRa packet
|
|
|
|
#endif |
|
|
|
lastActive = millis(); |
|
|
|
@ -146,6 +163,6 @@ void loop() { |
|
|
|
} else { |
|
|
|
nextSleepinSecs += 5; // When there is pending work, to work another 5s
|
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|