From: Keith Packard Date: Tue, 2 Apr 2013 23:44:58 +0000 (-0700) Subject: altoslib: Make any incoming telem packet update the RSSI value X-Git-Tag: altosdroid_v1.2-1~35 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=997cdef3fe04acdd566d287e70981f7b7934d0c8;hp=0cd203e418e73a1f11460425985b7575c2f0a76c altoslib: Make any incoming telem packet update the RSSI value Every packet has RSSI info, so use the latest one available. This makes telegps RSSI available as it never sends sensor packets (having no sensors). Signed-off-by: Keith Packard --- diff --git a/altoslib/AltosTelemetryRecord.java b/altoslib/AltosTelemetryRecord.java index 01215968..fdc3c88e 100644 --- a/altoslib/AltosTelemetryRecord.java +++ b/altoslib/AltosTelemetryRecord.java @@ -80,25 +80,25 @@ public abstract class AltosTelemetryRecord { r = new AltosTelemetryRecordSensor(bytes, rssi); break; case packet_type_configuration: - r = new AltosTelemetryRecordConfiguration(bytes); + r = new AltosTelemetryRecordConfiguration(bytes, rssi); break; case packet_type_location: - r = new AltosTelemetryRecordLocation(bytes); + r = new AltosTelemetryRecordLocation(bytes, rssi); break; case packet_type_satellite: - r = new AltosTelemetryRecordSatellite(bytes); + r = new AltosTelemetryRecordSatellite(bytes, rssi); break; case packet_type_companion: - r = new AltosTelemetryRecordCompanion(bytes); + r = new AltosTelemetryRecordCompanion(bytes, rssi); break; case packet_type_MM_sensor: r = new AltosTelemetryRecordMegaSensor(bytes, rssi); break; case packet_type_MM_data: - r = new AltosTelemetryRecordMegaData(bytes); + r = new AltosTelemetryRecordMegaData(bytes, rssi); break; default: - r = new AltosTelemetryRecordRaw(bytes); + r = new AltosTelemetryRecordRaw(bytes, rssi); break; } break; diff --git a/altoslib/AltosTelemetryRecordCompanion.java b/altoslib/AltosTelemetryRecordCompanion.java index e016dd01..2231df13 100644 --- a/altoslib/AltosTelemetryRecordCompanion.java +++ b/altoslib/AltosTelemetryRecordCompanion.java @@ -21,8 +21,8 @@ public class AltosTelemetryRecordCompanion extends AltosTelemetryRecordRaw { AltosRecordCompanion companion; - public AltosTelemetryRecordCompanion(int[] in_bytes) { - super(in_bytes); + public AltosTelemetryRecordCompanion(int[] in_bytes, int rssi) { + super(in_bytes, rssi); int off = 0; if (uint8(6) == 0) diff --git a/altoslib/AltosTelemetryRecordConfiguration.java b/altoslib/AltosTelemetryRecordConfiguration.java index 472a6318..47fc3488 100644 --- a/altoslib/AltosTelemetryRecordConfiguration.java +++ b/altoslib/AltosTelemetryRecordConfiguration.java @@ -29,8 +29,8 @@ public class AltosTelemetryRecordConfiguration extends AltosTelemetryRecordRaw { String callsign; String version; - public AltosTelemetryRecordConfiguration(int[] in_bytes) { - super(in_bytes); + public AltosTelemetryRecordConfiguration(int[] in_bytes, int rssi) { + super(in_bytes, rssi); device_type = uint8(5); flight = uint16(6); diff --git a/altoslib/AltosTelemetryRecordLocation.java b/altoslib/AltosTelemetryRecordLocation.java index 469a5400..02999696 100644 --- a/altoslib/AltosTelemetryRecordLocation.java +++ b/altoslib/AltosTelemetryRecordLocation.java @@ -37,8 +37,8 @@ public class AltosTelemetryRecordLocation extends AltosTelemetryRecordRaw { int climb_rate; int course; - public AltosTelemetryRecordLocation(int[] in_bytes) { - super(in_bytes); + public AltosTelemetryRecordLocation(int[] in_bytes, int rssi) { + super(in_bytes, rssi); flags = uint8(5); altitude = int16(6); diff --git a/altoslib/AltosTelemetryRecordMegaData.java b/altoslib/AltosTelemetryRecordMegaData.java index 08df9ee1..a484ef4e 100644 --- a/altoslib/AltosTelemetryRecordMegaData.java +++ b/altoslib/AltosTelemetryRecordMegaData.java @@ -35,8 +35,8 @@ public class AltosTelemetryRecordMegaData extends AltosTelemetryRecordRaw { int speed; int height; - public AltosTelemetryRecordMegaData(int[] in_bytes) { - super(in_bytes); + public AltosTelemetryRecordMegaData(int[] in_bytes, int rssi) { + super(in_bytes, rssi); state = int8(5); diff --git a/altoslib/AltosTelemetryRecordMegaSensor.java b/altoslib/AltosTelemetryRecordMegaSensor.java index 7548d699..2a4b17a4 100644 --- a/altoslib/AltosTelemetryRecordMegaSensor.java +++ b/altoslib/AltosTelemetryRecordMegaSensor.java @@ -35,10 +35,8 @@ public class AltosTelemetryRecordMegaSensor extends AltosTelemetryRecordRaw { int mag_y; int mag_z; - int rssi; - - public AltosTelemetryRecordMegaSensor(int[] in_bytes, int in_rssi) { - super(in_bytes); + public AltosTelemetryRecordMegaSensor(int[] in_bytes, int rssi) { + super(in_bytes, rssi); accel = int16(6); pres = int32(8); @@ -55,8 +53,6 @@ public class AltosTelemetryRecordMegaSensor extends AltosTelemetryRecordRaw { mag_x = int16(26); mag_y = int16(28); mag_z = int16(30); - - rssi = in_rssi; } public AltosRecord update_state(AltosRecord previous) { @@ -85,8 +81,6 @@ public class AltosTelemetryRecordMegaSensor extends AltosTelemetryRecordRaw { next.mag.y = mag_y; next.mag.z = mag_z; - next.rssi = rssi; - next.seen |= AltosRecord.seen_sensor; return next; diff --git a/altoslib/AltosTelemetryRecordRaw.java b/altoslib/AltosTelemetryRecordRaw.java index a06348c1..f94789bb 100644 --- a/altoslib/AltosTelemetryRecordRaw.java +++ b/altoslib/AltosTelemetryRecordRaw.java @@ -22,6 +22,7 @@ public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { int serial; int tick; int type; + int rssi; long received_time; @@ -53,11 +54,12 @@ public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { return AltosLib.string(bytes, off + 1, l); } - public AltosTelemetryRecordRaw(int[] in_bytes) { + public AltosTelemetryRecordRaw(int[] in_bytes, int in_rssi) { bytes = in_bytes; serial = uint16(0); tick = uint16(2); type = uint8(4); + rssi = in_rssi; } public AltosRecord update_state(AltosRecord previous) { @@ -69,6 +71,7 @@ public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { next = new AltosRecordNone(); next.serial = serial; next.tick = tick; + next.rssi = rssi; return next; } diff --git a/altoslib/AltosTelemetryRecordSatellite.java b/altoslib/AltosTelemetryRecordSatellite.java index 3e93b337..9835389b 100644 --- a/altoslib/AltosTelemetryRecordSatellite.java +++ b/altoslib/AltosTelemetryRecordSatellite.java @@ -21,8 +21,8 @@ public class AltosTelemetryRecordSatellite extends AltosTelemetryRecordRaw { int channels; AltosGPSSat[] sats; - public AltosTelemetryRecordSatellite(int[] in_bytes) { - super(in_bytes); + public AltosTelemetryRecordSatellite(int[] in_bytes, int rssi) { + super(in_bytes, rssi); channels = uint8(5); if (channels > 12) diff --git a/altoslib/AltosTelemetryRecordSensor.java b/altoslib/AltosTelemetryRecordSensor.java index 767a464a..e0e92c13 100644 --- a/altoslib/AltosTelemetryRecordSensor.java +++ b/altoslib/AltosTelemetryRecordSensor.java @@ -36,10 +36,8 @@ public class AltosTelemetryRecordSensor extends AltosTelemetryRecordRaw { int accel_plus_g; int accel_minus_g; - int rssi; - - public AltosTelemetryRecordSensor(int[] in_bytes, int in_rssi) { - super(in_bytes); + public AltosTelemetryRecordSensor(int[] in_bytes, int rssi) { + super(in_bytes, rssi); state = uint8(5); accel = int16(6); @@ -57,8 +55,6 @@ public class AltosTelemetryRecordSensor extends AltosTelemetryRecordRaw { ground_accel = int16(26); accel_plus_g = int16(28); accel_minus_g = int16(30); - - rssi = in_rssi; } public AltosRecord update_state(AltosRecord prev) { @@ -101,8 +97,6 @@ public class AltosTelemetryRecordSensor extends AltosTelemetryRecordRaw { next.accel_minus_g = AltosRecord.MISSING; } - next.rssi = rssi; - next.seen |= AltosRecord.seen_sensor | AltosRecord.seen_temp_volt; return next;