GPSlibrary

Revision:
0:3d25bc7ff80e
Child:
1:432f77f0d864
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPS.cpp	Tue Jul 16 12:07:09 2019 +0000
@@ -0,0 +1,54 @@
+#include "GPS.h"
+#include "mbed.h"
+
+
+GPS::GPS(PinName tx, PinName rx):gps(tx,rx)
+{
+    _tx=tx;
+    _rx=rx;
+
+}
+
+int GPS::getGPGGA()
+{
+    //Serial gps(_tx,_rx);
+    gps.baud(9600);
+    //Serial pc(USBTX,USBRX);
+    //pc.baud(9600);
+
+    char recvGPS=0;
+    char getGPS[128];
+    //char GPSMessage[128];
+    int i=0;
+    
+
+    if(gps.readable()) {
+
+        recvGPS=gps.getc();
+        getGPS[i]=recvGPS;
+
+        if(getGPS[i]==10) {
+
+            if((getGPS[5]==71)&&(getGPS[6]==65)) {
+
+                for(int n=0; n<i+1; n++) {
+
+                    GPSMessage[n] = getGPS[n];
+                
+                    
+                }
+            return 1;
+
+            }
+
+            i=0;
+
+        }
+
+        i++;
+    }
+
+    //char eGPSMessage[]= "Could not get GPS data!";
+    return 0;
+
+}
\ No newline at end of file