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

Commit e36415a

Browse files
committed
Add gnssfix valid status and whether differential has been applied
1 parent 97bd455 commit e36415a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,8 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
980980
gpsNanosecond = extractLong(16); //Includes milliseconds
981981

982982
fixType = extractByte(20 - startingSpot);
983+
gnssFixOk = extractByte(21 - startingSpot) & 0x1; //Get the 1st bit
984+
diffSoln = extractByte(21 - startingSpot) >> 1 & 0x1; //Get the 2nd bit
983985
carrierSolution = extractByte(21 - startingSpot) >> 6; //Get 6th&7th bits of this byte
984986
SIV = extractByte(23 - startingSpot);
985987
longitude = extractLong(24 - startingSpot);
@@ -1003,6 +1005,8 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
10031005
moduleQueried.gpsNanosecond = true;
10041006

10051007
moduleQueried.all = true;
1008+
moduleQueried.gnssFixOk = true;
1009+
moduleQueried.diffSoln = true;
10061010
moduleQueried.longitude = true;
10071011
moduleQueried.latitude = true;
10081012
moduleQueried.altitude = true;
@@ -3333,6 +3337,28 @@ uint8_t SFE_UBLOX_GPS::getFixType(uint16_t maxWait)
33333337
return (fixType);
33343338
}
33353339

3340+
//Get whether we have a valid fix (i.e within DOP & accuracy masks)
3341+
bool SFE_UBLOX_GPS::getGnssFixOk(uint16_t maxWait)
3342+
{
3343+
if (moduleQueried.gnssFixOk == false)
3344+
getPVT(maxWait);
3345+
moduleQueried.gnssFixOk = false; //Since we are about to give this to user, mark this data as stale
3346+
moduleQueried.all = false;
3347+
3348+
return (gnssFixOk);
3349+
}
3350+
3351+
//Get whether differential corrections were applied
3352+
bool SFE_UBLOX_GPS::getDiffSoln(uint16_t maxWait)
3353+
{
3354+
if (moduleQueried.diffSoln == false)
3355+
getPVT(maxWait);
3356+
moduleQueried.diffSoln = false; //Since we are about to give this to user, mark this data as stale
3357+
moduleQueried.all = false;
3358+
3359+
return (diffSoln);
3360+
}
3361+
33363362
//Get the carrier phase range solution status
33373363
//Useful when querying module to see if it has high-precision RTK fix
33383364
//0=No solution, 1=Float solution, 2=Fixed solution
@@ -3465,6 +3491,8 @@ void SFE_UBLOX_GPS::flushPVT()
34653491
moduleQueried.gpsNanosecond = false;
34663492

34673493
moduleQueried.all = false;
3494+
moduleQueried.gnssFixOk = false;
3495+
moduleQueried.diffSoln = false;
34683496
moduleQueried.longitude = false;
34693497
moduleQueried.latitude = false;
34703498
moduleQueried.altitude = false;

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,8 @@ class SFE_UBLOX_GPS
504504
void flushPVT(); //Mark all the PVT data as read/stale. This is handy to get data alignment after CRC failure
505505
void flushHPPOSLLH(); //Mark all the PVT data as read/stale. This is handy to get data alignment after CRC failure
506506

507+
bool getGnssFixOk(uint16_t maxWait = getPVTmaxWait); //Get whether we have a valid fix (i.e within DOP & accuracy masks)
508+
bool getDiffSoln(uint16_t maxWait = getPVTmaxWait); //Get whether differential corrections were applied
507509
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.
508510
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.
509511
int32_t getAltitude(uint16_t maxWait = getPVTmaxWait); //Returns the current altitude in mm above ellipsoid
@@ -687,6 +689,9 @@ class SFE_UBLOX_GPS
687689
bool gpsDateValid;
688690
bool gpsTimeValid;
689691

692+
693+
bool gnssFixOk; //valid fix (i.e within DOP & accuracy masks)
694+
bool diffSoln; //Differential corrections were applied
690695
int32_t latitude; //Degrees * 10^-7 (more accurate than floats)
691696
int32_t longitude; //Degrees * 10^-7 (more accurate than floats)
692697
int32_t altitude; //Number of mm above ellipsoid
@@ -873,6 +878,8 @@ class SFE_UBLOX_GPS
873878
uint32_t gpsNanosecond : 1;
874879

875880
uint32_t all : 1;
881+
uint32_t gnssFixOk : 1;
882+
uint32_t diffSoln : 1;
876883
uint32_t longitude : 1;
877884
uint32_t latitude : 1;
878885
uint32_t altitude : 1;

0 commit comments

Comments
 (0)