diff --git a/Adafruit_GPS.cpp b/Adafruit_GPS.cpp index 3c63e68..b1551af 100755 --- a/Adafruit_GPS.cpp +++ b/Adafruit_GPS.cpp @@ -204,6 +204,63 @@ boolean Adafruit_GPS::parse(char *nmea) { 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; } @@ -393,7 +450,7 @@ size_t Adafruit_GPS::available(void) { #if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL) if (gpsSwSerial) { return gpsSwSerial->available(); - } + } #endif if (gpsHwSerial) { return gpsHwSerial->available(); @@ -415,7 +472,7 @@ size_t Adafruit_GPS::write(uint8_t c) { #if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL) if (gpsSwSerial) { return gpsSwSerial->write(c); - } + } #endif if (gpsHwSerial) { return gpsHwSerial->write(c); @@ -447,13 +504,13 @@ char Adafruit_GPS::read(void) { #if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL) if(gpsSwSerial) { - if (!gpsSwSerial->available()) + if (!gpsSwSerial->available()) return c; c = gpsSwSerial->read(); - } + } #endif if (gpsHwSerial) { - if (!gpsHwSerial->available()) + if (!gpsHwSerial->available()) return c; c = gpsHwSerial->read(); } @@ -469,7 +526,7 @@ char Adafruit_GPS::read(void) { char curr_char = 0; for (int i=0; i= MAXLINELENGTH) lineidx = MAXLINELENGTH-1; // ensure there is someplace to put the next received character @@ -573,12 +630,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 } /**************************************************************************/ @@ -593,7 +650,7 @@ bool Adafruit_GPS::begin(uint32_t baud_or_i2caddr) #if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL) if(gpsSwSerial) { gpsSwSerial->begin(baud_or_i2caddr); - } + } #endif if (gpsHwSerial) { gpsHwSerial->begin(baud_or_i2caddr); diff --git a/Adafruit_GPS.h b/Adafruit_GPS.h index 4b6ff01..a65fa59 100644 --- a/Adafruit_GPS.h +++ b/Adafruit_GPS.h @@ -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); @@ -189,8 +193,8 @@ class Adafruit_GPS : public Print{ void parseLon(char *); boolean parseLonDir(char *); boolean parseFix(char *); - // Make all of these times far in the past by setting them near the middle of the - // millis() range. Timing assumes that sentences are parsed promptly. + // Make all of these times far in the past by setting them near the middle of the + // millis() range. Timing assumes that sentences are parsed promptly. uint32_t lastFix = 2000000000L; // millis() when last fix received uint32_t lastTime = 2000000000L; // millis() when last time received uint32_t lastDate = 2000000000L; // millis() when last date received