aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/H02ProtocolDecoder.java23
-rw-r--r--src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java3
2 files changed, 13 insertions, 13 deletions
diff --git a/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java b/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
index c4443a00b..6f1a4f01e 100644
--- a/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
@@ -88,19 +88,16 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
}
private Integer decodeBattery(int value) {
- switch (value) {
- case 6:
- return 100;
- case 5:
- return 80;
- case 4:
- return 60;
- case 3:
- return 20;
- case 2:
- return 10;
- default:
- return null;
+ if (value <= 3) {
+ return (value - 1) * 10;
+ } else if (value <= 6) {
+ return (value - 1) * 20;
+ } else if (value <= 100) {
+ return value;
+ } else if (value >= 0xF1 && value <= 0xF6) {
+ return value - 0xF0;
+ } else {
+ return null;
}
}
diff --git a/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java
index 4a5eadf52..c69dffce7 100644
--- a/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class H02ProtocolDecoderTest extends ProtocolTest {
H02ProtocolDecoder decoder = new H02ProtocolDecoder(null);
+ verifyPosition(decoder, binary(
+ "24702802061601234020031910125482600612695044000000ffffbbff000000000000000001760d04e2c9934d"));
+
verifyNotNull(decoder, buffer(
"*hq,356327081001239,VP1,V,470,002,92,3565,0Y92,19433,30Y92,1340,29#"));