diff options
-rw-r--r-- | src/org/traccar/protocol/Tlt2hProtocolDecoder.java | 9 | ||||
-rw-r--r-- | test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java | 4 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java index 531ae28b6..66146b6fb 100644 --- a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java +++ b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java @@ -38,7 +38,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { * Regular expressions pattern */ static private Pattern pattern = Pattern.compile( - "#([0-9a-f]+)" + // Cell info + "#([0-9a-f]+)?" + // Cell info "\\$GPRMC," + "(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time (HHMMSS.SSS) "([AV])," + // Validity @@ -81,9 +81,10 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { Integer index = 1; // Cell - extendedInfo.append("<cell>"); - extendedInfo.append(parser.group(index++)); - extendedInfo.append("</cell>"); + String cell = parser.group(index++); + if (cell != null) { + extendedInfo.append("<cell>").append(cell).append("</cell>"); + } // Time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); diff --git a/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java b/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java index 8660e733c..070aec4e1 100644 --- a/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java @@ -10,6 +10,10 @@ public class Tlt2hProtocolDecoderTest { Tlt2hProtocolDecoder decoder = new Tlt2hProtocolDecoder(null); decoder.setDataManager(new TestDataManager()); + + assertNotNull(decoder.decode(null, null, + "#357671030946351#V500#0000#AUTO#1\r\n" + + "#$GPRMC,223835.000,A,0615.3545,S,10708.5779,E,14.62,97.41,070313,,,D*70\r\n")); assertNotNull(decoder.decode(null, null, "#357671030938911#V500#0000#AUTOSTOP#1\r\n" + |