Slightly modified version of the SerialGPS library (https://os.mbed.com/teams/components/code/SerialGPS/) to support the BufferedSerial class

Revision:
3:ebd79e3acf14
Parent:
2:e7f24389167b
Child:
4:2c76f1ec13a9
diff -r e7f24389167b -r ebd79e3acf14 SerialGPS.h
--- a/SerialGPS.h	Tue Feb 16 16:48:14 2021 +0100
+++ b/SerialGPS.h	Tue Mar 02 18:27:46 2021 +0100
@@ -25,72 +25,65 @@
 #define MBED_GPS_H
 
 #include "mbed.h"
+#include "BufferedSerial.h"
 
-/**
-*  A SerialGPS interface for reading from a serial GPS module 
-*/
+#define MAX_LINELENGTH 255
+
 class SerialGPS 
 {
     public:
+        SerialGPS(PinName tx, PinName rx, int baud);
 
-        /** Create the SerialGPS interface, connected to the specified serial port and speed.
-        *  for example, GlobalSat EM406-A (e.g. on SparkFun GPS Shield) is 4800 Baud,
-        *  Adafruit Ultimate GPSv3 (connected to serial) is 9600 Baud
-        */    
-        SerialGPS(PinName tx, PinName rx, int baud);
-    
-        /** Sample the incoming GPS data, returning whether there is a lock
-        * 
-        * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0
-        */
-        int sample();
+        SerialGPS(BufferedSerial* serial);
     
         /** 
-        * The longitude (call sample() to set) 
+        * Sample the incoming GPS data
+        */
+        void read();
+    
+        /**
+        * Send PMTK command to GPS
+        *
+        * @param cmd the PMTK command to send to the GPS module
         */
-        float longitude;
+        void send_command(const char* cmd);
+
+        /**
+        * GPS fix
+        *
+        * @return true if the GPS module has acquired fix
+        */ 
+        bool fix();
+
+        /** 
+        * The longitude (call sample() to set) 
+        *
+        * @return _lat the latitude component
+        */
+        float get_lon();
 
         /** 
         * The latitude (call sample() to set) 
-        */
-        float latitude;
-    
-        /** 
-        * The time (call sample() to set) 
-        */
-        float time;
-    
-        /** 
-        * Number of satellites received (call sample() to set) 
-        */
-        int sats;
-    
-        /** 
-        * Horizontal dilusion of precision (call sample() to set) 
+        *
+        * @return _lon the longitude component
         */
-        float hdop;
-    
-        /** The altitude (call sample() to set)
-        *  Note that the accurate altitude is corrected by the geoid
-        *  See http://homepages.slingshot.co.nz/~geoff36/datum.htm
-        */
-        float alt;
-    
-        /** 
-        * The geoid (call sample() to set) 
-        */
-        float  geoid;
-    
-        /** 
-        * The NMEA sentence 
-        */
-        char msg[256];
+        float get_lat();
     
     private:
         float trunc(float v);
         void getline();
+        void set_vals();
+        char read_char();
+
         BufferedSerial* _gps_p;
         BufferedSerial& _gps;
+
+        char _nmea[MAX_LINELENGTH];
+        bool _fix;
+
+        float _UTCtime, _lat, _lon;
+        int _lock;
+        char _status, _NS, _EW;
 };
 
 #endif
\ No newline at end of file