aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-03-22 09:07:24 -0700
committerAnton Tananaev <anton@traccar.org>2023-03-22 09:07:24 -0700
commitf8fb3f67bc0bc44f9da89c3dabbec7406751e3c6 (patch)
tree16f7b5d68b966451be297bcb3b51fe9798dfd363
parent2bb447924b834693f4d97585f1e5e9e822b62fe3 (diff)
downloadtrackermap-server-f8fb3f67bc0bc44f9da89c3dabbec7406751e3c6.tar.gz
trackermap-server-f8fb3f67bc0bc44f9da89c3dabbec7406751e3c6.tar.bz2
trackermap-server-f8fb3f67bc0bc44f9da89c3dabbec7406751e3c6.zip
Decode TZone magnetic card
-rw-r--r--src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java37
-rw-r--r--src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java4
2 files changed, 27 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java b/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java
index 8e84a6781..ba9b41654 100644
--- a/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java
@@ -204,30 +204,39 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
}
- private void decodeTags(Position position, ByteBuf buf) {
+ private void decodeTags(Position position, ByteBuf buf, int hardware) {
int blockLength = buf.readUnsignedShort();
int blockEnd = buf.readerIndex() + blockLength;
if (blockLength > 0) {
- buf.readUnsignedByte(); // tag type
+ int type = buf.readUnsignedByte();
- int count = buf.readUnsignedByte();
- int tagLength = buf.readUnsignedByte();
+ if (hardware != 0x153 || type >= 2) {
- for (int i = 1; i <= count; i++) {
- int tagEnd = buf.readerIndex() + tagLength;
+ int count = buf.readUnsignedByte();
+ int tagLength = buf.readUnsignedByte();
+
+ for (int i = 1; i <= count; i++) {
+ int tagEnd = buf.readerIndex() + tagLength;
+
+ buf.readUnsignedByte(); // status
+ buf.readUnsignedShortLE(); // battery voltage
- buf.readUnsignedByte(); // status
- buf.readUnsignedShortLE(); // battery voltage
+ position.set(Position.PREFIX_TEMP + i, (buf.readShortLE() & 0x3fff) * 0.1);
+
+ buf.readUnsignedByte(); // humidity
+ buf.readUnsignedByte(); // rssi
+
+ buf.readerIndex(tagEnd);
+ }
- position.set(Position.PREFIX_TEMP + i, (buf.readShortLE() & 0x3fff) * 0.1);
+ } else if (type == 1) {
- buf.readUnsignedByte(); // humidity
- buf.readUnsignedByte(); // rssi
+ position.set("driverLicense", buf.readCharSequence(
+ blockEnd - buf.readerIndex(), StandardCharsets.UTF_8).toString());
- buf.readerIndex(tagEnd);
}
}
@@ -364,9 +373,9 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
}
- if (hardware == 0x406) {
+ if (hardware == 0x153 || hardware == 0x406) {
- decodeTags(position, buf);
+ decodeTags(position, buf, hardware);
}
diff --git a/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java
index 4813021fd..8fdc8c23c 100644
--- a/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java
@@ -10,6 +10,10 @@ public class TzoneProtocolDecoderTest extends ProtocolTest {
var decoder = inject(new TzoneProtocolDecoder(null));
+ verifyAttribute(decoder, binary(
+ "545a00d424240153011300000863835029944118170316023b180016040485c73d2479187e170316023b1800000000060c000000000d1cc0406303019904aa00000000008a012520205e544f4e474c4f4d245049544f4f4e244d522e5e5e3f3b363030373634333132303130303134323234323d3139303631393538313032363d3f2b2020202020202020202020202032322020202020202020202020203120202020202020202020202030303234363238202031303730302020202020202020202020202020202020202020203f00030080000006e80e0d0a"),
+ "driverLicense", "% ^TONGLOM$PITOON$MR.^^?;6007643120100142242=190619581026=?+ 22 1 0024628 10700 ?");
+
verifyAttributes(decoder, binary(
"545a003724240407020200000180322000001610160b151019100000000c010a07320101088600007dca000baa102837016a0114025500000169e80d0a"));