aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/protocol/T800xProtocolDecoder.java112
-rw-r--r--src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java9
2 files changed, 71 insertions, 50 deletions
diff --git a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
index 8a047fd38..b23e3fa70 100644
--- a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2021 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -191,56 +191,68 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_IGNITION, buf.readUnsignedByte() > 0);
- switch (buf.readUnsignedShort()) {
- case 0x01:
- position.set("tagId", ByteBufUtil.hexDump(buf.readSlice(6)));
- position.set("tagBattery", buf.readUnsignedByte() * 0.01 + 1.22);
- position.set("tirePressure", buf.readUnsignedByte() * 1.527 * 2);
- position.set("tagTemp", buf.readUnsignedByte() - 55);
- position.set("tagStatus", buf.readUnsignedByte());
- break;
- case 0x02:
- position.set("tagId", ByteBufUtil.hexDump(buf.readSlice(6)));
- position.set("tagBattery", BcdUtil.readInteger(buf, 2) * 0.1);
- switch (buf.readUnsignedByte()) {
- case 0:
- position.set(Position.KEY_ALARM, Position.ALARM_SOS);
- break;
- case 1:
+ int i = 1;
+ while (buf.isReadable()) {
+ switch (buf.readUnsignedShort()) {
+ case 0x01:
+ position.set("tag" + i + "Id", ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tag" + i + "Battery", buf.readUnsignedByte() * 0.01 + 1.22);
+ position.set("tag" + i + "TirePressure", buf.readUnsignedByte() * 1.527 * 2);
+ position.set("tag" + i + "TireTemp", buf.readUnsignedByte() - 55);
+ position.set("tag" + i + "TireStatus", buf.readUnsignedByte());
+ break;
+ case 0x02:
+ position.set("tag" + i + "Id", ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tag" + i + "Battery", BcdUtil.readInteger(buf, 2) * 0.1);
+ switch (buf.readUnsignedByte()) {
+ case 0:
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ break;
+ case 1:
+ position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
+ break;
+ default:
+ break;
+ }
+ buf.readUnsignedByte(); // status
+ buf.skipBytes(16); // location
+ break;
+ case 0x03:
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tag" + i + "Battery", BcdUtil.readInteger(buf, 2) * 0.1);
+ if (buf.readUnsignedByte() == 1) {
position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
- break;
- default:
- break;
- }
- break;
- case 0x03:
- position.set(Position.KEY_DRIVER_UNIQUE_ID, ByteBufUtil.hexDump(buf.readSlice(6)));
- position.set("tagBattery", BcdUtil.readInteger(buf, 2) * 0.1);
- if (buf.readUnsignedByte() == 1) {
- position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
- }
- break;
- case 0x04:
- position.set("tagId", ByteBufUtil.hexDump(buf.readSlice(6)));
- position.set("tagBattery", buf.readUnsignedByte() * 0.01 + 2);
- buf.readUnsignedByte(); // battery level
- position.set(Position.KEY_DEVICE_TEMP, buf.readUnsignedShort() * 0.01);
- position.set("humidity", buf.readUnsignedShort() * 0.01);
- position.set("lightSensor", BitUtil.to(buf.readUnsignedByte(), 15));
- break;
- case 0x05:
- position.set("tagId", ByteBufUtil.hexDump(buf.readSlice(6)));
- position.set("tagBattery", buf.readUnsignedByte() * 0.01 + 2);
- position.set(Position.KEY_DEVICE_TEMP, buf.readUnsignedShort() * 0.01);
- position.set(Position.KEY_DOOR, buf.readUnsignedByte() > 0);
- break;
- case 0x06:
- position.set("tagId", ByteBufUtil.hexDump(buf.readSlice(6)));
- position.set("tagBattery", buf.readUnsignedByte() * 0.01 + 2);
- position.set(Position.KEY_OUTPUT, buf.readUnsignedByte() > 0);
- break;
- default:
- break;
+ }
+ buf.readUnsignedByte(); // status
+ buf.skipBytes(16); // location
+ break;
+ case 0x04:
+ position.set("tag" + i + "Id", ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tag" + i + "Battery", buf.readUnsignedByte() * 0.01 + 2);
+ buf.readUnsignedByte(); // battery level
+ position.set("tag" + i + "Temp", buf.readUnsignedShort() * 0.01);
+ position.set("tag" + i + "Humidity", buf.readUnsignedShort() * 0.01);
+ position.set("tag" + i + "LightSensor", buf.readUnsignedShort());
+ position.set("tag" + i + "Rssi", buf.readUnsignedByte() - 128);
+ break;
+ case 0x05:
+ position.set("tag" + i + "Id", ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tag" + i + "Battery", buf.readUnsignedByte() * 0.01 + 2);
+ buf.readUnsignedByte(); // battery level
+ position.set("tag" + i + "Temp", buf.readUnsignedShort() * 0.01);
+ position.set("tag" + i + "Door", buf.readUnsignedByte() > 0);
+ position.set("tag" + i + "Rssi", buf.readUnsignedByte() - 128);
+ break;
+ case 0x06:
+ position.set("tag" + i + "Id", ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tag" + i + "Battery", buf.readUnsignedByte() * 0.01 + 2);
+ position.set("tag" + i + "Output", buf.readUnsignedByte() > 0);
+ position.set("tag" + i + "Rssi", buf.readUnsignedByte() - 128);
+ break;
+ default:
+ break;
+ }
+ i += 1;
}
sendResponse(channel, header, type, index, imei, 0);
diff --git a/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java
index 9fb57f400..61fb658a6 100644
--- a/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java
@@ -12,6 +12,15 @@ public class T800xProtocolDecoderTest extends ProtocolTest {
var decoder = new T800xProtocolDecoder(null);
verifyAttributes(decoder, binary(
+ "27271000247bd00860112047066487210407034238000005d7d17365e625ff640a730148"));
+
+ verifyAttributes(decoder, binary(
+ "27271000277bb30860112047066487210407022840000004e6215130c50fff620a0c1518000156"));
+
+ verifyPosition(decoder, binary(
+ "27270200497d880860112047066487470021040702270500006442d4e2e342f671b441000000008000008080881dff3900000384700640003c0000001e1e00641e30d2800000000000"));
+
+ verifyAttributes(decoder, binary(
"252510003100180865284041080544201221191023000003ffff9702eff820014700000000912a6ac26dff09c200000000"));
verifyAttribute(decoder, binary(