X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosConfigData.java;h=2f36e215a36cbac3367382db5c263c3402ce6161;hb=e063701310c1ab5b766c27f24088699aad142fbd;hp=e5c546ff69c84e5f576ec42dbce25678a23f5f4a;hpb=f0216d721ed13f4d3dc608bb6ad8f83732b27c0a;p=fw%2Faltos diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index e5c546ff..2f36e215 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -80,6 +80,9 @@ public class AltosConfigData implements Iterable { /* Log listing replies */ public int stored_flight; + /* HAS_TRACKER */ + public int[] tracker_distances; + public static String get_string(String line, String label) throws ParseException { if (line.startsWith(label)) { String quoted = line.substring(label.length()).trim(); @@ -103,6 +106,20 @@ public class AltosConfigData implements Iterable { throw new ParseException("mismatch", 0); } + public static int[] get_distances(String line, String label) throws NumberFormatException, ParseException { + if (line.startsWith(label)) { + String tail = line.substring(label.length()).trim(); + String[] tokens = tail.split("\\s+"); + if (tokens.length > 1) { + int[] distances = new int[2]; + distances[0] = Integer.parseInt(tokens[0]); + distances[1] = Integer.parseInt(tokens[1]); + return distances; + } + } + throw new ParseException("mismatch", 0); + } + public Iterator iterator() { return lines.iterator(); } @@ -215,6 +232,8 @@ public class AltosConfigData implements Iterable { beep = -1; + tracker_distances = null; + storage_size = -1; storage_erase_unit = -1; stored_flight = 0; @@ -294,6 +313,9 @@ public class AltosConfigData implements Iterable { /* HAS_BEEP */ try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {} + /* HAS_TRACKER */ + try { tracker_distances = get_distances(line, "Tracker setting:"); } catch (Exception e) {} + /* Storage info replies */ try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} try { storage_erase_unit = get_int(line, "Storage erase unit:"); } catch (Exception e) {} @@ -381,7 +403,7 @@ public class AltosConfigData implements Iterable { return 1024; } - public void get_values(AltosConfigValues source) { + public void get_values(AltosConfigValues source) throws AltosConfigDataException { /* HAS_FLIGHT */ if (main_deploy >= 0) @@ -424,6 +446,9 @@ public class AltosConfigData implements Iterable { /* HAS_BEEP */ if (beep >= 0) beep = source.beep(); + /* HAS_TRACKER */ + if (tracker_distances != null) + tracker_distances = source.tracker_distances(); } public void set_values(AltosConfigValues dest) { @@ -463,6 +488,7 @@ public class AltosConfigData implements Iterable { dest.set_pyros(null); dest.set_aprs_interval(aprs_interval); dest.set_beep(beep); + dest.set_tracker_distances(tracker_distances); } public void save(AltosLink link, boolean remote) throws InterruptedException, TimeoutException { @@ -533,6 +559,10 @@ public class AltosConfigData implements Iterable { if (beep >= 0) link.printf("c b %d\n", beep); + /* HAS_TRACKER */ + if (tracker_distances != null) + link.printf("c t %d %d\n", tracker_distances[0], tracker_distances[1]); + link.printf("c w\n"); link.flush_output(); }