Skip to content

fix(power): soft-sleep the GPS receiver during CPU light-sleep#10439

Open
DatanoiseTV wants to merge 1 commit into
meshtastic:developfrom
DatanoiseTV:fix/power-gps-soft-sleep
Open

fix(power): soft-sleep the GPS receiver during CPU light-sleep#10439
DatanoiseTV wants to merge 1 commit into
meshtastic:developfrom
DatanoiseTV:fix/power-gps-soft-sleep

Conversation

@DatanoiseTV
Copy link
Copy Markdown
Contributor

GPS only subscribed to notifyDeepSleep, so during light-sleep the
receiver kept drawing ~25 mA on a non-router device — the dominant
drain on devices that spend most of their time in LIGHT_SLEEP.
Subscribe to notifyLightSleep/notifyLightSleepEnd as well, but use
GPS_SOFTSLEEP instead of disable()+enable() since the state machine
survives across the short light-sleep window and full power-cycle
re-acquisition would cost more than it saves.

Split out from #10425 — single-concern PR.

Build verification

pio run -e t-deck-tft succeeds, no new warnings.

Attestations

  • I have tested that my proposed changes behave as described — review/static-analysis only, not on-air.
  • On-hardware testing requested from community: build-verified t-deck-tft only.

GPS only subscribed to notifyDeepSleep, so during light-sleep the
receiver kept drawing ~25 mA on a non-router device — the dominant
drain on devices that spend most of their time in LIGHT_SLEEP.
Subscribe to notifyLightSleep/notifyLightSleepEnd as well, but use
GPS_SOFTSLEEP instead of disable()+enable() since the state machine
survives across the short light-sleep window and full power-cycle
re-acquisition would cost more than it saves.
@github-actions github-actions Bot added needs-review Needs human review bugfix Pull request that fixes bugs labels May 9, 2026
@thebentern thebentern requested a review from Copilot May 9, 2026 18:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces GPS power draw during ESP32 CPU light-sleep by subscribing the GPS module to light-sleep enter/exit notifications and transitioning the receiver into a low-power “soft sleep” state across the light-sleep window (instead of fully disabling/enabling the GPS).

Changes:

  • Register/unregister GPS observers for notifyLightSleep and notifyLightSleepEnd on ESP32.
  • Add ESP32-only GPS callbacks to soft-sleep the receiver on light-sleep entry and restore it on wake.
  • Track the pre-light-sleep GPS power state to decide whether to resume GPS_ACTIVE after wake.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/gps/GPS.h Adds ESP32-only observer members/state for light-sleep enter/exit handling.
src/gps/GPS.cpp Hooks observers in setup()/destructor and implements prepareLightSleep() / endLightSleep() soft-sleep behavior.

Comment thread src/gps/GPS.cpp
{
preLightSleepState = powerState;
if (powerState == GPS_ACTIVE) {
setPowerState(GPS_SOFTSLEEP);
Comment thread src/gps/GPS.h
Comment on lines +201 to +205
#ifdef ARCH_ESP32
GPSPowerState preLightSleepState = GPS_OFF;
CallbackObserver<GPS, void *> notifyLightSleepObserver = CallbackObserver<GPS, void *>(this, &GPS::prepareLightSleep);
CallbackObserver<GPS, esp_sleep_wakeup_cause_t> notifyLightSleepEndObserver =
CallbackObserver<GPS, esp_sleep_wakeup_cause_t>(this, &GPS::endLightSleep);
@NomDeTom
Copy link
Copy Markdown
Collaborator

This needs to be reviewed against the main GPS power system. Tying it to CPU sleeping doesn't necessarily make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs needs-review Needs human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants