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.
Fork of lib_gps by
Diff: gps.cpp
- Revision:
- 1:2f5fbb33ae8b
- Parent:
- 0:0bd73064b7f6
- Child:
- 2:b531881123bf
--- a/gps.cpp Wed Mar 18 00:55:27 2015 +0000 +++ b/gps.cpp Fri Mar 27 00:41:33 2015 +0000 @@ -1,6 +1,9 @@ #include "mbed.h" #include "gps.h" +#define LAT_UNFIXED 0xaaaaa9 +#define LONG_UNFIXED 0x355554e + const char NmeaDataTypeGPGGA[] = "GPGGA"; //const char NmeaDataTypeGPGSA[] = "GPGSA"; //const char NmeaDataTypeGPGSV[] = "GPGSV"; @@ -18,8 +21,8 @@ GPS::GPS() { - -} + have_fix = false; + } GPS::~GPS() { @@ -76,6 +79,7 @@ void GPS::enable(bool en) { if (en) { +#ifdef SOFT_START /* probably better instead to remove 22uF from GPS VCC */ volatile int d; volatile int i; @@ -106,12 +110,14 @@ asm("nop"); } } +#endif /* SOFT_START */ gps_en = 0; } else { gps_en = 1; } - //gps_en = !en; - //printf("gps_en:%d\n", en); + + // reset current string index + rx_buf_lens[rx_bufs_in_idx] = 0; } bool GPS::enabled() @@ -280,6 +286,12 @@ temp = Longitude * MaxWestPosition; LongitudeBinary = temp / 180; } + + //printf("binary: %x %x\r\n", LatitudeBinary, LongitudeBinary); + if (LatitudeBinary == LAT_UNFIXED && LongitudeBinary == LONG_UNFIXED) + have_fix = false; + else + have_fix = true; } int GPS::ParseGPSData(int idx) @@ -294,13 +306,19 @@ } NmeaString = rx_bufs[idx]; + + if (NmeaString[0] == 'P' && NmeaString[1] == 'M' && NmeaString[2] == 'T' && NmeaString[3] == 'K') { + /* anything useful from PMTK packets? */ + return SUCCESS; + } + fieldSize = 0; i = 0; while( NmeaString[i + fieldSize++] != ',' ) { if( fieldSize > 6 ) { - printf("gps:fieldSize:%d\r\n", fieldSize); + printf("gps parse:%s\r\n", NmeaString); return FAIL; } }