From: Keith Packard Date: Sun, 23 Aug 2020 17:51:00 +0000 (-0700) Subject: altoslib: Improve configuration performance over remote link X-Git-Tag: 1.9.5~1^2~18 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=10a10667a28f82c24d895e44617e68c7c1848c45 altoslib: Improve configuration performance over remote link Avoid re-setting dongle radio parameters when they haven't changed during device configuration setting. This avoids flipping back and forth from remote to local mode three times during config save. Wait for remote end to say 'Saved' before dropping radio link. This ensures that the remote end actually gets the save command before the link is terminated. Signed-off-by: Keith Packard --- diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 5d58566e..83f3ca07 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -796,33 +796,28 @@ public class AltosConfigData { has_setting, radio_calibration); /* When remote, reset the dongle frequency at the same time */ - if (remote) { - link.flush_output(); + if (remote && frequency != link.frequency) { link.stop_remote(); link.set_radio_frequency(frequency); - link.flush_output(); link.start_remote(); } } if (telemetry_rate != AltosLib.MISSING) { link.printf("c T %d\n", telemetry_rate); - if (remote) { - link.flush_output(); + if (remote && telemetry_rate != link.telemetry_rate) { link.stop_remote(); link.set_telemetry_rate(telemetry_rate); - link.flush_output(); link.start_remote(); } } if (callsign != null) { link.printf("c c %s\n", callsign); - if (remote) { - link.flush_output(); + if (remote && !callsign.equals(link.callsign)) { + System.out.printf("changing link callsign from %s to %s\n", link.callsign, callsign); link.stop_remote(); link.set_callsign(callsign); - link.flush_output(); link.start_remote(); } } @@ -882,7 +877,7 @@ public class AltosConfigData { /* UI doesn't support accel cal */ link.printf("c w\n"); - link.flush_output(); + read_link(link, "Saved"); } public AltosConfigData(AltosLink link) throws InterruptedException, TimeoutException {