diff options
author | Anton Tananaev <anton@traccar.org> | 2023-10-17 21:02:34 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-10-17 21:02:34 -0700 |
commit | 37ed394724c0bdcc6f98f421e71d76916206ed30 (patch) | |
tree | 8d73c34dad60ff05f22d24e37bcec1da2ca9a7b4 | |
parent | d3631eb7286338a0ea046a511aa5cbfce470c7b7 (diff) | |
download | trackermap-server-37ed394724c0bdcc6f98f421e71d76916206ed30.tar.gz trackermap-server-37ed394724c0bdcc6f98f421e71d76916206ed30.tar.bz2 trackermap-server-37ed394724c0bdcc6f98f421e71d76916206ed30.zip |
Seeworld battery level decoding
-rw-r--r-- | src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java | 3 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java index f676e7363..cf7cd12d3 100644 --- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -841,7 +841,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // working mode position.set(Position.KEY_POWER, buf.readUnsignedShort() / 100.0); } else { - position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte() * 100 / 6); + int battery = buf.readUnsignedByte(); + position.set(Position.KEY_BATTERY_LEVEL, battery <= 6 ? battery * 100 / 6 : battery); position.set(Position.KEY_RSSI, buf.readUnsignedByte()); short alarmExtension = buf.readUnsignedByte(); if (variant != Variant.VXT01) { diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 8e60fb342..be8f4f5ef 100644 --- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -18,6 +18,10 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { "78780D01086471700328358100093F040D0A")); verifyAttribute(decoder, binary( + "78782616170A080C0E24C0027C58AD0C2B8B0100454E0901CC0025030328E7A0005D4B13021EC373170D0A"), + Position.KEY_BATTERY_LEVEL, 93); + + verifyAttribute(decoder, binary( "787826161709130f3a2dcc02c55f2a089f9af9005c210901360481fe066d9b03413e420102035f92fe0d0a"), Position.KEY_ALARM, Position.ALARM_SOS); |