From 2810e724193fac01e06e8412dae7bde3955fb46b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 29 Nov 2020 08:38:12 -0800 Subject: Decode battery level --- src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 1 + src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index 6d57c3339..b0cd1ab8c 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -317,6 +317,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.1); break; case 0xD4: + case 0xFE: position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); break; case 0xD5: diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java index 8e9e8c1d4..b4a5148d6 100644 --- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java @@ -14,6 +14,10 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "7E01000021013345678906000F002C012F373031313142534A2D4D3742203030303030303001D4C1423838383838B47E")); + verifyAttribute(decoder, binary( + "7e02000033202011200010001300020000000400020158b30006c93ee5002000000000201127162937010400000000fe0145ff0c01cc00000000263300000f3e627e"), + Position.KEY_BATTERY_LEVEL, 69); + verifyPosition(decoder, binary( "7e0200002e202000129707001c0000000000001c0601a2f0a8091f0bf00000000000ed201103031733000000000000000000780000000018000000267e")); -- cgit v1.2.3