From 34d28eb28f6931f55a46fdcc6c1b5ba9d5e4cfe4 Mon Sep 17 00:00:00 2001 From: Jason Reiss Date: Wed, 26 Oct 2022 11:42:20 -0500 Subject: gps: add check for loss of PPS to the SX1301 --- libloragw/src/loragw_gps.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libloragw/src/loragw_gps.c b/libloragw/src/loragw_gps.c index 5b400bf..de0d495 100644 --- a/libloragw/src/loragw_gps.c +++ b/libloragw/src/loragw_gps.c @@ -636,9 +636,19 @@ int lgw_gps_sync(struct tref *ref, uint32_t count_us, struct timespec utc, struc bool aber_n0; /* is the update value for synchronization aberrant or not ? */ static bool aber_min1 = false; /* keep track of whether value at sync N-1 was aberrant or not */ static bool aber_min2 = false; /* keep track of whether value at sync N-2 was aberrant or not */ + static uint32_t last_count_us = 0; CHECK_NULL(ref); + if (cnt_diff == 0.0 || last_count_us == count_us) { + // no pps change from SX1301, invalidate system reference time + ref->systime = 0; + ref->count_us = count_us; + return LGW_GPS_ERROR; + } + + last_count_us = count_us; + /* calculate the slope */ cnt_diff = (double)(count_us - ref->count_us) / (double)(TS_CPS); /* uncorrected by xtal_err */ -- cgit v1.2.3