From 25841c072a78888441ce153e2c56cfa980351597 Mon Sep 17 00:00:00 2001 From: a-f-G-U-C <65810997+a-f-G-U-C@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:11:11 +0000 Subject: [PATCH 1/2] allow GPS modules to redefine GPS::hasLock() --- src/gps/GPS.cpp | 2 ++ src/gps/GPS.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 4446540a3..0019bf307 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -80,6 +80,8 @@ GPS::~GPS() notifyDeepSleepObserver.unobserve(); } +bool GPS::hasLock() { return hasValidLocation; } + // Allow defining the polarity of the WAKE output. default is active high #ifndef GPS_WAKE_ACTIVE #define GPS_WAKE_ACTIVE 1 diff --git a/src/gps/GPS.h b/src/gps/GPS.h index 6de72f29c..63d594863 100644 --- a/src/gps/GPS.h +++ b/src/gps/GPS.h @@ -57,8 +57,8 @@ class GPS : private concurrency::OSThread */ virtual bool setup(); - /// Returns ture if we have acquired GPS lock. - bool hasLock() const { return hasValidLocation; } + /// Returns true if we have acquired GPS lock. + virtual bool hasLock(); /// Return true if we are connected to a GPS bool isConnected() const { return hasGPS; } From 5cf1a8765707525916b8d54dee65432ae93475a0 Mon Sep 17 00:00:00 2001 From: a-f-G-U-C <65810997+a-f-G-U-C@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:21:48 +0000 Subject: [PATCH 2/2] redefine hasLock() for UBlox GPS --- src/gps/UBloxGPS.cpp | 5 +++++ src/gps/UBloxGPS.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/gps/UBloxGPS.cpp b/src/gps/UBloxGPS.cpp index aae4ecc35..2da2a21a8 100644 --- a/src/gps/UBloxGPS.cpp +++ b/src/gps/UBloxGPS.cpp @@ -196,6 +196,11 @@ bool UBloxGPS::lookForLocation() return foundLocation; } +bool UBloxGPS::hasLock() +{ + return (fixType >= 3 && fixType <= 4); +} + bool UBloxGPS::whileIdle() { // if using i2c or serial look too see if any chars are ready diff --git a/src/gps/UBloxGPS.h b/src/gps/UBloxGPS.h index 9fda4bd0e..009744a52 100644 --- a/src/gps/UBloxGPS.h +++ b/src/gps/UBloxGPS.h @@ -54,6 +54,7 @@ class UBloxGPS : public GPS * @return true if we've acquired a new location */ virtual bool lookForLocation(); + virtual bool hasLock(); /// If possible force the GPS into sleep/low power mode virtual void sleep();