altoslib: Don't pass along GPS information when the GPS device is busted
authorKeith Packard <keithp@keithp.com>
Wed, 7 Oct 2020 01:54:27 +0000 (18:54 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 22 Oct 2020 04:34:49 +0000 (21:34 -0700)
If the telemetry packet indicates that there's no functioning GPS receiver,
then don't pass along those packets so that the UI displays things more accurately.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosTelemetryLocation.java

index 7a281fdf7422f81253ea42fbca786f97f5486b44..60a1d68cbfd3fe47d68158066c12f7ede478e1d3 100644 (file)
@@ -50,7 +50,6 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard {
        }
 
        public void provide_data(AltosDataListener listener) {
-               super.provide_data(listener);
 
                AltosCalData    cal_data = listener.cal_data();
 
@@ -63,6 +62,8 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard {
                gps.pdop = pdop() / 10.0;
                gps.hdop = hdop() / 10.0;
                gps.vdop = vdop() / 10.0;
+               if (gps.connected)
+                       super.provide_data(listener);
 
                if (gps.locked) {
                        gps.lat = latitude() * 1.0e-7;
@@ -78,6 +79,7 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard {
                        gps.course = course() * 2;
                        gps.climb_rate = climb_rate() * 1.0e-2;
                }
-               listener.set_gps(gps, true, false);
+               if (gps.connected)
+                       listener.set_gps(gps, true, false);
        }
 }