aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-01-19 18:42:06 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-01-19 18:42:06 -0800
commitc9e760c301fb2867769d842d35e5c51e3bb843d6 (patch)
treead76555d82e678b213af5ed32789b6eebd7f3242
parentce11cf209314dad9f7faa4c942e248ca5f64bc12 (diff)
downloadtraccar-server-c9e760c301fb2867769d842d35e5c51e3bb843d6.tar.gz
traccar-server-c9e760c301fb2867769d842d35e5c51e3bb843d6.tar.bz2
traccar-server-c9e760c301fb2867769d842d35e5c51e3bb843d6.zip
Decode fuel data
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java20
-rw-r--r--src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java4
2 files changed, 24 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index f425ec86f..bf5b6d89a 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -251,6 +251,26 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
case 0xD3:
position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.1);
break;
+ case 0xEB:
+ while (buf.readerIndex() < endIndex) {
+ int tenetLength = buf.readUnsignedShort();
+ int tenetType = buf.readUnsignedShort();
+ switch (tenetType) {
+ case 0x0001:
+ position.set("fuel1", buf.readUnsignedShort() * 0.1);
+ buf.readUnsignedByte(); // unused
+ break;
+ case 0x0023:
+ buf.skipBytes(4); // unused
+ position.set("fuel2", Double.parseDouble(
+ buf.readCharSequence(2, StandardCharsets.US_ASCII).toString()));
+ break;
+ default:
+ buf.skipBytes(tenetLength - 2);
+ break;
+ }
+ }
+ break;
default:
break;
}
diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
index 8050d07a1..c5e8d5b2a 100644
--- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
@@ -15,6 +15,10 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest {
"7E01000021013345678906000F002C012F373031313142534A2D4D3742203030303030303001D4C1423838383838B47E"));
verifyAttribute(decoder, binary(
+ "7E0200005C087034547007000B0000000000040003015A7CEF06CF8A84000000000000200108064451570800000000000000000104000000005309010000000000000000300113310109EB1D000800233030302E3838000A0003001A00000000000000050001037700B27E"),
+ "fuel1", 88.7);
+
+ verifyAttribute(decoder, binary(
"7e02000054086031592715006e0000000000000002015a3c1a06c8733800000000000019103022183633362a4d30302c34352c31313338363030526f79314f70656e26303030303030303030303030263132333435363738393031323334353623ff7e"),
Position.KEY_BATTERY, 3.86);