From 025f2dff7c93917484ed7b37ca49d4d958bfe450 Mon Sep 17 00:00:00 2001 From: jcardus Date: Sat, 29 Jun 2024 02:33:39 +0100 Subject: Implemented power and battery for aovx v series --- src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index d010a8fe0..e99caad5e 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -710,6 +710,8 @@ 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); case 0xF3: while (buf.readerIndex() < endIndex) { int extendedType = buf.readUnsignedShort(); @@ -772,6 +774,11 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { } } break; + case 0xF7: + position.set(Position.KEY_BATTERY, buf.readUnsignedInt() * 0.001); + position.set(Position.KEY_CHARGE, buf.readUnsignedByte() >= 2); + position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + break; case 0xFE: if (length == 1) { position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); -- cgit v1.2.3 From 0a2a8f7416e7cab25d49ce2bd6cf3b1aa9ce69da Mon Sep 17 00:00:00 2001 From: jcardus Date: Sat, 29 Jun 2024 02:56:07 +0100 Subject: missing break --- src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index e99caad5e..672d293e1 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -712,6 +712,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { break; case 0xF1: position.set(Position.KEY_POWER, buf.readUnsignedInt() * 0.001); + break; case 0xF3: while (buf.readerIndex() < endIndex) { int extendedType = buf.readUnsignedShort(); -- cgit v1.2.3 From e3ffb16089b742ea3868806237d1e9760395646d Mon Sep 17 00:00:00 2001 From: jcardus Date: Sun, 30 Jun 2024 00:54:55 +0100 Subject: fix KEY_CHARGE remove 2 tests --- .../java/org/traccar/protocol/HuabaoProtocolDecoder.java | 16 ++++++++++++++-- .../org/traccar/protocol/HuabaoProtocolDecoderTest.java | 8 -------- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index 672d293e1..accc3a879 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -777,8 +777,20 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { break; case 0xF7: position.set(Position.KEY_BATTERY, buf.readUnsignedInt() * 0.001); - position.set(Position.KEY_CHARGE, buf.readUnsignedByte() >= 2); - position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + if (length > 4) { + short batteryStatus = buf.readUnsignedByte(); + switch (batteryStatus) { + case 1: + position.set(Position.KEY_CHARGE, false); + break; + case 2: + case 3: + position.set(Position.KEY_CHARGE, true); + } + } + if (length > 5) { + position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + } break; case 0xFE: if (length == 1) { diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java index fa8fb2f29..286ebfed1 100644 --- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java @@ -227,18 +227,10 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "7e0002000004304832546500b7ca7e")); - verifyAttribute(decoder, binary( - "7E020000964130564801050048000000001000004F01651E2E02CAEC3802E80000001524062616002101040000000330011F31010EF1040000308CF231414F56585F564C3330302D4C415F48322E315F4547393135554C4141425230334130324D30385F56322E312E305F763130F3011FF400F5080000000000000001F6084008FFFFFFFD0009F70600000E870246F912000F000000010000062A00082406261600184D7E"), - Position.KEY_BATTERY, 3.719); - verifyAttribute(decoder, binary( "7E020000964130564801050048000000001000004F01651E2E02CAEC3802E80000001524062616002101040000000330011F31010EF1040000308CF231414F56585F564C3330302D4C415F48322E315F4547393135554C4141425230334130324D30385F56322E312E305F763130F3011FF400F5080000000000000001F6084008FFFFFFFD0009F70600000E870246F912000F000000010000062A00082406261600184D7E"), Position.KEY_CHARGE, true); - verifyAttribute(decoder, binary( - "7E020000964130564801050048000000001000004F01651E2E02CAEC3802E80000001524062616002101040000000330011F31010EF1040000308CF231414F56585F564C3330302D4C415F48322E315F4547393135554C4141425230334130324D30385F56322E312E305F763130F3011FF400F5080000000000000001F6084008FFFFFFFD0009F70600000E870246F912000F000000010000062A00082406261600184D7E"), - Position.KEY_BATTERY_LEVEL, 70); - verifyAttribute(decoder, binary( "7E020000964130564801050048000000001000004F01651E2E02CAEC3802E80000001524062616002101040000000330011F31010EF1040000308CF231414F56585F564C3330302D4C415F48322E315F4547393135554C4141425230334130324D30385F56322E312E305F763130F3011FF400F5080000000000000001F6084008FFFFFFFD0009F70600000E870246F912000F000000010000062A00082406261600184D7E"), Position.KEY_POWER, 12.428); -- cgit v1.2.3 From c9a1e9effd1765009d12ffb36281d0755f6dcdb3 Mon Sep 17 00:00:00 2001 From: jcardus Date: Sun, 30 Jun 2024 01:00:03 +0100 Subject: missing default switch --- src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index accc3a879..81f5194c8 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -786,6 +786,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { case 2: case 3: position.set(Position.KEY_CHARGE, true); + default: } } if (length > 5) { -- cgit v1.2.3 From 3be24b6d48ab25b6bac711be2fd124b50505fa65 Mon Sep 17 00:00:00 2001 From: jcardus Date: Sun, 30 Jun 2024 04:24:10 +0100 Subject: Actualizar HuabaoProtocolDecoder.java Co-authored-by: Anton Tananaev --- src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index 81f5194c8..f7145c86a 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -777,7 +777,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { break; case 0xF7: position.set(Position.KEY_BATTERY, buf.readUnsignedInt() * 0.001); - if (length > 4) { + if (length >= 5) { short batteryStatus = buf.readUnsignedByte(); switch (batteryStatus) { case 1: -- cgit v1.2.3 From 836f62d1f58af68d98d3815a67ed82df711c2871 Mon Sep 17 00:00:00 2001 From: jcardus Date: Sun, 30 Jun 2024 04:24:30 +0100 Subject: Actualizar HuabaoProtocolDecoder.java Co-authored-by: Anton Tananaev --- src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index f7145c86a..b1b065780 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -789,7 +789,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { default: } } - if (length > 5) { + if (length >= 6) { position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); } break; -- cgit v1.2.3 From be3180dce3889e201340d1542df46288191ee8f5 Mon Sep 17 00:00:00 2001 From: jcardus Date: Sun, 30 Jun 2024 04:34:25 +0100 Subject: don't store false for KEY_CHARGE --- src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index b1b065780..8afe04d0f 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -780,9 +780,6 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { if (length >= 5) { short batteryStatus = buf.readUnsignedByte(); switch (batteryStatus) { - case 1: - position.set(Position.KEY_CHARGE, false); - break; case 2: case 3: position.set(Position.KEY_CHARGE, true); -- cgit v1.2.3