Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 469e864

Browse files
authored
Merge pull request #142 from dotMorten/dotMorten/fixstatus
Add gnssfix valid status and whether differential has been applied
2 parents dca757f + e36415a commit 469e864

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/SparkFun_Ublox_Arduino_Library.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,8 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
982982
gpsNanosecond = extractLong(16); //Includes milliseconds
983983

984984
fixType = extractByte(20 - startingSpot);
985+
gnssFixOk = extractByte(21 - startingSpot) & 0x1; //Get the 1st bit
986+
diffSoln = extractByte(21 - startingSpot) >> 1 & 0x1; //Get the 2nd bit
985987
carrierSolution = extractByte(21 - startingSpot) >> 6; //Get 6th&7th bits of this byte
986988
SIV = extractByte(23 - startingSpot);
987989
longitude = extractLong(24 - startingSpot);
@@ -1005,6 +1007,8 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
10051007
moduleQueried.gpsNanosecond = true;
10061008

10071009
moduleQueried.all = true;
1010+
moduleQueried.gnssFixOk = true;
1011+
moduleQueried.diffSoln = true;
10081012
moduleQueried.longitude = true;
10091013
moduleQueried.latitude = true;
10101014
moduleQueried.altitude = true;
@@ -3548,6 +3552,28 @@ uint8_t SFE_UBLOX_GPS::getFixType(uint16_t maxWait)
35483552
return (fixType);
35493553
}
35503554

3555+
//Get whether we have a valid fix (i.e within DOP & accuracy masks)
3556+
bool SFE_UBLOX_GPS::getGnssFixOk(uint16_t maxWait)
3557+
{
3558+
if (moduleQueried.gnssFixOk == false)
3559+
getPVT(maxWait);
3560+
moduleQueried.gnssFixOk = false; //Since we are about to give this to user, mark this data as stale
3561+
moduleQueried.all = false;
3562+
3563+
return (gnssFixOk);
3564+
}
3565+
3566+
//Get whether differential corrections were applied
3567+
bool SFE_UBLOX_GPS::getDiffSoln(uint16_t maxWait)
3568+
{
3569+
if (moduleQueried.diffSoln == false)
3570+
getPVT(maxWait);
3571+
moduleQueried.diffSoln = false; //Since we are about to give this to user, mark this data as stale
3572+
moduleQueried.all = false;
3573+
3574+
return (diffSoln);
3575+
}
3576+
35513577
//Get the carrier phase range solution status
35523578
//Useful when querying module to see if it has high-precision RTK fix
35533579
//0=No solution, 1=Float solution, 2=Fixed solution
@@ -3680,6 +3706,8 @@ void SFE_UBLOX_GPS::flushPVT()
36803706
moduleQueried.gpsNanosecond = false;
36813707

36823708
moduleQueried.all = false;
3709+
moduleQueried.gnssFixOk = false;
3710+
moduleQueried.diffSoln = false;
36833711
moduleQueried.longitude = false;
36843712
moduleQueried.latitude = false;
36853713
moduleQueried.altitude = false;

src/SparkFun_Ublox_Arduino_Library.h

+7
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ class SFE_UBLOX_GPS
509509
void flushHPPOSLLH(); //Mark all the PVT data as read/stale. This is handy to get data alignment after CRC failure
510510
void flushDOP(); //Mark all the DOP data as read/stale. This is handy to get data alignment after CRC failure
511511

512+
bool getGnssFixOk(uint16_t maxWait = getPVTmaxWait); //Get whether we have a valid fix (i.e within DOP & accuracy masks)
513+
bool getDiffSoln(uint16_t maxWait = getPVTmaxWait); //Get whether differential corrections were applied
512514
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.
513515
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.
514516
int32_t getAltitude(uint16_t maxWait = getPVTmaxWait); //Returns the current altitude in mm above ellipsoid
@@ -700,6 +702,9 @@ class SFE_UBLOX_GPS
700702
bool gpsDateValid;
701703
bool gpsTimeValid;
702704

705+
706+
bool gnssFixOk; //valid fix (i.e within DOP & accuracy masks)
707+
bool diffSoln; //Differential corrections were applied
703708
int32_t latitude; //Degrees * 10^-7 (more accurate than floats)
704709
int32_t longitude; //Degrees * 10^-7 (more accurate than floats)
705710
int32_t altitude; //Number of mm above ellipsoid
@@ -897,6 +902,8 @@ uint16_t eastingDOP; // Easting dilution of precision * 10^-2
897902
uint32_t gpsNanosecond : 1;
898903

899904
uint32_t all : 1;
905+
uint32_t gnssFixOk : 1;
906+
uint32_t diffSoln : 1;
900907
uint32_t longitude : 1;
901908
uint32_t latitude : 1;
902909
uint32_t altitude : 1;

0 commit comments

Comments
 (0)