From 8b697cd2a445355dcfab5b33e0ce7a3128cab151 Mon Sep 17 00:00:00 2001 From: Todd Herbert Date: Thu, 13 Jun 2024 02:09:57 +1200 Subject: [PATCH] Attempt 2: Send PMREQ with duration 0 on MCU deep-sleep --- src/gps/GPS.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 6a8d6d59c1..e67e129c16 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -785,7 +785,7 @@ void GPS::setGPSPower(bool on, bool standbyOnly, uint32_t sleepTime) powerState = GPS_ACTIVE; else if (!enabled) // User has disabled with triple press powerState = GPS_OFF; - else if (sleepTime <= GPS_IDLE_THRESHOLD_SECONDS * 1000UL) + else if (sleepTime <= GPS_IDLE_THRESHOLD_SECONDS * 1000UL && sleepTime > 0) // sleepTime=0 indicates indefinite GPS poweroff powerState = GPS_IDLE; else if (standbyOnly) powerState = GPS_STANDBY; @@ -940,7 +940,8 @@ void GPS::setAwake(bool wantAwake) // How long to wait before attempting next GPS update // Aims to hit position.gps_update_interval by using the lock-time prediction - uint32_t compensatedSleepTime = (getSleepTime() > predictedLockTime) ? (getSleepTime() - predictedLockTime) : 0; + // Sleep for at least 1 second, so we don't ask GPS hardware to sleep indefinitely with a "0 second PMREQ" + uint32_t compensatedSleepTime = (getSleepTime() > predictedLockTime) ? (getSleepTime() - predictedLockTime) : 1; // If long interval between updates: power off between updates if (compensatedSleepTime > GPS_STANDBY_THRESHOLD_MINUTES * MS_IN_MINUTE) { @@ -1129,11 +1130,10 @@ void GPS::clearBuffer() /// Prepare the GPS for the cpu entering deep or light sleep, expect to be gone for at least 100s of msecs int GPS::prepareDeepSleep(void *unused) { - LOG_INFO("GPS deep sleep!\n"); - - // Manually enter GPSPowerState::OFF, so we can ensure a PMREQ with duration 0 has been sent - setGPSPower(false, false, 0); - + /* + * GPS power was previously set here. + * Now removed, as the same call is already made directly in doDeepSleep. + */ return 0; }