main.cpp
838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#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;
}
}
}