aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java12
-rw-r--r--src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java2
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"),