aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-10-27 07:17:25 -0700
committerAnton Tananaev <anton@traccar.org>2022-10-27 07:17:25 -0700
commitab10e710a9c57ef761ea9955198273db5f473581 (patch)
treef10fd94744012bf8d554393c180fff77b7499576 /src/main/java/org/traccar/protocol
parentcf59eb2c734f7d8bd5ea8f9ff82d4dc91492693f (diff)
downloadtrackermap-server-ab10e710a9c57ef761ea9955198273db5f473581.tar.gz
trackermap-server-ab10e710a9c57ef761ea9955198273db5f473581.tar.bz2
trackermap-server-ab10e710a9c57ef761ea9955198273db5f473581.zip
Fix DT700 temperature decoding
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index b6940aecf..27a5094a0 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -408,6 +408,13 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private double decodeCustomDouble(ByteBuf buf) {
+ int b1 = buf.readByte();
+ int b2 = buf.readUnsignedByte();
+ int sign = b1 != 0 ? b1 / Math.abs(b1) : 1;
+ return sign * (Math.abs(b1) + b2 / 255.0);
+ }
+
private Position decodeLocation(DeviceSession deviceSession, ByteBuf buf) {
Position position = new Position(getProtocolName());
@@ -529,12 +536,8 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
while (buf.readerIndex() < endIndex) {
int sensorIndex = buf.readUnsignedByte();
buf.skipBytes(6); // mac
- position.set(
- Position.PREFIX_TEMP + sensorIndex,
- buf.readUnsignedByte() + buf.readUnsignedByte() * 0.01);
- position.set(
- "humidity" + sensorIndex,
- buf.readUnsignedByte() + buf.readUnsignedByte() * 0.01);
+ position.set(Position.PREFIX_TEMP + sensorIndex, decodeCustomDouble(buf));
+ position.set("humidity" + sensorIndex, decodeCustomDouble(buf));
}
break;
case 0xEB: