altoslib: Discard previous flight state on SN change
authorKeith Packard <keithp@keithp.com>
Sat, 15 Dec 2012 03:28:49 +0000 (19:28 -0800)
committerKeith Packard <keithp@keithp.com>
Sat, 15 Dec 2012 03:28:49 +0000 (19:28 -0800)
A previous change discarded previous *telemetry* state, but failed to
discard any previous overall flight state. This would reset some of
the data fields, but wouldn't reset the GPS state and max measurements.

Signed-off-by: Keith Packard <keithp@keithp.com>

altoslib/AltosState.java

index f28dd1c..218c598 100644 (file)
@@ -92,6 +92,9 @@ public class AltosState {
        public void init (AltosRecord cur, AltosState prev_state) {
                data = cur;
 
+               /* Discard previous state if it was for a different board */
+               if (prev_state != null && prev_state.data.serial != data.serial)
+                       prev_state = null;
                ground_altitude = data.ground_altitude();
 
                altitude = data.altitude();