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

Add gnssfix valid status and whether differential has been applied #142

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down