mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-03 10:46:12 +00:00
Merge pull request #2286 from IoTThinks/MCdev-PowerSaving-for-nrf52-companion-202604
Added Power Saving for NRF52 companions to have extra 30% battery life
This commit is contained in:
@@ -2222,3 +2222,8 @@ bool MyMesh::advert() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To check if there is pending work
|
||||||
|
bool MyMesh::hasPendingWork() const {
|
||||||
|
return _mgr->getOutboundTotal() > 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -177,6 +177,9 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// To check if there is pending work
|
||||||
|
bool hasPendingWork() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void writeOKFrame();
|
void writeOKFrame();
|
||||||
void writeErrFrame(uint8_t err_code);
|
void writeErrFrame(uint8_t err_code);
|
||||||
|
|||||||
@@ -250,13 +250,19 @@ void loop() {
|
|||||||
#endif
|
#endif
|
||||||
rtc_clock.tick();
|
rtc_clock.tick();
|
||||||
|
|
||||||
|
if (!the_mesh.hasPendingWork()) {
|
||||||
|
#if defined(NRF52_PLATFORM)
|
||||||
|
board.sleep(0); // nrf ignores seconds param, sleeps whenever possible
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(ESP32) && defined(WIFI_SSID)
|
#if defined(ESP32) && defined(WIFI_SSID)
|
||||||
// Safely attempt to reconnect every 10 seconds if flagged
|
// Safely attempt to reconnect every 10 seconds if flagged
|
||||||
if (wifi_needs_reconnect && (millis() - last_wifi_reconnect_attempt > 10000)) {
|
if (wifi_needs_reconnect && (millis() - last_wifi_reconnect_attempt > 10000)) {
|
||||||
WIFI_DEBUG_PRINTLN("Attempting manual WiFi reconnect...");
|
WIFI_DEBUG_PRINTLN("Attempting manual WiFi reconnect...");
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
WiFi.reconnect();
|
WiFi.reconnect();
|
||||||
last_wifi_reconnect_attempt = millis();
|
last_wifi_reconnect_attempt = millis();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user