@@ -46,9 +46,8 @@ bool nmea_decode(NMEAFixInfo *gpsFix, const char *nmeaLine) {
46
46
char buf [NMEA_MAX_SIZE ];
47
47
strcpy (buf , nmeaLine );
48
48
char * nmea = buf , * nextComma ;
49
- bool lastWasGSV = gpsFix -> lastWasGSV ;
50
49
bool thisIsGSV = false;
51
- gpsFix -> lastWasGSV = false;
50
+ bool thisIsGGA = false;
52
51
if (nmea [0 ]== '$' && nmea [1 ]== 'G' ) {
53
52
if (nmea [3 ]== 'R' && nmea [4 ]== 'M' && nmea [5 ]== 'C' ) {
54
53
// $GNRMC,161945.00,A,5139.11397,N,00116.07202,W,1.530,,190919,,,A*7E
@@ -115,13 +114,14 @@ bool nmea_decode(NMEAFixInfo *gpsFix, const char *nmeaLine) {
115
114
gpsFix -> alt = nmea_decode_float (nmea , nextComma );
116
115
nmea = nextComma + 1 ; nextComma = nmea_next_comma (nmea );
117
116
// ....
117
+ thisIsGGA = true;
118
118
}
119
119
if (nmea [3 ]== 'G' && nmea [4 ]== 'S' && nmea [5 ]== 'V' ) {
120
120
// loads of cool data about what satellites we have and signal strength...
121
121
thisIsGSV = true;
122
- gpsFix -> lastWasGSV = true;
123
122
}
124
123
}
124
+ bool createGPSEvent = false;
125
125
/* When to create GPS data event?
126
126
F18 (UBlox) GPS gives a bunch of data ending in GLL
127
127
No fix:
@@ -153,14 +153,20 @@ bool nmea_decode(NMEAFixInfo *gpsFix, const char *nmeaLine) {
153
153
$BDGSV,1,1,00,0*74
154
154
155
155
The thing they have in common is they have GSV, then some stuff after that
156
- we don't care about. So when that happens, trigger success
156
+ we don't care about. So when that happens, trigger success.
157
157
*/
158
- if (lastWasGSV && !thisIsGSV ) {
158
+ if (gpsFix -> lastWasGSV && !thisIsGSV ) { // we got something other than GSV (the item right after)
159
159
// Complete set of data received
160
- return true;
160
+ createGPSEvent = true;
161
161
}
162
-
163
- return false;
162
+ if (gpsFix -> lastWasGGA && thisIsGGA ) { // We got two GGAs - we can do this if
163
+ // Complete set of data received
164
+ createGPSEvent = true;
165
+ }
166
+ // update info we had last
167
+ gpsFix -> lastWasGSV = thisIsGSV ;
168
+ gpsFix -> lastWasGGA = thisIsGGA ;
169
+ return createGPSEvent ;
164
170
}
165
171
166
172
0 commit comments