u-blox / Mbed 2 deprecated Cellular_m2x-demo-all

Dependencies:   C027_Support M2XStreamClient jsonlite mbed-rtos mbed

Fork of Cellular_m2x-demo-all by Michael Ammann

Revision:
14:fa2f402e4ce8
Parent:
13:b04452198625
Child:
16:5f9a8ea108bb
--- a/main.cpp	Wed Oct 01 09:23:57 2014 +0000
+++ b/main.cpp	Fri Dec 12 07:58:00 2014 +0000
@@ -68,14 +68,18 @@
     while ((ret = gps.getMessage(buf, sizeof(buf))) > 0) {
         int len = LENGTH(ret);
         if ((PROTOCOL(ret) == GPSParser::NMEA) && (len > 6)) {
-            if (!strncmp("$GPGGA", buf, 6)) {
-                char ch;
-                if (gps.getNmeaAngle(2,buf,len,latitude) && 
-                    gps.getNmeaAngle(4,buf,len,longitude) && 
-                    gps.getNmeaItem(6,buf,len,ch) &&
-                    gps.getNmeaItem(9,buf,len,elevation)) {
-                   printf("GPS Location: %.5f %.5f %.1f %c\r\n", latitude, longitude, elevation, ch); 
-                   location_valid = ch == '1' || ch == '2' || ch == '6';
+            // talker is $GA=Galileo $GB=Beidou $GL=Glonass $GN=Combined $GP=GPS
+            if ((buf[0] == '$') || buf[1] == 'G') {
+                #define _CHECK_TALKER(s) ((buf[3] == s[0]) && (buf[4] == s[1]) && (buf[5] == s[2]))
+                if (_CHECK_TALKER("GLL")) {
+                    char ch;
+                    if (gps.getNmeaAngle(2,buf,len,latitude) && 
+                        gps.getNmeaAngle(4,buf,len,longitude) && 
+                        gps.getNmeaItem(6,buf,len,ch) &&
+                        gps.getNmeaItem(9,buf,len,elevation)) {
+                       printf("GPS Location: %.5f %.5f %.1f %c\r\n", latitude, longitude, elevation, ch); 
+                       location_valid = ch == '1' || ch == '2' || ch == '6';
+                    }
                 }
             }
         }