seperate time setting from validity check, if we chaneg the time we also invalidate

This commit is contained in:
Chris Liebman 2018-03-08 12:40:03 -08:00
parent 49a69c7cad
commit 7f45ec04bf

10
GPS.cpp
View File

@ -122,12 +122,11 @@ void GPS::process()
getTime(&tv);
logger.debug(TAG, "'%s'", _nmea.getSentence());
if (_nmea.isValid() && _nmea.getNumSatellites() >= 4)
{
const char * id = _nmea.getMessageID();
//
// if it was a GGA and its valid then check and maybe update the time
//
const char * id = _nmea.getMessageID();
if (_nmea.getYear() > 2000 && strcmp("RMC", id) == 0)
{
struct tm tm;
@ -148,6 +147,7 @@ void GPS::process()
if (!_nmea_late)
{
_seconds = new_seconds;
invalidate("seconds adjusted!");
logger.info(TAG, "adjusting seconds from %lu to %lu from:'%s'", old_seconds, new_seconds, _nmea.getSentence());
}
else
@ -158,7 +158,10 @@ void GPS::process()
_nmea_late = false;
_nmea_timer.attach_ms(NMEA_TIMER_MS, _timer_handler, &_nmea_timeout);
}
if (_nmea.isValid() && _nmea.getNumSatellites() >= 4)
{
//
// if gps was not valid, it is now
//
@ -169,7 +172,6 @@ void GPS::process()
logger.info(TAG, "GPS valid!");
}
}
}
else /* nmea not valid or sat count < 4 */
{
if (_gps_valid)