aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2024-06-30 07:02:30 -0700
committerGitHub <noreply@github.com>2024-06-30 07:02:30 -0700
commit890d896eed89f33b9d71e894639cc8ec46ec0d68 (patch)
treebf63b405b600142652efce4b19f0fed87689aa38 /src
parent9c2c1566ab292ecc351c273c2ab0f3faf75a7daf (diff)
parentbe3180dce3889e201340d1542df46288191ee8f5 (diff)
downloadtrackermap-server-890d896eed89f33b9d71e894639cc8ec46ec0d68.tar.gz
trackermap-server-890d896eed89f33b9d71e894639cc8ec46ec0d68.tar.bz2
trackermap-server-890d896eed89f33b9d71e894639cc8ec46ec0d68.zip
Merge pull request #5358 from jcardus/huabao
Implemented power and battery for aovx v series
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java18
-rw-r--r--src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java8
2 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index d010a8fe0..8afe04d0f 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -710,6 +710,9 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
break;
+ case 0xF1:
+ position.set(Position.KEY_POWER, buf.readUnsignedInt() * 0.001);
+ break;
case 0xF3:
while (buf.readerIndex() < endIndex) {
int extendedType = buf.readUnsignedShort();
@@ -772,6 +775,21 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
}
}
break;
+ case 0xF7:
+ position.set(Position.KEY_BATTERY, buf.readUnsignedInt() * 0.001);
+ if (length >= 5) {
+ short batteryStatus = buf.readUnsignedByte();
+ switch (batteryStatus) {
+ case 2:
+ case 3:
+ position.set(Position.KEY_CHARGE, true);
+ default:
+ }
+ }
+ if (length >= 6) {
+ position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte());
+ }
+ break;
case 0xFE:
if (length == 1) {
position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte());
diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
index 2ba37ab09..286ebfed1 100644
--- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
@@ -227,6 +227,14 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"7e0002000004304832546500b7ca7e"));
+ verifyAttribute(decoder, binary(
+ "7E020000964130564801050048000000001000004F01651E2E02CAEC3802E80000001524062616002101040000000330011F31010EF1040000308CF231414F56585F564C3330302D4C415F48322E315F4547393135554C4141425230334130324D30385F56322E312E305F763130F3011FF400F5080000000000000001F6084008FFFFFFFD0009F70600000E870246F912000F000000010000062A00082406261600184D7E"),
+ Position.KEY_CHARGE, true);
+
+ verifyAttribute(decoder, binary(
+ "7E020000964130564801050048000000001000004F01651E2E02CAEC3802E80000001524062616002101040000000330011F31010EF1040000308CF231414F56585F564C3330302D4C415F48322E315F4547393135554C4141425230334130324D30385F56322E312E305F763130F3011FF400F5080000000000000001F6084008FFFFFFFD0009F70600000E870246F912000F000000010000062A00082406261600184D7E"),
+ Position.KEY_POWER, 12.428);
+
}
}