main.cpp 838 Bytes
#include "mbed.h"
#include "GPSDevice.h"
 
#define LENGTH 80
#define BAUD 9600

DigitalOut led1(LED1);
Serial pc(USBTX, USBRX, BAUD);
Serial uart(D8, D2, BAUD);

void readGPGGA();

int main()
{
    pc.printf("starting...");
    GPSDevice gpsDevice(&uart); 
            
    while(1) {
        char type[6];
        if (gpsDevice.canBeRead()){
            gpsDevice.readType(type);
            
            if (strcmp(type, GPGGA) == 0) {
              gpsDevice.readGPGGA();
              
              if(gpsDevice.isReadValid()) {   
                pc.printf("Time : %s\n", gpsDevice.getUTC());
                pc.printf("Latitude : %s N\n", gpsDevice.getLatitude());
                pc.printf("Longitude : %s E\n", gpsDevice.getLongitude());
              }           
            } 
            led1 = !led1;
        }
    }
}