From 97bb2ee691c2357cc52ff29e5f775fc0add89cc2 Mon Sep 17 00:00:00 2001 From: Jason Reiss Date: Fri, 20 Sep 2019 10:56:24 -0500 Subject: Beacon: reset last beacon if time change is detected. --- lora_pkt_fwd/src/lora_pkt_fwd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c index ec42ec0..360b96e 100644 --- a/lora_pkt_fwd/src/lora_pkt_fwd.c +++ b/lora_pkt_fwd/src/lora_pkt_fwd.c @@ -2452,6 +2452,12 @@ void thread_down(void) { /* Wait for GPS to be ready before inserting beacons in JiT queue */ if ((gps_ref_valid == true) && (xtal_correct_ok == true)) { + if (time_reference_gps.gps.tv_sec < last_beacon_gps_time.tv_sec || + (time_reference_gps.gps.tv_sec - last_beacon_gps_time.tv_sec) > 256) { + // Incase system time reference has moved + last_beacon_gps_time.tv_sec = 0; + } + /* compute GPS time for next beacon to come */ /* LoRaWAN: T = k*beacon_period + TBeaconDelay */ /* with TBeaconDelay = [1.5ms +/- 1µs]*/ @@ -2468,6 +2474,7 @@ void thread_down(void) { next_beacon_gps_time.tv_sec += (retry * beacon_period); next_beacon_gps_time.tv_nsec = 0; + #if DEBUG_BEACON { time_t time_unix; -- cgit v1.2.3