diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-11-24 10:26:45 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-11-24 10:26:45 -0800 |
commit | e3aceea851c2c2b234b56cbef38e6c16f33726a0 (patch) | |
tree | 7fbd9bd272d6a4124d5b6bb9cb48021e497a6312 | |
parent | f1a283153c790434087a6b5011e7a50c78a5ad55 (diff) | |
download | trackermap-server-e3aceea851c2c2b234b56cbef38e6c16f33726a0.tar.gz trackermap-server-e3aceea851c2c2b234b56cbef38e6c16f33726a0.tar.bz2 trackermap-server-e3aceea851c2c2b234b56cbef38e6c16f33726a0.zip |
Decode battery voltage
-rw-r--r-- | src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 8 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java | 5 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index a1987ee5a..342edb22b 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -215,6 +215,13 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { case 0x31: position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); break; + case 0x33: + String sentence = buf.readCharSequence(length, StandardCharsets.US_ASCII).toString(); + if (sentence.startsWith("*M00")) { + String lockStatus = sentence.substring(8, 8 + 7); + position.set(Position.KEY_BATTERY, Integer.parseInt(lockStatus.substring(2, 5)) * 0.01); + } + break; case 0x91: position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.1); position.set(Position.KEY_RPM, buf.readUnsignedShort()); @@ -245,6 +252,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.1); break; default: + System.out.print(String.format("%02x ", subtype)); break; } buf.readerIndex(endIndex); diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java index 321a422f4..8050d07a1 100644 --- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java @@ -2,6 +2,7 @@ package org.traccar.protocol; import org.junit.Test; import org.traccar.ProtocolTest; +import org.traccar.model.Position; public class HuabaoProtocolDecoderTest extends ProtocolTest { @@ -13,6 +14,10 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "7E01000021013345678906000F002C012F373031313142534A2D4D3742203030303030303001D4C1423838383838B47E")); + verifyAttribute(decoder, binary( + "7e02000054086031592715006e0000000000000002015a3c1a06c8733800000000000019103022183633362a4d30302c34352c31313338363030526f79314f70656e26303030303030303030303030263132333435363738393031323334353623ff7e"), + Position.KEY_BATTERY, 3.86); + verifyPosition(decoder, binary( "7e0200004e08026300003006480000000000000007021477d90841920700000000005019110515194001040000167130011631010cd00400000400d3020027d4013fd6143839363130313832303030343833363532383330da0104897e")); |