summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2022-01-24 10:54:22 -0600
committerJason Reiss <jreiss@multitech.com>2022-01-24 10:54:22 -0600
commit857e83833cadd1365e4a4f284200cdb900bd8eed (patch)
tree5b54bc9419ff6d2d312c4167b5ab427754d75338
parentc2cccb19edc320e82d6e3cf4b60d6c263c069af5 (diff)
downloadpacket_forwarder_mtac_full-857e83833cadd1365e4a4f284200cdb900bd8eed.tar.gz
packet_forwarder_mtac_full-857e83833cadd1365e4a4f284200cdb900bd8eed.tar.bz2
packet_forwarder_mtac_full-857e83833cadd1365e4a4f284200cdb900bd8eed.zip
wait 32s before scheduling beacons4.0.15
-rw-r--r--lora_pkt_fwd/src/lora_pkt_fwd.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c
index 6d87f91..193ef57 100644
--- a/lora_pkt_fwd/src/lora_pkt_fwd.c
+++ b/lora_pkt_fwd/src/lora_pkt_fwd.c
@@ -334,6 +334,11 @@ void thread_jit(void);
void thread_timersync(void);
void thread_spectralscan(void);
+
+struct timespec start_time;
+struct timespec check_time;
+
+
/* -------------------------------------------------------------------------- */
/* --- PRIVATE FUNCTIONS DEFINITION ----------------------------------------- */
@@ -1886,9 +1891,6 @@ int main(int argc, char** argv)
sigaction(SIGHUP, &sighupact, NULL); /* rotate logfile on HUP */
signal(SIGPIPE, SIG_IGN); /* ignore writes after closing socket */
- struct timespec start_time;
- struct timespec check_time;
-
clock_gettime(CLOCK_MONOTONIC, &start_time);
/* main loop task : statistics collection */
@@ -2851,7 +2853,7 @@ 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)) {
+ if ((gps_ref_valid == true) && (int)difftimespec(recv_time, start_time) > 32)) {
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))) {
@@ -3555,8 +3557,12 @@ void thread_gps(void) {
/* try to update time reference with the new GPS time & timestamp */
pthread_mutex_lock(&mx_timeref);
- lgw_gps_sync(&time_reference_gps, trig_tstamp, gpsdata.fix.time);
+ i = lgw_gps_sync(&time_reference_gps, trig_tstamp, gpsdata.fix.time);
pthread_mutex_unlock(&mx_timeref);
+
+ if (i != LGW_GPS_SUCCESS) {
+ MSG("WARNING: [gps] GPS out of sync, keeping previous time reference\n");
+ }
} else {
gps_coord_valid = false;
}