altoslib: Parse TeleGPS state value from GPS telemetry packet
authorKeith Packard <keithp@keithp.com>
Sun, 8 Jun 2014 04:13:40 +0000 (21:13 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 8 Jun 2014 04:13:40 +0000 (21:13 -0700)
TeleGPS adds 0x80 to the state value to signify that this otherwise
unused byte contains the current state value

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosGPS.java
altoslib/AltosState.java
altoslib/AltosTelemetryLocation.java

index 2708d026e840184a0013c8b632a26a1ffe7780db..f28108334ade41b1f9400e3a61c31557c1037524 100644 (file)
@@ -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;
                }
        }
 
index ddda82b9e4fd3a686ff8cac1eead1b3e8a0a38bd..ef3a09766adc68e69c60e09b725f2358aa56ffbc 100644 (file)
@@ -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) {
index 8368188f895492d42b83385babb524836e1a0b68..67705cde57750df8d724f0011b34ab04383799db 100644 (file)
@@ -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;