altoslib: Preserve receiver_serial across state reset for new transmitter
authorKeith Packard <keithp@keithp.com>
Sat, 5 Jul 2014 06:20:51 +0000 (23:20 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 5 Jul 2014 07:38:09 +0000 (00:38 -0700)
When the transmitter serial or flight number changes, we re-init the
state information, but we want to preserve the receiver serial number
so that the log file has that in the name

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

index e0c00602c7cdb4827571f4a7df326c59b720a00b..5e7908af135402642abf1d7824a34943ad43954e 100644 (file)
@@ -1024,15 +1024,21 @@ public class AltosState implements Cloneable {
                firmware_version = version;
        }
 
+       private void re_init() {
+               int bt = boost_tick;
+               int rs = receiver_serial;
+               init();
+               boost_tick = bt;
+               receiver_serial = rs;
+       }
+
        public void set_flight(int flight) {
 
                /* When the flight changes, reset the state */
-               if (flight != AltosLib.MISSING && flight != 0) {
+               if (flight != AltosLib.MISSING) {
                        if (this.flight != AltosLib.MISSING &&
                            this.flight != flight) {
-                               int bt = boost_tick;
-                               init();
-                               boost_tick = bt;
+                               re_init();
                        }
                        this.flight = flight;
                }
@@ -1043,9 +1049,7 @@ public class AltosState implements Cloneable {
                if (serial != AltosLib.MISSING) {
                        if (this.serial != AltosLib.MISSING &&
                            this.serial != serial) {
-                               int bt = boost_tick;
-                               init();
-                               boost_tick = bt;
+                               re_init();
                        }
                        this.serial = serial;
                }