From 0d491bc058de127bbcc8c014fe9a18e89544f1bb Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 1 Jun 2021 21:59:48 -0700 Subject: Ignore empty locations (fix #4687) --- src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java | 5 ++++- src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java index 2bfc08c75..ad7dfa886 100644 --- a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java @@ -179,6 +179,9 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); position.setTime(dateBuilder.getDate()); + + } else { + continue; } } else if (message.contains("$WIFI")) { @@ -220,7 +223,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { positions.add(position); } - return positions; + return positions.isEmpty() ? null : positions; } } diff --git a/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java index bc1c8e112..b747fa960 100644 --- a/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java @@ -11,6 +11,10 @@ public class Tlt2hProtocolDecoderTest extends ProtocolTest { var decoder = new Tlt2hProtocolDecoder(null); + verifyNull(decoder, text( + "#860517049471362#MT700#0000#AUTO#1\r\n", + "#36$GPRMC,,V,,,,,,,,,,A*5C\r\n")); + verifyPositions(decoder, text( "#867198059727390#MT700#0000#AUTO#1\r\n", "#38$GPRMC,105721.00,A,2238.3071,N,11401.7575,E,,96.70,250321,,,A*74\r\n")); -- cgit v1.2.3