summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2022-01-24 10:52:07 -0600
committerJason Reiss <jreiss@multitech.com>2022-01-24 10:52:07 -0600
commite4b66900abb578d3e3d7a1c15f0b31d637984f7b (patch)
tree7d7e69cce606f1f43fb7a26d5f50a35b6a66caa3
parent7dfad6c35334110b9b7e26cb434af2dcca95d0aa (diff)
downloadlora_gateway_mtac_full-e4b66900abb578d3e3d7a1c15f0b31d637984f7b.tar.gz
lora_gateway_mtac_full-e4b66900abb578d3e3d7a1c15f0b31d637984f7b.tar.bz2
lora_gateway_mtac_full-e4b66900abb578d3e3d7a1c15f0b31d637984f7b.zip
gps update only once per second5.0.11
-rw-r--r--libloragw/src/loragw_gps.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libloragw/src/loragw_gps.c b/libloragw/src/loragw_gps.c
index 3b19909..2698c4b 100644
--- a/libloragw/src/loragw_gps.c
+++ b/libloragw/src/loragw_gps.c
@@ -637,6 +637,10 @@ int lgw_gps_sync(struct tref *ref, uint32_t count_us, struct timespec gps_time)
if (ref->systime != 0) {
cnt_diff = (double)(count_us - ref->count_us) / (double)(TS_CPS); /* uncorrected by xtal_err */
utc_diff = (double)((gps_time.tv_sec - timezone) - (ref->utc).tv_sec) + (1E-9 * (double)(gps_time.tv_nsec - (ref->utc).tv_nsec));
+
+ if (!calibrating && utc_diff < 1.0)
+ return LGW_GPS_ERROR;
+
if (cnt_diff != 0 && utc_diff != 0) { // prevent divide by zero
slope = cnt_diff/utc_diff;
} else {
@@ -645,12 +649,7 @@ int lgw_gps_sync(struct tref *ref, uint32_t count_us, struct timespec gps_time)
update = (slope >= MINUS_10PPM && slope <= PLUS_10PPM);
- if (cnt_diff > 1.5) {
- update = true;
- slope = 1.0;
- } else if (!calibrating && utc_diff < 10.0) {
- return LGW_GPS_ERROR;
- } else if (calibrating && !update && utc_diff > 1.5) {
+ if (calibrating && !update && utc_diff > 1.5) {
update = true;
} else if (update) {
calibrating = false;