Move variant-specific lines back to variant (#6044)
Some checks are pending
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32-s3 (push) Blocked by required conditions
CI / build-esp32-c3 (push) Blocked by required conditions
CI / build-esp32-c6 (push) Blocked by required conditions
CI / build-nrf52 (push) Blocked by required conditions
CI / build-rpi2040 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / build-debian-src (push) Waiting to run
CI / package-pio-deps-native (push) Waiting to run
CI / test-native (push) Waiting to run
CI / docker-debian-amd64 (push) Waiting to run
CI / docker-alpine-amd64 (push) Waiting to run
CI / docker-debian-arm64 (push) Waiting to run
CI / docker-debian-armv7 (push) Waiting to run
CI / after-checks (push) Blocked by required conditions
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
Flawfinder Scan / Flawfinder (push) Waiting to run

Last release a change introduced different branching functions in
gps.cpp based on the model of a device. This makes the code less
readable and introduces the potential for bugs.

This patch creates a new variable, GPS_PROBETRIES that can be set
in variant.h of devices that will control how many times we will
probe for GPS presence. It sets up the T1000-E to use this variable
and cleans the code in gps.c
This commit is contained in:
Tom Fifield 2025-02-20 21:48:37 +08:00 committed by GitHub
parent 994e22aba9
commit ec0eafedab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 10 deletions

View File

@ -437,6 +437,10 @@ static const int serialSpeeds[3] = {9600, 115200, 38400};
static const int rareSerialSpeeds[3] = {4800, 57600, GPS_BAUDRATE}; static const int rareSerialSpeeds[3] = {4800, 57600, GPS_BAUDRATE};
#endif #endif
#ifndef GPS_PROBETRIES
#define GPS_PROBETRIES 2
#endif
/** /**
* @brief Setup the GPS based on the model detected. * @brief Setup the GPS based on the model detected.
* We detect the GPS by cycling through a set of baud rates, first common then rare. * We detect the GPS by cycling through a set of baud rates, first common then rare.
@ -460,11 +464,7 @@ bool GPS::setup()
digitalWrite(PIN_GPS_EN, HIGH); digitalWrite(PIN_GPS_EN, HIGH);
delay(1000); delay(1000);
#endif #endif
#ifdef TRACKER_T1000_E if (probeTries < GPS_PROBETRIES) {
if (probeTries < 5) {
#else
if (probeTries < 2) {
#endif
LOG_DEBUG("Probe for GPS at %d", serialSpeeds[speedSelect]); LOG_DEBUG("Probe for GPS at %d", serialSpeeds[speedSelect]);
gnssModel = probe(serialSpeeds[speedSelect]); gnssModel = probe(serialSpeeds[speedSelect]);
if (gnssModel == GNSS_MODEL_UNKNOWN) { if (gnssModel == GNSS_MODEL_UNKNOWN) {
@ -475,11 +475,7 @@ bool GPS::setup()
} }
} }
// Rare Serial Speeds // Rare Serial Speeds
#ifdef TRACKER_T1000_E if (probeTries == GPS_PROBETRIES) {
if (probeTries == 5) {
#else
if (probeTries == 2) {
#endif
LOG_DEBUG("Probe for GPS at %d", rareSerialSpeeds[speedSelect]); LOG_DEBUG("Probe for GPS at %d", rareSerialSpeeds[speedSelect]);
gnssModel = probe(rareSerialSpeeds[speedSelect]); gnssModel = probe(rareSerialSpeeds[speedSelect]);
if (gnssModel == GNSS_MODEL_UNKNOWN) { if (gnssModel == GNSS_MODEL_UNKNOWN) {

View File

@ -111,6 +111,7 @@ extern "C" {
#define GPS_TX_PIN PIN_SERIAL1_TX #define GPS_TX_PIN PIN_SERIAL1_TX
#define GPS_BAUDRATE 115200 #define GPS_BAUDRATE 115200
#define GPS_PROBETRIES 5
#define PIN_GPS_EN (32 + 11) // P1.11 #define PIN_GPS_EN (32 + 11) // P1.11
#define GPS_EN_ACTIVE HIGH #define GPS_EN_ACTIVE HIGH