aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/AdmProtocolDecoder.java40
-rw-r--r--test/org/traccar/protocol/AdmProtocolDecoderTest.java3
2 files changed, 41 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)) {
diff --git a/test/org/traccar/protocol/AdmProtocolDecoderTest.java b/test/org/traccar/protocol/AdmProtocolDecoderTest.java
index bd4624974..599dd6190 100644
--- a/test/org/traccar/protocol/AdmProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/AdmProtocolDecoderTest.java
@@ -14,6 +14,9 @@ public class AdmProtocolDecoderTest extends ProtocolTest {
"010042033836313331313030323639343838320501000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073"));
verifyPosition(decoder, binary(
+ "01002e40041c0744009dfe6742c6c860427402000000f4ff077752c8f55b000000000b4132010213430100041e"));
+
+ verifyPosition(decoder, binary(
"01002680336510002062A34C423DCF8E42A50B1700005801140767E30F568F2534107D220000"));
verifyPosition(decoder, binary(