Bump java lib versions in preparation for 1.9.2
[fw/altos] / altoslib / AltosTelemetry.java
index fe536c6ac17e4ede763d2bb832b9bb7e1c2f4121..ec3d8495dc1efff7fe65071e42aefecec471936e 100644 (file)
@@ -16,7 +16,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altoslib_12;
+package org.altusmetrum.altoslib_14;
 
 import java.text.*;
 
@@ -28,8 +28,11 @@ public abstract class AltosTelemetry implements AltosDataProvider {
        int[]   bytes;
 
        /* All telemetry packets have these fields */
-       public int rssi() { return AltosConvert.telem_to_rssi(AltosLib.int8(bytes, bytes.length - 3)); }
-       public int status() { return AltosLib.uint8(bytes, bytes.length - 2); }
+       static public int rssi(int[] bytes) { return AltosConvert.telem_to_rssi(AltosLib.int8(bytes, bytes.length - 3)); }
+       static public int status(int[] bytes) { return AltosLib.uint8(bytes, bytes.length - 2); }
+
+       public int rssi() { return rssi(bytes); }
+       public int status() { return status(bytes); }
 
        /* All telemetry packets report these fields in some form */
        public abstract int serial();
@@ -71,12 +74,13 @@ public abstract class AltosTelemetry implements AltosDataProvider {
        final static int packet_type_location = 0x05;
        final static int packet_type_satellite = 0x06;
        final static int packet_type_companion = 0x07;
-       final static int packet_type_mega_sensor = 0x08;
+       final static int packet_type_mega_sensor_mpu = 0x08;
        final static int packet_type_mega_data = 0x09;
        final static int packet_type_metrum_sensor = 0x0a;
        final static int packet_type_metrum_data = 0x0b;
        final static int packet_type_mini2 = 0x10;
        final static int packet_type_mini3 = 0x11;
+       final static int packet_type_mega_sensor_bmx160 = 0x12;
 
        static AltosTelemetry parse_hex(String hex)  throws ParseException, AltosCRCException {
                AltosTelemetry  telem = null;
@@ -96,6 +100,9 @@ public abstract class AltosTelemetry implements AltosDataProvider {
                if (!cksum(bytes))
                        throw new ParseException(String.format("invalid line \"%s\"", hex), 0);
 
+               if ((status(bytes) & PKT_APPEND_STATUS_1_CRC_OK) == 0)
+                       throw new AltosCRCException(rssi(bytes));
+
                /* length, data ..., rssi, status, checksum -- 4 bytes extra */
                switch (bytes.length) {
                case AltosLib.ao_telemetry_standard_len + 4: