Keep receiver timesync fast and extend sender fast window
- Receiver now sends time sync every 60s indefinitely (mains powered) - Sender stays in fast timesync listen mode for first 60s even with RTC
This commit is contained in:
@@ -123,7 +123,7 @@ void receiver_loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (time_to_send_timesync()) {
|
if (time_to_send_timesync()) {
|
||||||
time_send_timesync(self_short_id); // 60s for first 10 min, then hourly if RTC is present
|
time_send_timesync(self_short_id); // always every 60s (receiver is mains-powered)
|
||||||
}
|
}
|
||||||
|
|
||||||
mqtt_loop();
|
mqtt_loop();
|
||||||
@@ -302,7 +302,7 @@ inline constexpr uint16_t EXPECTED_SENDER_IDS[NUM_SENDERS] = { 0xF19C };
|
|||||||
- Enable/disable with `ENABLE_DS3231` in `include/config.h`.
|
- Enable/disable with `ENABLE_DS3231` in `include/config.h`.
|
||||||
- Receiver time sync packets set the RTC.
|
- Receiver time sync packets set the RTC.
|
||||||
- On boot, if no LoRa time sync has arrived yet, the sender uses the RTC time as the initial `ts_utc`.
|
- On boot, if no LoRa time sync has arrived yet, the sender uses the RTC time as the initial `ts_utc`.
|
||||||
- When no RTC is present or enabled, the receiver keeps sending time sync every 60 seconds.
|
- Receiver keeps sending time sync every 60 seconds.
|
||||||
|
|
||||||
## Build Environments
|
## Build Environments
|
||||||
- `lilygo-t3-v1-6-1`: production build (debug on)
|
- `lilygo-t3-v1-6-1`: production build (debug on)
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ static bool battery_sample_due(uint32_t now_ms) {
|
|||||||
|
|
||||||
static bool sender_timesync_window_due() {
|
static bool sender_timesync_window_due() {
|
||||||
uint32_t interval_sec = SENDER_TIMESYNC_CHECK_SEC_FAST;
|
uint32_t interval_sec = SENDER_TIMESYNC_CHECK_SEC_FAST;
|
||||||
if (time_is_synced() && time_rtc_present()) {
|
if (millis() - g_boot_ms >= 60000UL && time_is_synced() && time_rtc_present()) {
|
||||||
interval_sec = SENDER_TIMESYNC_CHECK_SEC_SLOW;
|
interval_sec = SENDER_TIMESYNC_CHECK_SEC_SLOW;
|
||||||
}
|
}
|
||||||
if (g_sender_last_timesync_check_ms == 0) {
|
if (g_sender_last_timesync_check_ms == 0) {
|
||||||
@@ -1005,9 +1005,6 @@ static void receiver_loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t interval_sec = TIME_SYNC_INTERVAL_SEC;
|
uint32_t interval_sec = TIME_SYNC_INTERVAL_SEC;
|
||||||
if (time_rtc_present() && millis() - g_boot_ms >= TIME_SYNC_FAST_WINDOW_MS) {
|
|
||||||
interval_sec = TIME_SYNC_SLOW_INTERVAL_SEC;
|
|
||||||
}
|
|
||||||
if (!g_ap_mode && millis() - g_last_timesync_ms > interval_sec * 1000UL) {
|
if (!g_ap_mode && millis() - g_last_timesync_ms > interval_sec * 1000UL) {
|
||||||
g_last_timesync_ms = millis();
|
g_last_timesync_ms = millis();
|
||||||
if (!time_send_timesync(g_short_id)) {
|
if (!time_send_timesync(g_short_id)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user