summaryrefslogtreecommitdiff
path: root/altoslib
diff options
context:
space:
mode:
Diffstat (limited to 'altoslib')
-rw-r--r--altoslib/AltosConfigData.java31
-rw-r--r--altoslib/AltosLink.java24
2 files changed, 48 insertions, 7 deletions
diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java
index fd38635c..4ada1d3b 100644
--- a/altoslib/AltosConfigData.java
+++ b/altoslib/AltosConfigData.java
@@ -386,6 +386,10 @@ public class AltosConfigData implements Iterable<String> {
return radio_frequency >= 0 || radio_setting >= 0 || radio_channel >= 0;
}
+ public boolean has_telemetry_rate() {
+ return telemetry_rate >= 0;
+ }
+
public void set_frequency(double freq) {
int frequency = radio_frequency;
int setting = radio_setting;
@@ -558,20 +562,39 @@ public class AltosConfigData implements Iterable<String> {
radio_calibration);
/* When remote, reset the dongle frequency at the same time */
if (remote) {
+ link.flush_output();
link.stop_remote();
link.set_radio_frequency(frequency);
+ link.flush_output();
link.start_remote();
}
}
- if (callsign != null)
+ if (telemetry_rate >= 0) {
+ link.printf("c T %d\n", telemetry_rate);
+ if (remote) {
+ link.flush_output();
+ 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();
+ link.stop_remote();
+ link.set_callsign(callsign);
+ link.flush_output();
+ link.start_remote();
+ }
+ }
+
if (radio_enable >= 0)
link.printf("c e %d\n", radio_enable);
- if (telemetry_rate >= 0)
- link.printf("c T %d\n", telemetry_rate);
-
/* HAS_ACCEL */
/* UI doesn't support accel cal */
if (pad_orientation >= 0)
diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java
index eadab5df..62bd82b9 100644
--- a/altoslib/AltosLink.java
+++ b/altoslib/AltosLink.java
@@ -163,8 +163,21 @@ public abstract class AltosLink implements Runnable {
if (!can_cancel && remote)
System.out.printf("Uh-oh, reading remote serial device from swing thread\n");
- if (remote && can_cancel)
+ if (remote && can_cancel) {
timeout = 500;
+ switch (telemetry_rate) {
+ case AltosLib.ao_telemetry_rate_38400:
+ default:
+ timeout = 500;
+ break;
+ case AltosLib.ao_telemetry_rate_9600:
+ timeout = 2000;
+ break;
+ case AltosLib.ao_telemetry_rate_2400:
+ timeout = 8000;
+ break;
+ }
+ }
try {
++in_reply;
@@ -307,7 +320,7 @@ public abstract class AltosLink implements Runnable {
*/
public boolean monitor_mode = false;
public int telemetry = AltosLib.ao_telemetry_standard;
- public int telemetry_rate = AltosLib.ao_telemetry_rate_38400;
+ public int telemetry_rate = -1;
public double frequency;
public String callsign;
AltosConfigData config_data;
@@ -446,7 +459,12 @@ public abstract class AltosLink implements Runnable {
if (debug)
System.out.printf("start remote %7.3f\n", frequency);
set_radio_frequency(frequency);
- set_callsign(AltosPreferences.callsign());
+ if (telemetry_rate < 0)
+ telemetry_rate = AltosPreferences.telemetry_rate(serial);
+ set_telemetry_rate(telemetry_rate);
+ if (callsign.equals(""))
+ callsign = AltosPreferences.callsign();
+ set_callsign(callsign);
printf("p\nE 0\n");
flush_input();
remote = true;