diff options
author | Anton Tananaev <anton@traccar.org> | 2023-03-22 09:07:24 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-03-22 09:07:24 -0700 |
commit | f8fb3f67bc0bc44f9da89c3dabbec7406751e3c6 (patch) | |
tree | 16f7b5d68b966451be297bcb3b51fe9798dfd363 /src/main/java/org/traccar/protocol | |
parent | 2bb447924b834693f4d97585f1e5e9e822b62fe3 (diff) | |
download | trackermap-server-f8fb3f67bc0bc44f9da89c3dabbec7406751e3c6.tar.gz trackermap-server-f8fb3f67bc0bc44f9da89c3dabbec7406751e3c6.tar.bz2 trackermap-server-f8fb3f67bc0bc44f9da89c3dabbec7406751e3c6.zip |
Decode TZone magnetic card
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r-- | src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java | 37 |
1 files changed, 23 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); } |