summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2019-09-20 13:08:49 -0500
committerJason Reiss <jreiss@multitech.com>2019-09-20 13:08:49 -0500
commite6960db410f52ccadd3d70d3411c1f512f21ff78 (patch)
treed2eb742d014e92fb3848cbf780a35ac3b3ce381f
parent97bb2ee691c2357cc52ff29e5f775fc0add89cc2 (diff)
downloadpacket_forwarder_mtac_full-e6960db410f52ccadd3d70d3411c1f512f21ff78.tar.gz
packet_forwarder_mtac_full-e6960db410f52ccadd3d70d3411c1f512f21ff78.tar.bz2
packet_forwarder_mtac_full-e6960db410f52ccadd3d70d3411c1f512f21ff78.zip
Remove xtal correction requirement for beacons check that sheduling times look correct
-rw-r--r--lora_pkt_fwd/src/lora_pkt_fwd.c16
1 files 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(&current_unix_time, NULL);
get_concentrator_time(&current_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, &current_concentrator_time, &beacon_pkt, JIT_PKT_TYPE_BEACON);
if (jit_result == JIT_ERROR_OK) {
/* update stats */