From e98235e314ac764509af26c93da9e6d1de8184ea Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 14 Oct 2017 12:18:26 -0700 Subject: altoslib: Save separate config for local and remote. Use in idle When using the remote link, there are two separate configuration data blocks, that for the local device and for remote. Make the link report both versions, depending on whether it is in remote mode or not. Request config data in remote mode when running idle monitoring so that the presented data is for the remote device, not the local one. Signed-off-by: Keith Packard --- altoslib/AltosIdleMonitor.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'altoslib/AltosIdleMonitor.java') diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index fc5d4cc8..834d9aa5 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -33,6 +33,7 @@ public class AltosIdleMonitor extends Thread { double frequency; String callsign; + AltosState state; AltosListenerState listener_state; AltosConfigData config_data; AltosGPS gps; @@ -52,20 +53,23 @@ public class AltosIdleMonitor extends Thread { return link.reply_abort; } - boolean provide_data(AltosDataListener listener) throws InterruptedException, TimeoutException, AltosUnknownProduct { + boolean provide_data() throws InterruptedException, TimeoutException, AltosUnknownProduct { boolean worked = false; boolean aborted = false; try { start_link(); - fetch.provide_data(listener); + link.config_data(); + if (state == null) + state = new AltosState(new AltosCalData(link.config_data())); + fetch.provide_data(state); if (!link.has_error && !link.reply_abort) worked = true; } finally { aborted = stop_link(); if (worked) { if (remote) - listener.set_rssi(link.rssi(), 0); + state.set_rssi(link.rssi(), 0); listener_state.battery = link.monitor_battery(); } } @@ -92,14 +96,11 @@ public class AltosIdleMonitor extends Thread { } public void run() { - AltosState state = null; + state = null; try { for (;;) { try { - link.config_data(); - if (state == null) - state = new AltosState(new AltosCalData(link.config_data())); - provide_data(state); + provide_data(); listener.update(state, listener_state); } catch (TimeoutException te) { } catch (AltosUnknownProduct ae) { -- cgit v1.2.3