Skip to content

GPS detection in initBasicGPS() too short — most repeater variants affected #2258

@TerryFrench

Description

@TerryFrench

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);
#endif

Cold-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:

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);
  }
#endif

This 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions