From e36415a153363f55677bc014d2671774a2f5bbf6 Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Thu, 29 Oct 2020 15:30:51 -0700 Subject: [PATCH] Add gnssfix valid status and whether differential has been applied --- src/SparkFun_Ublox_Arduino_Library.cpp | 28 ++++++++++++++++++++++++++ src/SparkFun_Ublox_Arduino_Library.h | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index 81994a1..e286540 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -980,6 +980,8 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg) gpsNanosecond = extractLong(16); //Includes milliseconds fixType = extractByte(20 - startingSpot); + gnssFixOk = extractByte(21 - startingSpot) & 0x1; //Get the 1st bit + diffSoln = extractByte(21 - startingSpot) >> 1 & 0x1; //Get the 2nd bit carrierSolution = extractByte(21 - startingSpot) >> 6; //Get 6th&7th bits of this byte SIV = extractByte(23 - startingSpot); longitude = extractLong(24 - startingSpot); @@ -1003,6 +1005,8 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg) moduleQueried.gpsNanosecond = true; moduleQueried.all = true; + moduleQueried.gnssFixOk = true; + moduleQueried.diffSoln = true; moduleQueried.longitude = true; moduleQueried.latitude = true; moduleQueried.altitude = true; @@ -3333,6 +3337,28 @@ uint8_t SFE_UBLOX_GPS::getFixType(uint16_t maxWait) return (fixType); } +//Get whether we have a valid fix (i.e within DOP & accuracy masks) +bool SFE_UBLOX_GPS::getGnssFixOk(uint16_t maxWait) +{ + if (moduleQueried.gnssFixOk == false) + getPVT(maxWait); + moduleQueried.gnssFixOk = false; //Since we are about to give this to user, mark this data as stale + moduleQueried.all = false; + + return (gnssFixOk); +} + +//Get whether differential corrections were applied +bool SFE_UBLOX_GPS::getDiffSoln(uint16_t maxWait) +{ + if (moduleQueried.diffSoln == false) + getPVT(maxWait); + moduleQueried.diffSoln = false; //Since we are about to give this to user, mark this data as stale + moduleQueried.all = false; + + return (diffSoln); +} + //Get the carrier phase range solution status //Useful when querying module to see if it has high-precision RTK fix //0=No solution, 1=Float solution, 2=Fixed solution @@ -3465,6 +3491,8 @@ void SFE_UBLOX_GPS::flushPVT() moduleQueried.gpsNanosecond = false; moduleQueried.all = false; + moduleQueried.gnssFixOk = false; + moduleQueried.diffSoln = false; moduleQueried.longitude = false; moduleQueried.latitude = false; moduleQueried.altitude = false; diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index 8feadfc..bc81953 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -504,6 +504,8 @@ class SFE_UBLOX_GPS void flushPVT(); //Mark all the PVT data as read/stale. This is handy to get data alignment after CRC failure void flushHPPOSLLH(); //Mark all the PVT data as read/stale. This is handy to get data alignment after CRC failure + bool getGnssFixOk(uint16_t maxWait = getPVTmaxWait); //Get whether we have a valid fix (i.e within DOP & accuracy masks) + bool getDiffSoln(uint16_t maxWait = getPVTmaxWait); //Get whether differential corrections were applied int32_t getLatitude(uint16_t maxWait = getPVTmaxWait); //Returns the current latitude in degrees * 10^-7. Auto selects between HighPrecision and Regular depending on ability of module. int32_t getLongitude(uint16_t maxWait = getPVTmaxWait); //Returns the current longitude in degrees * 10-7. Auto selects between HighPrecision and Regular depending on ability of module. int32_t getAltitude(uint16_t maxWait = getPVTmaxWait); //Returns the current altitude in mm above ellipsoid @@ -687,6 +689,9 @@ class SFE_UBLOX_GPS bool gpsDateValid; bool gpsTimeValid; + + bool gnssFixOk; //valid fix (i.e within DOP & accuracy masks) + bool diffSoln; //Differential corrections were applied int32_t latitude; //Degrees * 10^-7 (more accurate than floats) int32_t longitude; //Degrees * 10^-7 (more accurate than floats) int32_t altitude; //Number of mm above ellipsoid @@ -873,6 +878,8 @@ class SFE_UBLOX_GPS uint32_t gpsNanosecond : 1; uint32_t all : 1; + uint32_t gnssFixOk : 1; + uint32_t diffSoln : 1; uint32_t longitude : 1; uint32_t latitude : 1; uint32_t altitude : 1;