Nile Mittow / Mbed 2 deprecated HL_GwoopsGPS_Example

Dependencies:   mbed

Fork of HL_GPS_Example by Nile Mittow

Revision:
21:dfa20810d1d0
Parent:
20:a728f1075fb1
Child:
22:9551b2ce17c9
--- a/main.cpp	Tue Mar 14 21:22:36 2017 +0000
+++ b/main.cpp	Thu Mar 16 23:10:57 2017 +0000
@@ -1,81 +1,20 @@
 #include "mbed.h"
-#include "GPRMCSentence.h"
+#include "GwoopsGPS.h"
 
 #define GPSBUFFSIZE 256
 
 Serial pc(USBTX, USBRX); // tx, rx
-Serial xgps(PTC15, PTC14);
-// If using MODSERIAL (as part of the WNC Interface for the AT&T IoT Starter Kit):
-// MODSERIAL xgps(PTC15, PTC14, GPSBUFFSIZE, GPSBUFFSIZE);
+Serial sgps(PTC15, PTC14, 9600);
 
-unsigned gpsSentenceIndex = 0;
-char gpsSentence[GPSBUFFSIZE];
-GPRMCSentence lastPosition;
-
-void clearGpsSentence() {
-    for(int i=0;i<GPSBUFFSIZE;i++) gpsSentence[i] = '\0';
-    gpsSentenceIndex = 0;
-}
  
 int main() {
-    pc.printf("Where am I? ----------- \n");
-    clearGpsSentence();
+    pc.printf("Where am I? ----------- \n\r");
+    GwoopsGPS xgps(&sgps);
     while(1) {
-        gpsSentence[gpsSentenceIndex] = xgps.getc();
-        //pc.putc(gpsSentence[gpsSentenceIndex]);
-        gpsSentenceIndex++;
-        if(gpsSentence[gpsSentenceIndex - 1] == '\n') {
-            gpsSentence[gpsSentenceIndex] = '\0';
-            if (parseGPRMCStrToStruct(gpsSentence, &lastPosition) >= 0) {
-                pc.printf("time: %s Status: %c \n\r" , lastPosition.time, lastPosition.status);
-                pc.printf("Lat : %s %c \n\r" , lastPosition.latitude, lastPosition.latdir);
-                pc.printf("Long: %s %c \n\r" , lastPosition.longitude, lastPosition.longdir);
-            }
-            clearGpsSentence();
+        if (xgps.isValid()) {
+            pc.printf("\r\n");
+            xgps.printData(&pc);
         }
+        else pc.printf(".");
     }
 }
-
-
-/*include "mbed.h"
-
-DigitalOut rled(LED_RED);
-DigitalOut gled(LED_GREEN);
-DigitalOut bled(LED_BLUE);
-
-int main() {
-    while(1) {
-        rled = 0;
-        gled = 0;
-        bled = 0;
-        wait(0.2);
-        rled = 0;
-        gled = 0;
-        bled = 1;
-        wait(0.2);
-        rled = 0;
-        gled = 1;
-        bled = 0;
-        wait(0.2);
-        rled = 0;
-        gled = 1;
-        bled = 1;
-        wait(0.2);
-        rled = 1;
-        gled = 0;
-        bled = 0;
-        wait(0.2);
-        rled = 1;
-        gled = 0;
-        bled = 1;
-        wait(0.2);
-        rled = 1;
-        gled = 1;
-        bled = 0;
-        wait(0.2);
-        rled = 1;
-        gled = 1;
-        bled = 1;
-        wait(0.2);
-    }
-}*/