diff options
Diffstat (limited to 'libloragw/src')
-rw-r--r-- | libloragw/src/loragw_gps.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/libloragw/src/loragw_gps.c b/libloragw/src/loragw_gps.c index de0d495..d02e23a 100644 --- a/libloragw/src/loragw_gps.c +++ b/libloragw/src/loragw_gps.c @@ -640,6 +640,11 @@ int lgw_gps_sync(struct tref *ref, uint32_t count_us, struct timespec utc, struc CHECK_NULL(ref); + /* calculate the slope */ + + cnt_diff = (double)(count_us - ref->count_us) / (double)(TS_CPS); /* uncorrected by xtal_err */ + utc_diff = (double)(utc.tv_sec - (ref->utc).tv_sec) + (1E-9 * (double)(utc.tv_nsec - (ref->utc).tv_nsec)); + if (cnt_diff == 0.0 || last_count_us == count_us) { // no pps change from SX1301, invalidate system reference time ref->systime = 0; @@ -649,11 +654,6 @@ int lgw_gps_sync(struct tref *ref, uint32_t count_us, struct timespec utc, struc last_count_us = count_us; - /* calculate the slope */ - - cnt_diff = (double)(count_us - ref->count_us) / (double)(TS_CPS); /* uncorrected by xtal_err */ - utc_diff = (double)(utc.tv_sec - (ref->utc).tv_sec) + (1E-9 * (double)(utc.tv_nsec - (ref->utc).tv_nsec)); - /* detect aberrant points by measuring if slope limits are exceeded */ if (utc_diff != 0) { // prevent divide by zero slope = cnt_diff/utc_diff; |