aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TaipProtocolDecoder.java
diff options
context:
space:
mode:
authorninioe <ninioe@gmail.com>2016-07-19 15:20:15 +0300
committerninioe <ninioe@gmail.com>2016-07-19 15:20:15 +0300
commit20f603076210073e122c720e21a3e8999478b11a (patch)
tree668a50e6c55601c2420bf0f4b986ed0b194c2e32 /src/org/traccar/protocol/TaipProtocolDecoder.java
parente954e95547d05a34bbd36e3aa5003f4ddaf2ccd0 (diff)
parent00e2f8a3575855a8b863e245005b8f83b3314bfb (diff)
downloadtrackermap-server-20f603076210073e122c720e21a3e8999478b11a.tar.gz
trackermap-server-20f603076210073e122c720e21a3e8999478b11a.tar.bz2
trackermap-server-20f603076210073e122c720e21a3e8999478b11a.zip
Merge remote-tracking branch 'refs/remotes/tananaev/master'
Diffstat (limited to 'src/org/traccar/protocol/TaipProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TaipProtocolDecoder.java33
1 files changed, 8 insertions, 25 deletions
diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java
index f44b9bcbe..811db774c 100644
--- a/src/org/traccar/protocol/TaipProtocolDecoder.java
+++ b/src/org/traccar/protocol/TaipProtocolDecoder.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.DateUtil;
import org.traccar.helper.Parser;
@@ -84,27 +85,6 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
sentence = sentence.substring(beginIndex + 1);
}
- // Find device identifier
- beginIndex = sentence.indexOf(";ID=");
- if (beginIndex != -1) {
- beginIndex += 4;
- int endIndex = sentence.indexOf(';', beginIndex);
- if (endIndex == -1) {
- endIndex = sentence.length();
- }
-
- String id = sentence.substring(beginIndex, endIndex);
- if (!identify(id, channel, remoteAddress)) {
- return null;
- }
-
- if (sendResponse && channel != null) {
- channel.write(id);
- }
- } else {
- return null;
- }
-
Parser parser = new Parser(PATTERN, sentence);
if (!parser.matches()) {
return null;
@@ -112,7 +92,6 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setProtocol(getProtocolName());
- position.setDeviceId(getDeviceId());
String week = parser.next();
String day = parser.next();
@@ -157,8 +136,9 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
switch (key) {
case "id":
- if (!identify(value, channel, remoteAddress)) {
- return null;
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, value);
+ if (deviceSession != null) {
+ position.setDeviceId(deviceSession.getDeviceId());
}
if (sendResponse && channel != null) {
channel.write(value);
@@ -186,7 +166,10 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
}
}
- return position;
+ if (position.getDeviceId() != 0) {
+ return position;
+ }
+ return null;
}
}