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 f28dd1c6609f24070b7ba0fa4ce4e5f8f60205ed..218c598ab5d80d6a4e264b86a1a9d25209b5f933 100644 (file)
@@ -92,6 +92,9 @@ public class AltosState {
        public void init (AltosRecord cur, AltosState prev_state) {
                data = cur;
 
        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();
                ground_altitude = data.ground_altitude();
 
                altitude = data.altitude();