fix timesync from RTC
This commit is contained in:
parent
f74f103e80
commit
fbb1878807
@ -65,7 +65,13 @@ time_t get_rtctime(uint16_t *msec) {
|
||||
|
||||
// if we have a RTC pulse, we calculate msec
|
||||
#ifdef RTC_INT
|
||||
*msec = lastRTCpulse % 1000;
|
||||
uint16_t ppsDiff = millis() - lastRTCpulse;
|
||||
if (ppsDiff < 1000)
|
||||
*msec = ppsDiff;
|
||||
else {
|
||||
ESP_LOGD(TAG, "no pulse from RTC");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return t;
|
||||
|
@ -203,8 +203,10 @@ void timepulse_init(void) {
|
||||
#endif
|
||||
|
||||
// get time if we don't have one
|
||||
if (timeSource != _set)
|
||||
if (timeSource != _set) {
|
||||
delay(1000); // wait for first PPS time stamp to arrive
|
||||
setTimeSyncIRQ(); // init systime by RTC or GPS or LORA
|
||||
}
|
||||
|
||||
// start cyclic time sync
|
||||
timesyncer.attach(TIME_SYNC_INTERVAL * 60, setTimeSyncIRQ);
|
||||
|
Loading…
Reference in New Issue
Block a user