paxcounter.conf: added time sync retry setting
This commit is contained in:
parent
185953bd5a
commit
a7a49ee9a0
@ -67,6 +67,7 @@
|
|||||||
|
|
||||||
// settings for syncing time of node with external time source
|
// settings for syncing time of node with external time source
|
||||||
#define TIME_SYNC_INTERVAL 0 // sync time attempt each .. minutes from time source (GPS/LORA/RTC) [default = 60], 0 means off
|
#define TIME_SYNC_INTERVAL 0 // sync time attempt each .. minutes from time source (GPS/LORA/RTC) [default = 60], 0 means off
|
||||||
|
#define TIME_SYNC_INTERVAL_RETRY 0 // retry time sync after lost sync each .. minutes [default = 10], 0 means off
|
||||||
#define TIME_SYNC_COMPILEDATE 0 // set to 1 to use compile date to initialize RTC after power outage [default = 0]
|
#define TIME_SYNC_COMPILEDATE 0 // set to 1 to use compile date to initialize RTC after power outage [default = 0]
|
||||||
#define TIME_SYNC_LORAWAN 0 // set to 1 to use LORA network as time source, 0 means off [default = 0]
|
#define TIME_SYNC_LORAWAN 0 // set to 1 to use LORA network as time source, 0 means off [default = 0]
|
||||||
#define TIME_SYNC_TIMESERVER 0 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0]
|
#define TIME_SYNC_TIMESERVER 0 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0]
|
||||||
|
@ -43,7 +43,7 @@ time_t timeProvider(void) {
|
|||||||
t = get_rtctime();
|
t = get_rtctime();
|
||||||
if (t) {
|
if (t) {
|
||||||
timeSource = _rtc;
|
timeSource = _rtc;
|
||||||
timesyncer.attach(60, timeSync); // short retry
|
timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, timeSync); // short retry
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ time_t timeProvider(void) {
|
|||||||
|
|
||||||
if (!t) {
|
if (!t) {
|
||||||
timeSource = _unsynced;
|
timeSource = _unsynced;
|
||||||
timesyncer.attach(60, timeSync); // short retry
|
timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, timeSync); // short retry
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
@ -138,7 +138,6 @@ void IRAM_ATTR CLOCKIRQ(void) {
|
|||||||
portYIELD_FROM_ISR();
|
portYIELD_FROM_ISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// helper function to check plausibility of a time
|
// helper function to check plausibility of a time
|
||||||
time_t timeIsValid(time_t const t) {
|
time_t timeIsValid(time_t const t) {
|
||||||
// is it a time in the past? we use compile date to guess
|
// is it a time in the past? we use compile date to guess
|
||||||
@ -204,7 +203,6 @@ void clock_init(void) {
|
|||||||
assert(ClockTask); // has clock task started?
|
assert(ClockTask); // has clock task started?
|
||||||
} // clock_init
|
} // clock_init
|
||||||
|
|
||||||
|
|
||||||
void clock_loop(void *taskparameter) { // ClockTask
|
void clock_loop(void *taskparameter) { // ClockTask
|
||||||
|
|
||||||
// caveat: don't use now() in this task, it will cause a race condition
|
// caveat: don't use now() in this task, it will cause a race condition
|
||||||
|
@ -160,8 +160,7 @@ void process_timesync_req(void *taskparameter) {
|
|||||||
I2C_MUTEX_UNLOCK();
|
I2C_MUTEX_UNLOCK();
|
||||||
|
|
||||||
timeSource = _lora;
|
timeSource = _lora;
|
||||||
timesyncer.attach(TIME_SYNC_INTERVAL * 60,
|
timesyncer.attach(TIME_SYNC_INTERVAL * 60, timeSync); // regular repeat
|
||||||
timeSync); // set to regular repeat
|
|
||||||
ESP_LOGI(TAG, "[%0.3f] Timesync finished, time was adjusted",
|
ESP_LOGI(TAG, "[%0.3f] Timesync finished, time was adjusted",
|
||||||
millis() / 1000.0);
|
millis() / 1000.0);
|
||||||
} else
|
} else
|
||||||
|
Loading…
Reference in New Issue
Block a user