-
Notifications
You must be signed in to change notification settings - Fork 720
GPS detection in initBasicGPS() too short — most repeater variants affected #2258
Description
Problem
The GPS detection in EnvironmentSensorManager::initBasicGPS() uses a hardcoded 1-second delay before checking Serial1.available():
_location->begin();
_location->reset(); // 10ms reset pulse
delay(1000); // only 1 second
#ifdef ENV_SKIP_GPS_DETECT
gps_detected = true;
#else
gps_detected = (Serial1.available() > 0);
#endifCold-starting GPS modules often need 2-5 seconds before they begin outputting NMEA sentences. When detection fails, gps_detected is set to false, which hides all GPS CLI commands and prevents GPS time sync entirely.
Current workaround
The ENV_SKIP_GPS_DETECT=1 and PERSISTANT_GPS=1 build flags bypass detection and force GPS active. But only 3 out of ~20+ GPS-equipped variants have these flags in their repeater builds:
- LilyGo TBeam 1W
- ThinkNode M5
- ThinkNode M1 (PR Enable GPS time sync for ThinkNode M1 repeater builds 🤖🤖 #2256)
Plus Station G2 (PR #2255). All other GPS-equipped repeater variants (Heltec V4, Heltec Tracker/V2, T096, T114, TBeam SX1262, TBeam Supreme, TDeck, T-Echo, SenseCap Solar, ProMicro, Nano G2 Ultra, ThinkNode M3/M6, GAT562 variants, etc.) are susceptible to GPS detection failure on cold start.
Suggested fix
Instead of adding ENV_SKIP_GPS_DETECT to every variant, fix the detection itself. For example, a short retry loop:
_location->begin();
_location->reset();
#ifdef ENV_SKIP_GPS_DETECT
gps_detected = true;
#else
gps_detected = false;
for (int i = 0; i < 5 && !gps_detected; i++) {
delay(1000);
gps_detected = (Serial1.available() > 0);
}
#endifThis gives GPS modules up to 5 seconds to start sending NMEA data, returning early as soon as data is detected (no wasted boot time for fast modules). The reset pulse (currently 10ms) could also be extended to 50-100ms for broader module compatibility.
An even more robust approach would be to not permanently disable GPS on detection failure — allow users to manually enable it via settings even if auto-detection missed it.
Related
- Update RTC from GPS #1426 — Update RTC from GPS
- Enable GPS time sync for Station G2 repeater builds 🤖🤖 #2255 — Station G2 repeater GPS fix (per-variant flag workaround)
- Enable GPS time sync for ThinkNode M1 repeater builds 🤖🤖 #2256 — ThinkNode M1 repeater GPS fix (per-variant flag workaround)
- GPS not working on SenseCAP Solar Node P1-Pro with Repeater Firmware v1.11.0 #1503 — GPS not working on SenseCAP repeater firmware
- Reddit discussion: https://www.reddit.com/r/meshcore/comments/1qyoxh2/can_you_use_gps_on_a_repeater/