Modified hasPendingWork to return bool
This commit is contained in:
@@ -1116,7 +1116,7 @@ void MyMesh::loop() {
|
|||||||
last_millis = now;
|
last_millis = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
// To get the current pending work
|
// To check if there is pending work
|
||||||
int MyMesh::hasPendingWork() const {
|
bool MyMesh::hasPendingWork() const {
|
||||||
return _mgr->getOutboundCount(0xFFFFFFFF);
|
return _mgr->getOutboundCount(0xFFFFFFFF) > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,6 +226,6 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// To get the current pending work
|
// To check if there is pending work
|
||||||
int hasPendingWork() const;
|
bool hasPendingWork() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ void loop() {
|
|||||||
|
|
||||||
if (the_mesh.getNodePrefs()->powersaving_enabled && // To check if power saving is enabled
|
if (the_mesh.getNodePrefs()->powersaving_enabled && // To check if power saving is enabled
|
||||||
the_mesh.millisHasNowPassed(lastActive + nextSleepinSecs * 1000)) { // To check if it is time to sleep
|
the_mesh.millisHasNowPassed(lastActive + nextSleepinSecs * 1000)) { // To check if it is time to sleep
|
||||||
if (the_mesh.hasPendingWork() == 0) { // No pending work. Safe to sleep
|
if (!the_mesh.hasPendingWork()) { // No pending work. Safe to sleep
|
||||||
board.sleep(1800); // To sleep. Wake up after 30 minutes or when receiving a LoRa packet
|
board.sleep(1800); // To sleep. Wake up after 30 minutes or when receiving a LoRa packet
|
||||||
lastActive = millis();
|
lastActive = millis();
|
||||||
nextSleepinSecs = 5; // Default: To work for 5s and sleep again
|
nextSleepinSecs = 5; // Default: To work for 5s and sleep again
|
||||||
|
|||||||
Reference in New Issue
Block a user