Added support for the GSA sentence

This commit is contained in:
Bas Rijniersce 2019-10-31 14:05:02 -07:00
parent 5c2ddda5c2
commit ebde856657
2 changed files with 147 additions and 13 deletions

View File

@ -204,6 +204,136 @@ boolean Adafruit_GPS::parse(char *nmea) {
return true;
}
if (strStartsWith(nmea, "$GPRMC") || strStartsWith(nmea, "$GNRMC")) {
// found RMC
// get time
p = strchr(p, ',')+1;
parseTime(p);
// fix or no fix
p = strchr(p, ',')+1;
if(!parseFix(p)) return false;
// parse out latitude
p = strchr(p, ',')+1;
parseLat(p);
p = strchr(p, ',')+1;
if(!parseLatDir(p)) return false;
// parse out longitude
p = strchr(p, ',')+1;
parseLon(p);
p = strchr(p, ',')+1;
if(!parseLonDir(p)) return false;
// speed
p = strchr(p, ',')+1;
if (',' != *p)
{
speed = atof(p);
}
// angle
p = strchr(p, ',')+1;
if (',' != *p)
{
angle = atof(p);
}
p = strchr(p, ',')+1;
if (',' != *p)
{
uint32_t fulldate = atof(p);
day = fulldate / 10000;
month = (fulldate % 10000) / 100;
year = (fulldate % 100);
lastDate = sentTime;
}
return true;
}
if (strStartsWith(nmea, "$GPGLL") || strStartsWith(nmea, "$GNGLL")) {
// found GLL
// parse out latitude
p = strchr(p, ',')+1;
parseLat(p);
p = strchr(p, ',')+1;
if(!parseLatDir(p)) return false;
// parse out longitude
p = strchr(p, ',')+1;
parseLon(p);
p = strchr(p, ',')+1;
if(!parseLonDir(p)) return false;
// get time
p = strchr(p, ',')+1;
parseTime(p);
// fix or no fix
p = strchr(p, ',')+1;
if(!parseFix(p)) return false;
return true;
}
if (strStartsWith(nmea, "$GPGSA")) {
// found GSA
// parse out Auto selection, but ignore them
p = strchr(p, ',')+1;
// parse out 3d fixquality
p = strchr(p, ',')+1;
if (',' != *p)
{
fixquality_3d = atoi(p);
}
// parse out Satellite PDNs, but ignore them
p = strchr(p, ',')+1;
p = strchr(p, ',')+1;
p = strchr(p, ',')+1;
p = strchr(p, ',')+1;
p = strchr(p, ',')+1;
p = strchr(p, ',')+1;
p = strchr(p, ',')+1;
p = strchr(p, ',')+1;
p = strchr(p, ',')+1;
p = strchr(p, ',')+1;
p = strchr(p, ',')+1;
p = strchr(p, ',')+1;
//parse out PDOP
p = strchr(p, ',')+1;
if (',' != *p)
{
PDOP = atof(p);
}
// parse out HDOP, we also parse this from the GGA sentence. Chipset should report the same for both
p = strchr(p, ',')+1;
if (',' != *p)
{
HDOP = atof(p);
}
// parse out VDOP
p = strchr(p, ',')+1;
if (',' != *p)
{
VDOP = atof(p);
}
return true;
}
// we dont parse the remaining, yet!
return false;
}
@ -573,12 +703,12 @@ void Adafruit_GPS::common_init(void) {
lastline = line2;
hour = minute = seconds = year = month = day =
fixquality = satellites = 0; // uint8_t
fixquality = fixquality_3d = satellites = 0; // uint8_t
lat = lon = mag = 0; // char
fix = false; // boolean
milliseconds = 0; // uint16_t
latitude = longitude = geoidheight = altitude =
speed = angle = magvariation = HDOP = 0.0; // float
speed = angle = magvariation = HDOP = VDOP = PDOP = 0.0; // float
}
/**************************************************************************/

View File

@ -66,6 +66,7 @@
#define PMTK_SET_NMEA_OUTPUT_GSAONLY "$PMTK314,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29" ///< turn on just the GPGSA
#define PMTK_SET_NMEA_OUTPUT_GSVONLY "$PMTK314,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0*29" ///< turn on just the GPGSV
#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28" ///< turn on GPRMC and GPGGA
#define PMTK_SET_NMEA_OUTPUT_RMCGGAGSA "$PMTK314,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29" ///< turn on GPRMC, GPGGA and GPGSA
#define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28" ///< turn on ALL THE DATA
#define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28" ///< turn off output
@ -159,11 +160,14 @@ class Adafruit_GPS : public Print{
float angle; ///< Course in degrees from true north
float magvariation; ///< Magnetic variation in degrees (vs. true north)
float HDOP; ///< Horizontal Dilution of Precision - relative accuracy of horizontal position
float VDOP; ///< Vertical Dilution of Precision - relative accuracy of vertical position
float PDOP; ///< Position Dilution of Precision - Complex maths derives a simple, single number for each kind of DOP
char lat; ///< N/S
char lon; ///< E/W
char mag; ///< Magnetic variation direction
boolean fix; ///< Have a fix?
uint8_t fixquality; ///< Fix quality (0, 1, 2 = Invalid, GPS, DGPS)
uint8_t fixquality_3d; ///< 3D fix quality (1, 3, 3 = Nofix, 2D fix, 3D fix)
uint8_t satellites; ///< Number of satellites in use
boolean waitForSentence(const char *wait, uint8_t max = MAXWAITSENTENCE, boolean usingInterrupts = false);