aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/Tlt2hProtocolDecoder.java10
-rw-r--r--test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java4
2 files changed, 9 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
index 4433322c2..c8671bc54 100644
--- a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
@@ -35,14 +35,14 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
super(serverManager);
}
- static private Pattern patternHeader = Pattern.compile(
+ private static final Pattern patternHeader = Pattern.compile(
"#(\\d+)#" + // IMEI
"[^#]+#" +
"\\d+#" +
"([^#]+)#" + // Status
"\\d+"); // Number of records
- static private Pattern patternPosition = Pattern.compile(
+ private static final Pattern patternPosition = Pattern.compile(
"#([0-9a-f]+)?" + // Cell info
"\\$GPRMC," +
"(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time (HHMMSS.SSS)
@@ -51,8 +51,8 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
"([NS])," +
"(\\d+)(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM)
"([EW])," +
- "(\\d+\\.\\d{2})?," + // Speed
- "(\\d+\\.\\d{2})?," + // Course
+ "(\\d+\\.\\d+)?," + // Speed
+ "(\\d+\\.\\d+)?," + // Course
"(\\d{2})(\\d{2})(\\d{2})" + // Date (DDMMYY)
".+"); // Other (Checksumm)
@@ -107,7 +107,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
index += 1; // Skip milliseconds
// Validity
- position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
+ position.setValid(parser.group(index++).compareTo("A") == 0);
// Latitude
Double latitude = Double.valueOf(parser.group(index++));
diff --git a/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java b/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java
index ce9943405..0a7dede6c 100644
--- a/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java
@@ -30,6 +30,10 @@ public class Tlt2hProtocolDecoderTest {
"#353686009063310#353686009063310#0000#AUTO#2\r\n" +
"#239757a9$GPRMC,150252.001,A,2326.6856,S,4631.8154,W,,,260513,,,A*52\r\n" +
"#239757a9$GPRMC,150322.001,A,2326.6854,S,4631.8157,W,,,260513,,,A*55"));
+
+ verify(decoder.decode(null, null,
+ "#357671031289215#V600#0000#AUTOLOW#1\r\n" +
+ "#00735e1c$GPRMC,115647.000,A,5553.6524,N,02632.3128,E,0.00,0.0,130614,0.0,W,A*28"));
}