diff options
author | Keith Packard <keithp@keithp.com> | 2014-07-04 23:20:51 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-07-05 00:38:09 -0700 |
commit | 2e99ff2c99f5d4a2fa196507e794c690665ab39e (patch) | |
tree | 2e79fdedde593d51892256f0f6295bea6690741c | |
parent | d6e64790287d684cb9b70c67fa270825932cc020 (diff) |
altoslib: Preserve receiver_serial across state reset for new transmitter
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>
-rw-r--r-- | altoslib/AltosState.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index e0c00602..5e7908af 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -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; } |