aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Tk102ProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/Tk102ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Tk102ProtocolDecoder.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/Tk102ProtocolDecoder.java b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
index 8323d6a3d..bb7510eb1 100644
--- a/src/org/traccar/protocol/Tk102ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
@@ -17,6 +17,7 @@ package org.traccar.protocol;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -58,14 +59,17 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
if (sentence.startsWith("[!")) {
- if (!identify(sentence.substring(14, 14 + 15), channel, remoteAddress)) {
- return null;
- }
- if (channel != null) {
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, sentence.substring(14, 14 + 15));
+ if (deviceSession != null && channel != null) {
channel.write("[”0000000001" + sentence.substring(13) + "]");
}
- } else if (hasDeviceId()) {
+ } else {
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
+ if (deviceSession == null) {
+ return null;
+ }
Parser parser = new Parser(PATTERN, sentence);
if (!parser.matches()) {
@@ -74,7 +78,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setProtocol(getProtocolName());
- position.setDeviceId(getDeviceId());
+ position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());