Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: io/GPSTracker.cpp
- Revision:
- 76:b07effe83fb8
- Parent:
- 65:a62dbef2f924
- Child:
- 92:0acd11870c6a
--- a/io/GPSTracker.cpp Wed Feb 18 10:19:51 2015 +0000 +++ b/io/GPSTracker.cpp Wed Feb 25 10:06:11 2015 +0000 @@ -1,6 +1,7 @@ -#include "GPSTracker.h" #include <stdlib.h> #include <string.h> +#include "GPSTracker.h" +#include "logging.h" GPSTracker::GPSTracker(GPSI2C& gps) : _gps(gps), @@ -40,22 +41,29 @@ } len = LENGTH(ret); - if ((PROTOCOL(ret) != GPSParser::NMEA) || (len <= 6)) + if ((PROTOCOL(ret) != GPSParser::NMEA) || (len <= 6)) { + aWarning("GPS data is not in NMEA protocol!\r\n"); continue; + } - // we're only interested in fixed GPS positions - // we are not interested in invalid data - if ((strncmp("$GPGGA", buf, 6) != 0) || - (!_gps.getNmeaItem(6, buf, len, n, 10)) || (n == 0)) + // we're only interested in fixed GPS positions, data type: GPGGA + if ((strncmp("$GPGGA", buf, 6) != 0)) { continue; + } + + if (!_gps.getNmeaItem(6, buf, len, n, 10) || n == 0) { + continue; + } // get altitude, latitude and longitude if ((!_gps.getNmeaAngle(2, buf, len, latitude)) || (!_gps.getNmeaAngle(4, buf, len, longitude)) || (!_gps.getNmeaItem(9, buf, len, altitude)) || (!_gps.getNmeaItem(10, buf, len, chr)) || - (chr != 'M')) + (chr != 'M')) { + aWarning("Unable to retrieve GPS data!\r\n"); continue; + } _mutex.lock(); _position.altitude = altitude;