From e6960db410f52ccadd3d70d3411c1f512f21ff78 Mon Sep 17 00:00:00 2001 From: Jason Reiss Date: Fri, 20 Sep 2019 13:08:49 -0500 Subject: Remove xtal correction requirement for beacons check that sheduling times look correct --- lora_pkt_fwd/src/lora_pkt_fwd.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c index 360b96e..9d2d4df 100644 --- a/lora_pkt_fwd/src/lora_pkt_fwd.c +++ b/lora_pkt_fwd/src/lora_pkt_fwd.c @@ -2275,6 +2275,7 @@ void thread_down(void) { size_t beacon_RFU2_size = 0; uint8_t beacon_pyld_idx = 0; time_t diff_beacon_time; + time_t time_us = 0; struct timespec next_beacon_gps_time; /* gps time of next beacon packet */ struct timespec last_beacon_gps_time; /* gps time of last enqueued beacon packet */ int retry; @@ -2450,10 +2451,10 @@ void thread_down(void) { while (beacon_loop && (beacon_period != 0)) { pthread_mutex_lock(&mx_timeref); /* Wait for GPS to be ready before inserting beacons in JiT queue */ - if ((gps_ref_valid == true) && (xtal_correct_ok == true)) { + if ((gps_ref_valid == 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) { + if (time_reference_gps.gps.tv_sec < last_beacon_gps_time.tv_sec + 128 || + (time_reference_gps.gps.tv_sec - last_beacon_gps_time.tv_sec) > (time_t)(beacon_period * (JIT_NUM_BEACON_IN_QUEUE+1))) { // Incase system time reference has moved last_beacon_gps_time.tv_sec = 0; } @@ -2516,6 +2517,15 @@ void thread_down(void) { /* Insert beacon packet in JiT queue */ gettimeofday(¤t_unix_time, NULL); get_concentrator_time(¤t_concentrator_time, current_unix_time); + + time_us = (current_concentrator_time.tv_sec * 1000000UL + current_concentrator_time.tv_usec); + + if (beacon_pkt.count_us == 0 + || beacon_pkt.count_us < time_us + || beacon_pkt.count_us - time_us < 1e6) { + break; + } + jit_result = jit_enqueue(&jit_queue, ¤t_concentrator_time, &beacon_pkt, JIT_PKT_TYPE_BEACON); if (jit_result == JIT_ERROR_OK) { /* update stats */ -- cgit v1.2.3