summaryrefslogtreecommitdiff
path: root/libloragw/src/loragw_gps.c
diff options
context:
space:
mode:
Diffstat (limited to 'libloragw/src/loragw_gps.c')
-rw-r--r--libloragw/src/loragw_gps.c10
1 files changed, 10 insertions, 0 deletions
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 */