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:
parent
3e0102920a
commit
74239d77f4
@ -35,8 +35,10 @@ void calibrateTime(void) {
|
|||||||
timesync_request();
|
timesync_request();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// (only!) if we lost time, we try to fallback to local time source RTS or GPS
|
// if no LORA timesource is available, or if we lost time, then fallback to
|
||||||
if (timeSource == _unsynced) {
|
// local time source RTS or GPS
|
||||||
|
if (((!TIME_SYNC_LORASERVER) && (!TIME_SYNC_LORAWAN)) ||
|
||||||
|
(timeSource == _unsynced)) {
|
||||||
|
|
||||||
// has RTC -> fallback to RTC time
|
// has RTC -> fallback to RTC time
|
||||||
#ifdef HAS_RTC
|
#ifdef HAS_RTC
|
||||||
@ -47,7 +49,10 @@ void calibrateTime(void) {
|
|||||||
// no RTC -> fallback to GPS time
|
// no RTC -> fallback to GPS time
|
||||||
#if (HAS_GPS)
|
#if (HAS_GPS)
|
||||||
t = get_gpstime(&t_msec);
|
t = get_gpstime(&t_msec);
|
||||||
timeSource = _gps;
|
if (t) {
|
||||||
|
// only set time source to GPS if GPS time was actually valid
|
||||||
|
timeSource = _gps;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (t)
|
if (t)
|
||||||
|
Loading…
Reference in New Issue
Block a user