aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
index 9e28b5051..feedb2c5e 100644
--- a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2019 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.
@@ -44,7 +44,11 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN = new PatternBuilder()
.text("(").optional()
- .number("(d+)(,)?") // device id
+ .groupBegin()
+ .expression("(.{12})") // device id
+ .or()
+ .expression("(.+),") // device id
+ .groupEnd()
.expression("(.{4}),?") // command
.number("(d*)")
.number("(dd)(dd)(dd),?") // date (mmddyy if comma-delimited, otherwise yyddmm)
@@ -371,7 +375,17 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
+ String id = null;
+ boolean alternative = false;
+ if (parser.hasNext()) {
+ id = parser.next();
+ }
+ if (parser.hasNext()) {
+ id = parser.next();
+ alternative = true;
+ }
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id);
if (deviceSession == null) {
return null;
}
@@ -379,8 +393,6 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- boolean alternative = parser.next() != null;
-
decodeType(position, parser.next(), parser.next());
DateBuilder dateBuilder = new DateBuilder();