aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-04-09 21:30:05 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-04-09 21:30:05 -0700
commitd701e4cd549e99c594a7ddf41359b59f34ad2cff (patch)
tree4261e454b974d947bfd5e527d2704a0bfea71b9c /src/main/java/org/traccar/protocol
parente6b0e38e6d250253b62c41dac3f01a9309a8de7f (diff)
downloadtraccar-server-d701e4cd549e99c594a7ddf41359b59f34ad2cff.tar.gz
traccar-server-d701e4cd549e99c594a7ddf41359b59f34ad2cff.tar.bz2
traccar-server-d701e4cd549e99c594a7ddf41359b59f34ad2cff.zip
Support letters in device id
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-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();