Enable reversible ESP32 BLE shutdown and bounded radio2 CPU sleep

This commit is contained in:
mikecarper committed 2026-10-21 17:53:57 -07:00
1 parent a3d77a9a76
commit 61eecbd971
38 files changed
+1829 -117

No files matched your search

+19 -2
View File
@@ -45,8 +45,10 @@ after off starts a fresh window. Collection defaults off at every boot.
`radio2` means the scanner cannot safely idle right now: for example, a short
remaining visit, calibration, pending reception or an unvalidated platform.
On nRF52, settled long visits can idle the MCU with power saving enabled;
the RF receiver stays on. See [radio profiles](radio_profiles.md#mcu-power-saving-while-scanning).
On nRF52 and ESP32, settled long visits can idle the MCU with power saving
enabled; the RF receiver stays on. ESP32 requires working radio GPIO wake and
physically stopped WiFi/Bluetooth drivers. Short visits and active transports
retain polling. See [radio profiles](radio_profiles.md#mcu-power-saving-while-scanning).
The role reports the first actual short-circuit blocker. It does not query
otherwise skipped hardware just to populate an exhaustive list. Board guards
@@ -71,6 +73,21 @@ than the 32-bit `micros()` wrap (about 71 minutes); the normal wait paths here
are much shorter. Keep gaps between policy observations below the `millis()`
wrap (about 49 days).
## ESP32 Bluetooth off and CPU sleep
Switching Bluetooth off now completes a reversible host/controller shutdown,
including when Bluetooth was saved off at startup. Existing pairings, address,
name and PIN are retained when it is switched back on. A pending disconnect or
failed teardown keeps the CPU awake rather than treating stopped advertising
as a stopped controller. `get bluetooth` reports a pending change until that
transition finishes.
USB host sessions, logging, active WiFi/ESP-NOW, OTA and serial work keep their
existing sleep guards. This change does not sleep an ESP32 through a live
Bluetooth or WiFi connection. Such connections require SDK-managed modem and
automatic sleep; lowering CPU frequency or yielding alone is not proof of
light sleep.
## Noise-floor sampling and sleep
Startup still collects a complete baseline promptly: 64 accepted samples,
+9 -2
View File
@@ -932,8 +932,15 @@ retries, or short visits. All normal USB, logging, bridge, OTA, queue and role
sleep guards still apply. An nRF52 periodic interrupt bounds each wait to
about 0.977 ms; admission reserves another 0.488 ms before the visit deadline
and is rechecked immediately before sleeping. If that wake source is not
available, scanning keeps polling. Other MCU families retain polling until
their timing is validated.
available, scanning keeps polling.
ESP32 also permits MCU idle during settled long visits. It requires radio GPIO
wake and physically stopped WiFi/Bluetooth drivers. Its timer slices are at
most 10 ms, reserve 4 ms before the visit deadline, and require at least 2 ms
usable time. Absolute deadlines are checked again after wake-source setup;
expired visits, pending interrupts or setup failures retain polling. USB,
logging, active wireless services and the other role guards remain blockers.
Other MCU families retain polling until their timing is validated.
The integer admission gate requires at least 49 RTC2 ticks (about 1.495 ms)
remaining after the work checks. A configured visit must also cover the loop