diff options
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/AdmProtocolDecoder.java | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/AdmProtocolDecoder.java b/src/org/traccar/protocol/AdmProtocolDecoder.java index 1dd2b64f1..52d1439ed 100644 --- a/src/org/traccar/protocol/AdmProtocolDecoder.java +++ b/src/org/traccar/protocol/AdmProtocolDecoder.java @@ -62,7 +62,7 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShortLE() * 0.1)); position.set(Position.KEY_ACCELERATION, buf.readUnsignedByte() * 0.1); - position.setAltitude(buf.readUnsignedShortLE()); + position.setAltitude(buf.readShortLE()); position.set(Position.KEY_HDOP, buf.readUnsignedByte() * 0.1); position.set(Position.KEY_SATELLITES, buf.readUnsignedByte() & 0x0f); @@ -105,7 +105,43 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder { } if (BitUtil.check(type, 6)) { - buf.skipBytes(buf.getUnsignedByte(buf.readerIndex())); + int endIndex = buf.readerIndex() + buf.readUnsignedByte(); + while (buf.readerIndex() < endIndex) { + int mask = buf.readUnsignedByte(); + long value; + switch (BitUtil.from(mask, 6)) { + case 3: + value = buf.readLongLE(); + break; + case 2: + value = buf.readUnsignedIntLE(); + break; + case 1: + value = buf.readUnsignedShortLE(); + break; + default: + value = buf.readUnsignedByte(); + break; + } + int index = BitUtil.to(mask, 6); + switch (index) { + case 1: + position.set(Position.PREFIX_TEMP + 1, value); + break; + case 2: + position.set("humidity", value); + break; + case 3: + position.set("illumination", value); + break; + case 4: + position.set(Position.KEY_BATTERY, value); + break; + default: + position.set("can" + index, value); + break; + } + } } if (BitUtil.check(type, 7)) { |