aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java4
-rw-r--r--src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java4
2 files changed, 7 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java
index 5ba053df3..2e7cdde4e 100644
--- a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java
@@ -210,7 +210,9 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
parser = new Parser(PATTERN_WIFI, message);
if (parser.matches()) {
- position.set(Position.KEY_BATTERY, parser.nextInt() * 0.1);
+ if (parser.hasNext()) {
+ position.set(Position.KEY_BATTERY, parser.nextInt() * 0.1);
+ }
Network network = new Network();
if (parser.hasNext(4)) {
diff --git a/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java
index 63aa3ebc0..cdfae465c 100644
--- a/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java
@@ -12,6 +12,10 @@ public class Tlt2hProtocolDecoderTest extends ProtocolTest {
var decoder = inject(new Tlt2hProtocolDecoder(null));
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"));
+
+ verifyPositions(decoder, false, text(
"#862255061825896#MT710#0000#TOWED#1\r\n",
"#39#$WIFI,015259.00,A,-47,7483C2DBC0B0,-48,7683C2ABC0B0,-48,7683C29BC0B0,-48,7683C2CBC0B0,-48,7683C2BBC0B0,151123*74\r\n"));