From: Keith Packard Date: Sun, 8 Jun 2014 04:13:40 +0000 (-0700) Subject: altoslib: Parse TeleGPS state value from GPS telemetry packet X-Git-Tag: 1.3.2.4~5 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=d69547796caf74405f8304d23d4ae318315bbd7b altoslib: Parse TeleGPS state value from GPS telemetry packet TeleGPS adds 0x80 to the state value to signify that this otherwise unused byte contains the current state value Signed-off-by: Keith Packard --- diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index 2708d026..f2810833 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -45,6 +45,10 @@ public class AltosGPS implements Cloneable { public int h_error; /* m */ public int v_error; /* m */ + public int state; /* for TeleGPS */ + + static final int AO_GPS_STATE_VALID = 0x80; + public AltosGPSSat[] cc_gps_sat; /* tracking data */ public void ParseGPSDate(String date) throws ParseException { @@ -298,6 +302,7 @@ public class AltosGPS implements Cloneable { g.hdop = hdop; /* unitless? */ g.h_error = h_error; /* m */ g.v_error = v_error; /* m */ + g.state = state; if (cc_gps_sat != null) { g.cc_gps_sat = new AltosGPSSat[cc_gps_sat.length]; @@ -330,6 +335,7 @@ public class AltosGPS implements Cloneable { hdop = old.hdop; /* unitless? */ h_error = old.h_error; /* m */ v_error = old.v_error; /* m */ + state = old.state; if (old.cc_gps_sat != null) { cc_gps_sat = new AltosGPSSat[old.cc_gps_sat.length]; @@ -345,6 +351,7 @@ public class AltosGPS implements Cloneable { alt = AltosLib.MISSING; ClearGPSTime(); cc_gps_sat = null; + state = 0; } } diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index ddda82b9..ef3a0976 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -918,6 +918,9 @@ public class AltosState implements Cloneable { elevation = from_pad.elevation; range = from_pad.range; } + + if ((gps.state & AltosGPS.AO_GPS_STATE_VALID) != 0) + set_state (gps.state & ~(AltosGPS.AO_GPS_STATE_VALID)); } public void set_tick(int new_tick) { diff --git a/altoslib/AltosTelemetryLocation.java b/altoslib/AltosTelemetryLocation.java index 8368188f..67705cde 100644 --- a/altoslib/AltosTelemetryLocation.java +++ b/altoslib/AltosTelemetryLocation.java @@ -36,6 +36,7 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard { int ground_speed; int climb_rate; int course; + int state; public AltosTelemetryLocation(int[] bytes) { super(bytes); @@ -57,6 +58,7 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard { ground_speed = uint16(26); climb_rate = int16(28); course = uint8(30); + state = uint8(31); } public void update_state(AltosState state) { @@ -66,6 +68,7 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard { gps.nsat = flags & 0xf; gps.locked = (flags & (1 << 4)) != 0; gps.connected = (flags & (1 << 5)) != 0; + gps.state = this.state; if (gps.locked) { gps.lat = latitude * 1.0e-7;