diff options
author | Jason Reiss <jreiss@multitech.com> | 2020-03-20 08:57:53 -0500 |
---|---|---|
committer | Jason Reiss <jreiss@multitech.com> | 2020-03-20 08:57:53 -0500 |
commit | b41e94f6850bc6e5b46e324d6bf9abff2cbc3f1e (patch) | |
tree | 1c9911122c00dee428f76fa15d1528d1d7432795 | |
parent | 28b9dff2eb06fb88421cf32771d380a178079fce (diff) | |
download | packet_forwarder_mtac_full-b41e94f6850bc6e5b46e324d6bf9abff2cbc3f1e.tar.gz packet_forwarder_mtac_full-b41e94f6850bc6e5b46e324d6bf9abff2cbc3f1e.tar.bz2 packet_forwarder_mtac_full-b41e94f6850bc6e5b46e324d6bf9abff2cbc3f1e.zip |
Add LBT periodic restart and lgw_page monitor
-rw-r--r-- | lora_pkt_fwd/src/lora_pkt_fwd.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c index debb71b..389b552 100644 --- a/lora_pkt_fwd/src/lora_pkt_fwd.c +++ b/lora_pkt_fwd/src/lora_pkt_fwd.c @@ -3129,11 +3129,32 @@ static void gps_process_sync(void) { /* get timestamp captured on PPM pulse */ pthread_mutex_lock(&mx_concent); i = lgw_get_trigcnt(&trig_tstamp); + + uint8_t page = 0; + lgw_get_cur_page(&page); + + if (page != 2) { + //quit rather than reset the page. We don't know if this was on purpose or not. + exit_sig = true; + MSG("WARNING: lgw page was unexpectedly changed, process is exiting.\n"); + break; + } + pthread_mutex_unlock(&mx_concent); if (i != LGW_HAL_SUCCESS) { - MSG("WARNING: [gps] failed to read concentrator timestamp\n"); - return; + printf("# SX1301 time (PPS): unknown\n"); + } else { + printf("# SX1301 time (PPS): %u %u\n", trig_tstamp, page); + } + + static uint32_t last_tstamp = 0; + if (lbt_enabled && trig_tstamp < last_tstamp) { + printf("# Restarting LBT\n"); + lgw_fpga_reg_w(LGW_FPGA_CTRL_FEATURE_START, 0); + wait_ms(5); + lgw_fpga_reg_w(LGW_FPGA_CTRL_FEATURE_START, 1); } + last_tstamp = trig_tstamp; /* try to update time reference with the new GPS time & timestamp */ pthread_mutex_lock(&mx_timeref); |