summaryrefslogtreecommitdiff
path: root/altoslib/AltosIdleMonitor.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-10-14 12:18:26 -0700
committerKeith Packard <keithp@keithp.com>2017-10-14 12:18:26 -0700
commite98235e314ac764509af26c93da9e6d1de8184ea (patch)
tree88b237b9838c05c0f5dbb8e446c248ee5309be7f /altoslib/AltosIdleMonitor.java
parent964a14568b73296194f84c728cc7e01d6f0e2f64 (diff)
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 <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosIdleMonitor.java')
-rw-r--r--altoslib/AltosIdleMonitor.java17
1 files changed, 9 insertions, 8 deletions
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) {