Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C027_Support
Fork of C027_SupportTest by
Diff: main.cpp
- Revision:
- 27:fe3b383dd4ec
- Parent:
- 24:81f5b43a6585
- Child:
- 28:334263983fcd
diff -r 59ed90c2efe0 -r fe3b383dd4ec main.cpp
--- a/main.cpp Wed Oct 01 09:19:33 2014 +0000
+++ b/main.cpp Fri Dec 12 07:50:45 2014 +0000
@@ -48,7 +48,7 @@
#endif
// Create the modem object
MDMSerial mdm;
- //mdm.setDebug(4); // enable this for debugging issues
+ mdm.setDebug(4); // enable this for debugging issues
// initialize the modem
MDMParser::DevStatus devStatus = {};
MDMParser::NetStatus netStatus = {};
@@ -86,7 +86,9 @@
// join the internet connection
MDMParser::IP ip = mdm.join(APN,USERNAME,PASSWORD);
- if (ip != NOIP)
+ if (ip == NOIP)
+ printf("Not joined");
+ else
{
mdm.dumpIp(ip);
printf("Make a Http Post Request\r\n");
@@ -193,25 +195,29 @@
//printf("NMEA: %.*s\r\n", len-2, msg);
if ((PROTOCOL(ret) == GPSParser::NMEA) && (len > 6))
{
- if (!strncmp("$GPGLL", buf, 6)) {
- double la = 0, lo = 0;
- char ch;
- if (gps.getNmeaAngle(1,buf,len,la) &&
- gps.getNmeaAngle(3,buf,len,lo) &&
- gps.getNmeaItem(6,buf,len,ch) && ch == 'A')
- {
- printf("GPS Location: %.5f %.5f\r\n", la, lo);
- sprintf(link, "I am here!\n"
- "https://maps.google.com/?q=%.5f,%.5f", la, lo);
+ // talker is $GA=Galileo $GB=Beidou $GL=Glonass $GN=Combined $GP=GPS
+ if ((buf[0] == '$') || buf[1] == 'G') {
+ #define _CHECK_TALKER(s) ((buf[3] == s[0]) && (buf[4] == s[1]) && (buf[5] == s[2]))
+ if (_CHECK_TALKER("GLL")) {
+ double la = 0, lo = 0;
+ char ch;
+ if (gps.getNmeaAngle(1,buf,len,la) &&
+ gps.getNmeaAngle(3,buf,len,lo) &&
+ gps.getNmeaItem(6,buf,len,ch) && ch == 'A')
+ {
+ printf("GPS Location: %.5f %.5f\r\n", la, lo);
+ sprintf(link, "I am here!\n"
+ "https://maps.google.com/?q=%.5f,%.5f", la, lo);
+ }
+ } else if (_CHECK_TALKER("GGA") || _CHECK_TALKER("GNS") ) {
+ double a = 0;
+ if (gps.getNmeaItem(9,buf,len,a)) // altitude msl [m]
+ printf("GPS Altitude: %.1f\r\n", a);
+ } else if (_CHECK_TALKER("VTG")) {
+ double s = 0;
+ if (gps.getNmeaItem(7,buf,len,s)) // speed [km/h]
+ printf("GPS Speed: %.1f\r\n", s);
}
- } else if (!strncmp("$GPGGA", buf, 6)) {
- double a = 0;
- if (gps.getNmeaItem(9,buf,len,a)) // altitude msl [m]
- printf("GPS Altitude: %.1f\r\n", a);
- } else if (!strncmp("$GPVTG", buf, 6)) {
- double s = 0;
- if (gps.getNmeaItem(7,buf,len,s)) // speed [km/h]
- printf("GPS Speed: %.1f\r\n", s);
}
}
}
