aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/protocol/T800xProtocolDecoder.java8
-rw-r--r--src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java4
2 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
index 3331ebb71..5822d6b8f 100644
--- a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
@@ -230,10 +230,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
int battery = BcdUtil.readInteger(buf, 2);
- if (battery == 0) {
- battery = 100;
- }
- position.set(Position.KEY_BATTERY, battery);
+ position.set(Position.KEY_BATTERY_LEVEL, battery > 0 ? battery : 100);
}
@@ -284,7 +281,8 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
}
position.set(Position.KEY_G_SENSOR, "[" + accelerationX + "," + accelerationY + "," + accelerationZ + "]");
- position.set(Position.KEY_BATTERY_LEVEL, BcdUtil.readInteger(buf, 2));
+ int battery = BcdUtil.readInteger(buf, 2);
+ position.set(Position.KEY_BATTERY_LEVEL, battery > 0 ? battery : 100);
position.set(Position.KEY_DEVICE_TEMP, (int) buf.readByte());
position.set("lightSensor", BcdUtil.readInteger(buf, 2) * 0.1);
position.set(Position.KEY_BATTERY, BcdUtil.readInteger(buf, 2) * 0.1);
diff --git a/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java
index 48c535c96..d2532d091 100644
--- a/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java
@@ -11,6 +11,10 @@ public class T800xProtocolDecoderTest extends ProtocolTest {
T800xProtocolDecoder decoder = new T800xProtocolDecoder(null);
+ verifyAttribute(decoder, binary(
+ "2727020049052e086528404072393849002008060310110000000068b7c8c286eaa441000000008000008100001617410700019ce782b0001e000002581e00000530d4801f00000000"),
+ Position.KEY_BATTERY_LEVEL, 100);
+
verifyPosition(decoder, binary(
"262602005308090865284040309670000f000f0f0000005a47c000050100000020000000008bfd0020022505185300004041dcc9d6c243b3c6410000012712400000000009e2ffffffffffffffffffffffff09"));