Enable reversible ESP32 BLE shutdown and bounded radio2 CPU sleep
This commit is contained in:
1 parent
a3d77a9a76
commit
61eecbd971
38 files changed
+1829
-117
No files matched your search
@@ -58,6 +58,7 @@ static bool armTrackerSleepWake(uint32_t seconds) {
|
||||
|
||||
#if defined(ESP32_PLATFORM)
|
||||
#include <helpers/ESP32TrueRandom.h>
|
||||
#include <helpers/esp32/ProfileIdleSleep.h>
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
@@ -405,6 +406,9 @@ void loop() {
|
||||
can_power_save = can_power_save && sleep_guard(!user_btn.needsPolling(), mesh::powerdiag::Reason::Button);
|
||||
#endif
|
||||
if (can_power_save) {
|
||||
#if defined(ESP32_PLATFORM)
|
||||
const uint32_t sleep_budget_started_us = static_cast<uint32_t>(esp_timer_get_time());
|
||||
#endif
|
||||
uint32_t sleep_ms = the_mesh.getPowerSaveSleepMilliseconds(30000);
|
||||
uint32_t noise_floor_delay_ms = 0;
|
||||
const bool noise_floor_wait = the_mesh.getNextNoiseFloorWakeDelay(noise_floor_delay_ms);
|
||||
@@ -444,6 +448,13 @@ void loop() {
|
||||
&& the_mesh.millisHasNowPassed(
|
||||
POWERSAVING_FIRST_SLEEP_SECS * 1000UL)) {
|
||||
if (mesh::powerdiag::enabled()) mesh::powerdiag::decision(0, millis());
|
||||
#if defined(ESP32_PLATFORM)
|
||||
if (the_mesh.isDualRadioActive()) {
|
||||
if (!mesh::esp32::tryProfileIdleSleep(the_mesh, board, sleep_budget_started_us, sleep_ms)
|
||||
&& mesh::powerdiag::enabled())
|
||||
mesh::powerdiag::decision(mesh::powerdiag::mask(mesh::powerdiag::Reason::DualRadio), millis());
|
||||
} else
|
||||
#endif
|
||||
board.sleepMilliseconds(sleep_ms);
|
||||
} else if (sleep_ms > 0 && mesh::powerdiag::enabled()) {
|
||||
mesh::powerdiag::decision(mesh::powerdiag::mask(mesh::powerdiag::Reason::Startup), millis());
|
||||
|
||||
Reference in new issue
Block a user