You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/simple_repeater/main.cpp
+10-6Lines changed: 10 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,12 @@ void halt() {
20
20
staticchar command[160];
21
21
22
22
// For power saving
23
+
constuint32_tPOWERSAVING_FIRSTSLEEP_SINCEBOOT_SECS = 120; // PowerSaving will be active some time after boot
24
+
constuint32_tPOWERSAVING_MAXSLEEP_PERIOD_SECS = 1800; // Wakeup periodically to do scheduled jobs
25
+
constuint32_tPOWERSAVING_WAKEUP_PERIOD_SECS = 5; // Awake period after wakeup
26
+
23
27
unsignedlong lastActive = 0; // mark last active time
24
-
unsignedlong nextSleepinSecs = 120; // next sleep in seconds. The first sleep (if enabled) is after 2 minutes from boot
28
+
unsignedlong nextSleepinSecs = POWERSAVING_FIRSTSLEEP_SINCEBOOT_SECS; // next sleep in seconds. The first sleep (if enabled) is after some time since boot
25
29
26
30
voidsetup() {
27
31
Serial.begin(115200);
@@ -127,14 +131,14 @@ void loop() {
127
131
#endif
128
132
rtc_clock.tick();
129
133
130
-
if (the_mesh.getNodePrefs()->powersaving_enabled && //To check if power saving is enabled
131
-
the_mesh.millisHasNowPassed(lastActive + nextSleepinSecs * 1000)) { //To check if it is time to sleep
134
+
if (the_mesh.getNodePrefs()->powersaving_enabled && //Check if power saving is enabled
135
+
the_mesh.millisHasNowPassed(lastActive + nextSleepinSecs * 1000)) { //Check if it is time to sleep
132
136
if (!the_mesh.hasPendingWork()) { // No pending work. Safe to sleep
133
-
board.sleep(1800); //To sleep. Wake up after 30 minutes or when receiving a LoRa packet
137
+
board.sleep(POWERSAVING_MAXSLEEP_PERIOD_SECS); //Sleep. Wake up periodically or when receiving a LoRa packet
134
138
lastActive = millis();
135
-
nextSleepinSecs = 5; // Default: To work for 5s and sleep again
139
+
nextSleepinSecs = POWERSAVING_WAKEUP_PERIOD_SECS; // Default: Work for 1 wakeup period and sleep again
136
140
} else {
137
-
nextSleepinSecs += 5; // When there is pending work, to work another 5s
141
+
nextSleepinSecs += POWERSAVING_WAKEUP_PERIOD_SECS; // When there is pending work, work another wakeup period
0 commit comments