aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-02-17 07:13:09 -0800
committerAnton Tananaev <anton@traccar.org>2024-02-17 07:13:09 -0800
commitf632b15098776b35910834aabc35bb62737c6d78 (patch)
tree6509f75b7d629f636c1d80317c5e2b3488461293
parent0c8b5c1ab1f83cc0fc6d2f17cdf808388b383e14 (diff)
downloadtrackermap-server-f632b15098776b35910834aabc35bb62737c6d78.tar.gz
trackermap-server-f632b15098776b35910834aabc35bb62737c6d78.tar.bz2
trackermap-server-f632b15098776b35910834aabc35bb62737c6d78.zip
Handle MT600 no location messages
-rw-r--r--src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java31
-rw-r--r--src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java10
2 files changed, 30 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java
index 79488acc0..4b11cbc74 100644
--- a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2024 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,8 +63,9 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
.number("(x+)") // cell id
.groupEnd("?")
.text("$GPRMC,")
- .number("(dd)(dd)(dd).d+,") // time (hhmmss.sss)
+ .number("(?:(dd)(dd)(dd).d+)?,") // time (hhmmss.sss)
.expression("([AVL]),") // validity
+ .groupBegin()
.number("(d+)(dd.d+),") // latitude
.expression("([NS]),")
.number("(d+)(dd.d+),") // longitude
@@ -72,6 +73,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.?d*)?,") // speed
.number("(d+.?d*)?,") // course
.number("(dd)(dd)(dd)") // date (ddmmyy)
+ .groupEnd("?")
.any()
.compile();
@@ -190,17 +192,26 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
position.setNetwork(network);
}
- DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ DateBuilder dateBuilder = new DateBuilder();
+ if (parser.hasNext(3)) {
+ dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ }
position.setValid(parser.next().equals("A"));
- position.setLatitude(parser.nextCoordinate());
- position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble(0));
- position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
- position.setTime(dateBuilder.getDate());
+ if (parser.hasNext()) {
+
+ position.setLatitude(parser.nextCoordinate());
+ position.setLongitude(parser.nextCoordinate());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
+
+ dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ position.setTime(dateBuilder.getDate());
+
+ } else {
+ getLastLocation(position, null);
+ }
} else {
continue;
diff --git a/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java
index a64a10450..8a7ba84ab 100644
--- a/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java
@@ -11,6 +11,14 @@ public class Tlt2hProtocolDecoderTest extends ProtocolTest {
var decoder = inject(new Tlt2hProtocolDecoder(null));
+ verifyPositions(decoder, false, text(
+ "#868105044690301#MT600+#0000#0#0#129#40#0#AUTOLOW#1\r\n" +
+ "#072030fa20c$GPRMC,,V,,,,,,,,,,A*5C\r\n"));
+
+ verifyPositions(decoder, text(
+ "#868105044690301#MT600+#0000#0#0#143#40#0#AUTO#1\r\n",
+ "#072030fcf21$GPRMC,155616.00,A,4931.9210,N,09652.5290,W,53.80,90.00,150224,,,A*48\r\n"));
+
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"),
@@ -24,7 +32,7 @@ public class Tlt2hProtocolDecoderTest extends ProtocolTest {
"#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"));
- verifyNull(decoder, text(
+ verifyPositions(decoder, false, text(
"#860517049471362#MT700#0000#AUTO#1\r\n",
"#36$GPRMC,,V,,,,,,,,,,A*5C\r\n"));