Fix: issue #639, if no LORA time source available and GPS time in first call is invalid, then time will never get updated from GPS

https://github.com/cyberman54/ESP32-Paxcounter/issues/639
This commit is contained in:
Oliver Seiler 2020-09-27 17:35:27 +13:00
parent 3e0102920a
commit 74239d77f4

View File

@ -35,8 +35,10 @@ void calibrateTime(void) {
timesync_request();
#endif
// (only!) if we lost time, we try to fallback to local time source RTS or GPS
if (timeSource == _unsynced) {
// if no LORA timesource is available, or if we lost time, then fallback to
// local time source RTS or GPS
if (((!TIME_SYNC_LORASERVER) && (!TIME_SYNC_LORAWAN)) ||
(timeSource == _unsynced)) {
// has RTC -> fallback to RTC time
#ifdef HAS_RTC
@ -47,7 +49,10 @@ void calibrateTime(void) {
// no RTC -> fallback to GPS time
#if (HAS_GPS)
t = get_gpstime(&t_msec);
if (t) {
// only set time source to GPS if GPS time was actually valid
timeSource = _gps;
}
#endif
if (t)