From 44752e41007aff70d16af5fad6fb49b7ed0ef2b2 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 29 Jul 2024 15:57:14 -0700 Subject: Support Magnet 4G GPS battery --- src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 5 +++++ src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index 443da28a3..c581211ea 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -595,6 +595,11 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { case 0xE2: position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedInt() * 0.1); break; + case 0xE3: + buf.readUnsignedByte(); // reserved + position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + position.set(Position.KEY_BATTERY, buf.readUnsignedShort() / 100.0); + break; case 0xE6: while (buf.readerIndex() < endIndex) { int sensorIndex = buf.readUnsignedByte(); diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java index 286ebfed1..023beaeeb 100644 --- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java @@ -11,6 +11,10 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest { var decoder = inject(new HuabaoProtocolDecoder(null)); + verifyAttribute(decoder, binary( + "7e02000033017051564189000c00000000000c00020158ff7206cd1f4c000000000123201122115639010400000000300143310114930100e3060064019a0000557e"), + Position.KEY_BATTERY_LEVEL, 100); + verifyAttribute(decoder, binary( "7e020000520198080908740af300000000000c000f016602a302c662f802fc000000cc24051618132401040000020f30011e310109f30100610204b056020acd5d0b0102d40379b8011423033c51108017ffffffffffffffffffffffffffffc87e"), Position.PREFIX_TEMP + 1, -32745); -- cgit v1.2.3