From c2701ae646124f0668c5f2d1df3fc80f0075a9d7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 10 Feb 2013 14:17:04 -0800 Subject: altosui: Interrupt MonitorIdle when changing frequency/callsign When switching radio parameters, the local device needs to have the parameters switched, so interrupt the current operation and start over, the frequency and callsign will be set the next time through. Signed-off-by: Keith Packard --- altoslib/AltosIdleMonitor.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'altoslib/AltosIdleMonitor.java') diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index 6b20b3f1..f2f75bbb 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -27,6 +27,7 @@ public class AltosIdleMonitor extends Thread { AltosState state; boolean remote; double frequency; + String callsign; AltosState previous_state; AltosConfigData config_data; AltosGPS gps; @@ -87,6 +88,7 @@ public class AltosIdleMonitor extends Thread { try { if (remote) { link.set_radio_frequency(frequency); + link.set_callsign(callsign); link.start_remote(); } else link.flush_input(); @@ -126,12 +128,29 @@ public class AltosIdleMonitor extends Thread { public void set_frequency(double in_frequency) { frequency = in_frequency; + link.abort_reply(); + } + + public void set_callsign(String in_callsign) { + callsign = in_callsign; + link.abort_reply(); } public void post_state() { listener.update(state); } + public void abort() { + if (isAlive()) { + interrupt(); + link.abort_reply(); + try { + join(); + } catch (InterruptedException ie) { + } + } + } + public void run() { try { for (;;) { -- cgit v1.2.3