From de4bcd9a52031e3cdc94649e977e996d20951e70 Mon Sep 17 00:00:00 2001 From: liquidraver <504870+liquidraver@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:41:56 +0200 Subject: [PATCH] clear first_fix_acquired on gps off, increase timeout to 120 sec --- zephcore/Kconfig | 6 +++++- zephcore/adapters/gps/ZephyrGPSManager.cpp | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/zephcore/Kconfig b/zephcore/Kconfig index f955d1d..bd85e2a 100644 --- a/zephcore/Kconfig +++ b/zephcore/Kconfig @@ -445,11 +445,15 @@ config ZEPHCORE_GPS_POLL_INTERVAL_SEC config ZEPHCORE_GPS_FIX_TIMEOUT_SEC int "GPS fix acquisition timeout in seconds" - default 30 + default 120 range 10 300 help Maximum time to wait for GPS fix before giving up. GPS will be powered off after this timeout. + Default 120s — 30s was too aggressive for Air530Z / MAX-7Q warm + starts in marginal sky conditions; the acquire loop would time out + before the 3-consecutive-good-fix gate could promote. Only applies + to wake cycles after the first successful fix since enable. endmenu diff --git a/zephcore/adapters/gps/ZephyrGPSManager.cpp b/zephcore/adapters/gps/ZephyrGPSManager.cpp index 1f21943..aec1b89 100644 --- a/zephcore/adapters/gps/ZephyrGPSManager.cpp +++ b/zephcore/adapters/gps/ZephyrGPSManager.cpp @@ -85,7 +85,7 @@ enum gps_state { static enum gps_state gps_current_state = GPS_STATE_OFF; static uint8_t consecutive_good_fixes = 0; -static bool first_fix_acquired = false; /* True after first successful fix since enable */ +static bool first_fix_acquired = false; /* True after first 3-good-fix cycle since enable. Cleared on gps_enable(false) and at boot. */ static bool gps_time_synced = false; /* True after GPS syncs RTC. Starts false at boot (RTC reset), * set true after 3 good fixes, cleared when GPS disabled. */ static int64_t last_fix_uptime_ms = 0; /* k_uptime when last validated fix was acquired */ @@ -1297,6 +1297,12 @@ void gps_enable(bool enable) gps_current_state = GPS_STATE_OFF; consecutive_good_fixes = 0; + /* Clear first-fix flag so the next enable gets the "no timeout" + * grace period again — in marginal signal, a 30–120s timeout may + * never be enough, and the user explicitly toggled GPS expecting + * it to try hard for a fix. */ + first_fix_acquired = false; + /* Clear time sync flag - time will drift, allow phone sync again */ gps_time_synced = false; }