diff options
author | Anton Tananaev <anton@traccar.org> | 2024-01-18 06:44:11 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-01-18 06:44:11 -0800 |
commit | 2eba0bdf8c02036d6761667f0aa022ead9587c11 (patch) | |
tree | 8144a9152c94dab87f864cfd5db998030199e82a /src | |
parent | 79a4cf9355b08e0b306146a94bd65adb5ed963a5 (diff) | |
download | trackermap-server-2eba0bdf8c02036d6761667f0aa022ead9587c11.tar.gz trackermap-server-2eba0bdf8c02036d6761667f0aa022ead9587c11.tar.bz2 trackermap-server-2eba0bdf8c02036d6761667f0aa022ead9587c11.zip |
Add MT700 battery (fix #5197)
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java | 10 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java | 5 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java index 2e7cdde4e..79488acc0 100644 --- a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java @@ -55,7 +55,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN_POSITION = new PatternBuilder() .text("#") - .number("(?:(dd)|x*)") // cell or voltage + .number("(?:(dd|dddd)|x*)") // cell or voltage .groupBegin() .number("#(d+),") // mcc .number("(d+),") // mnc @@ -77,7 +77,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN_WIFI = new PatternBuilder() .text("#") - .number("(?:(dd)|x+)") // cell or voltage + .number("(?:(dd|dddd)|x+)") // cell or voltage .expression("#?") .groupBegin() .number("(d+),") // mcc @@ -179,7 +179,8 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { if (parser.matches()) { if (parser.hasNext()) { - position.set(Position.KEY_BATTERY, parser.nextInt() * 0.1); + int voltage = parser.nextInt(); + position.set(Position.KEY_BATTERY, voltage > 100 ? voltage * 0.001 : voltage * 0.1); } if (parser.hasNext(4)) { @@ -211,7 +212,8 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { if (parser.matches()) { if (parser.hasNext()) { - position.set(Position.KEY_BATTERY, parser.nextInt() * 0.1); + int voltage = parser.nextInt(); + position.set(Position.KEY_BATTERY, voltage > 100 ? voltage * 0.001 : voltage * 0.1); } Network network = new Network(); diff --git a/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java index cdfae465c..a64a10450 100644 --- a/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java @@ -11,6 +11,11 @@ public class Tlt2hProtocolDecoderTest extends ProtocolTest { var decoder = inject(new Tlt2hProtocolDecoder(null)); + verifyAttribute(decoder, text( + "#867665041689485#MT700N#0000#HT#1\r\n", + "#5065$GPRMC,148996.00,A,2485.2458,N,01258.4535,E,,,151348,,,A*5D\r\n"), + Position.KEY_BATTERY, 5.065); + verifyPositions(decoder, false, text( "#862255061983166#MT700NW#0000#TOWED#1\r\n", "#4502$WIFI,051550.00,A,-50,7683C2CBC0B0,-51,7683C29BC0B0,-51,7683C2BBC0B0,-51,7483C2DBC0B0,-51,7683C2ABC0B0,221123*78\r\n")); |