summaryrefslogtreecommitdiff
path: root/lora_pkt_fwd
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2019-09-20 10:56:24 -0500
committerJason Reiss <jreiss@multitech.com>2019-09-20 10:56:24 -0500
commit97bb2ee691c2357cc52ff29e5f775fc0add89cc2 (patch)
treeb44811bc516d12547d89ed7e4854b365d9c7a7e1 /lora_pkt_fwd
parent124cf5d915aeaaceef412b835a955eca9953ea31 (diff)
downloadpacket_forwarder_mtac_full-97bb2ee691c2357cc52ff29e5f775fc0add89cc2.tar.gz
packet_forwarder_mtac_full-97bb2ee691c2357cc52ff29e5f775fc0add89cc2.tar.bz2
packet_forwarder_mtac_full-97bb2ee691c2357cc52ff29e5f775fc0add89cc2.zip
Beacon: reset last beacon if time change is detected.
Diffstat (limited to 'lora_pkt_fwd')
-rw-r--r--lora_pkt_fwd/src/lora_pkt_fwd.c7
1 files changed, 7 insertions, 0 deletions
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;