Basic GPS message parser

Fork of GPS by Simon Ford

Revision:
3:ac28455d8e5a
Parent:
2:8c97b7918a94
--- a/GPS.cpp	Mon Feb 15 20:56:20 2016 +0000
+++ b/GPS.cpp	Tue Aug 22 15:23:05 2017 +0000
@@ -25,13 +25,16 @@
 GPS::GPS(PinName tx, PinName rx, int baudrate) : _gps(tx, rx) {
     _gps.baud(baudrate);    
     longitude = 0.0;
-    latitude = 0.0;        
+    latitude = 0.0;
+    altitude = 0.0;
 }
 
 int GPS::sample() {
     //float time;
     char ns, ew;
     int lock;
+    int satsInUse;
+    float hdop;
 
     while(1) {        
         getline();
@@ -41,10 +44,11 @@
         // Position -1.929107, 51.407211
         //          51.4136298,-1.2670097
         //Position -1.262323, 51.407383
-        if(sscanf(msg, "GPGGA,%f,%f,%c,%f,%c,%d", &time, &latitude, &ns, &longitude, &ew, &lock) >= 1) { 
+        if(sscanf(msg, "GPGGA,%f,%f,%c,%f,%c,%d,%d,%f,%f", &time, &latitude, &ns, &longitude, &ew, &lock, &satsInUse, &hdop, &altitude) >= 1) { 
             if(!lock) {
                 longitude = 0.0;
-                latitude = 0.0;        
+                latitude = 0.0;
+                altitude = 0;
                 return 0;
             } else {
                 //printf("%s\n\r",msg);