aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-10-09 16:24:37 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-10-09 16:24:37 -0700
commit1ed18df76447d01ace02ec29856d4bd9c7720e83 (patch)
tree5525407ff9476e51ed90803183b2bd2f1f437ae2 /src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java
parent91e6409a0c012106cec454e5953fab2e4b558972 (diff)
downloadtrackermap-server-1ed18df76447d01ace02ec29856d4bd9c7720e83.tar.gz
trackermap-server-1ed18df76447d01ace02ec29856d4bd9c7720e83.tar.bz2
trackermap-server-1ed18df76447d01ace02ec29856d4bd9c7720e83.zip
Fix decoding
Diffstat (limited to 'src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java b/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java
index 4680e0a2f..b8477dcb6 100644
--- a/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TzoneProtocolDecoder.java
@@ -288,7 +288,7 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
blockLength = buf.readUnsignedShort();
blockEnd = buf.readerIndex() + blockLength;
- if (blockLength >= 13) {
+ if (hardware == 0x407 || blockLength >= 13) {
position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
position.set("terminalInfo", buf.readUnsignedByte());
@@ -312,9 +312,16 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort());
} else {
- position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedShort());
- position.set("humidity", buf.readUnsignedShort());
- position.set("lightSensor", buf.readUnsignedByte());
+ int temperature = buf.readUnsignedShort();
+ if (!BitUtil.check(temperature, 15)) {
+ double value = BitUtil.to(temperature, 14) * 0.01;
+ position.set(Position.PREFIX_TEMP + 1, BitUtil.check(temperature, 14) ? -value : value);
+ }
+ int humidity = buf.readUnsignedShort();
+ if (!BitUtil.check(humidity, 15)) {
+ position.set("humidity", BitUtil.to(humidity, 15));
+ }
+ position.set("lightSensor", buf.readUnsignedByte() == 0);
}
}