Gate slow timesync on LoRa reception
- Keep sender in fast TimeSync listen mode until it receives a LoRa beacon - Reset scheduler when interval changes to avoid stuck timing
This commit is contained in:
10
src/main.cpp
10
src/main.cpp
@@ -170,9 +170,17 @@ static bool battery_sample_due(uint32_t now_ms) {
|
||||
|
||||
static bool sender_timesync_window_due() {
|
||||
uint32_t interval_sec = SENDER_TIMESYNC_CHECK_SEC_FAST;
|
||||
if (millis() - g_boot_ms >= 60000UL && time_is_synced() && time_rtc_present()) {
|
||||
bool allow_slow = (millis() - g_boot_ms >= 60000UL) && time_is_synced() && time_rtc_present() &&
|
||||
(g_sender_last_timesync_rx_ms > 0);
|
||||
// RTC boot time is not evidence of receiving network TimeSync.
|
||||
if (allow_slow) {
|
||||
interval_sec = SENDER_TIMESYNC_CHECK_SEC_SLOW;
|
||||
}
|
||||
static uint32_t last_interval_sec = 0;
|
||||
if (last_interval_sec != interval_sec) {
|
||||
last_interval_sec = interval_sec;
|
||||
g_sender_last_timesync_check_ms = millis();
|
||||
}
|
||||
if (g_sender_last_timesync_check_ms == 0) {
|
||||
g_sender_last_timesync_check_ms = millis() - interval_sec * 1000UL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user