The function gps_storelocation(gpsStatus_t *gps_store) does check for .isUpdated(), but the updated flag is already reset while showing on the display. (push the button a few times to display GPS data)
This causes the gps_store data not to get updated and thus the random data of this struct (because it isn't initialized in the constructor) is sent to LoRa.
Then in the 2 places where this function is called, check for its return value:
#if (HAS_GPS)
if (GPSPORT == COUNTERPORT) {
// send GPS position only if we have a fix
if (gps_hasfix()) {
if (gps_storelocation(&gps_status))
payload.addGPS(gps_status);
} else
ESP_LOGD(TAG, "No valid GPS position");
}
#endif
#if (HAS_GPS)
case GPS_DATA:
if (GPSPORT != COUNTERPORT) {
// send GPS position only if we have a fix
if (gps_hasfix()) {
if (gps_storelocation(&gps_status)) {
payload.reset();
payload.addGPS(gps_status);
SendPayload(GPSPORT);
}
} else
ESP_LOGD(TAG, "No valid GPS position");
}
break;
#endif
This way, at least no bogus data is being sent to LoRa.
Tomorrow I will look into how we can read the GPS data without resetting the updated flag (or keep track of updated state elsewhere outside TinyGPS+)
The function
gps_storelocation(gpsStatus_t *gps_store)
does check for.isUpdated()
, but the updated flag is already reset while showing on the display. (push the button a few times to display GPS data)This causes the
gps_store
data not to get updated and thus the random data of this struct (because it isn't initialized in the constructor) is sent to LoRa.Proposal: Change the function to return a bool:
And make sure to initialize the struct:
Then in the 2 places where this function is called, check for its return value:
This way, at least no bogus data is being sent to LoRa.
Tomorrow I will look into how we can read the GPS data without resetting the updated flag (or keep track of updated state elsewhere outside TinyGPS+)