diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-05-23 11:26:54 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-05-23 11:26:54 -0700 |
commit | 410260640a5e58b6f3816e987470da0143337490 (patch) | |
tree | 44e707584913c63b92e7c6fba7faa3856387c727 /src | |
parent | 8b29c4b31db0a9552ed2106ca8d2030fca6edea9 (diff) | |
download | traccar-server-410260640a5e58b6f3816e987470da0143337490.tar.gz traccar-server-410260640a5e58b6f3816e987470da0143337490.tar.bz2 traccar-server-410260640a5e58b6f3816e987470da0143337490.zip |
Fix temperature decoding
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java | 12 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java index f60cead10..6d49be0ce 100644 --- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -295,7 +295,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { return true; } - private boolean decodeStatus(Position position, ByteBuf buf) { + private boolean decodeStatus(Position position, ByteBuf buf, boolean batteryLevel) { int status = buf.readUnsignedByte(); @@ -324,7 +324,11 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { break; } - position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte() * 100 / 6); + if (batteryLevel) { + position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte() * 100 / 6); + } else { + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01); + } position.set(Position.KEY_RSSI, buf.readUnsignedByte()); position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); @@ -866,7 +870,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } if (hasStatus(type)) { - decodeStatus(position, buf); + decodeStatus(position, buf, true); } if (type == MSG_GPS_LBS_1 && buf.readableBytes() > 75 + 6) { @@ -878,7 +882,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } if (type == MSG_GPS_LBS_1 && buf.readableBytes() == 18) { - decodeStatus(position, buf); + decodeStatus(position, buf, false); position.set("oil", buf.readUnsignedShort()); int temperature = buf.readUnsignedByte(); if (BitUtil.check(temperature, 7)) { diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java index f285fde97..ab1fc33f4 100644 --- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -19,7 +19,7 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyAttribute(decoder, binary( "78782b1215050d03041bcf031ff30a0be795bc001c17014e14a065dd95314504b6040000001c00000cd90ab8fb6f0d0a"), - Position.PREFIX_TEMP + 1, 0); + Position.PREFIX_TEMP + 1, 0x1c); verifyAttribute(decoder, binary( "7878151330802b00000642014f0008720000802b5ee4d4c90d0a"), |