aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-07-18 06:56:03 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-07-18 06:56:03 +1200
commitd62797376e7dc1d5810c1b8728da1e5443cc8e14 (patch)
tree57b636b5cb74b87cd969ccd666cd3294652bef06 /src
parentcb0d7cccaecfe049e04defd90884976ac1e982f9 (diff)
downloadtraccar-server-d62797376e7dc1d5810c1b8728da1e5443cc8e14.tar.gz
traccar-server-d62797376e7dc1d5810c1b8728da1e5443cc8e14.tar.bz2
traccar-server-d62797376e7dc1d5810c1b8728da1e5443cc8e14.zip
Refactor TAIP decoder
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/TaipProtocolDecoder.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java
index 7702a89fb..a08bb6f2b 100644
--- a/src/org/traccar/protocol/TaipProtocolDecoder.java
+++ b/src/org/traccar/protocol/TaipProtocolDecoder.java
@@ -104,15 +104,21 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setProtocol(getProtocolName());
+ Integer event = null;
+
if (parser.hasNext(3)) {
- position.set(Position.KEY_EVENT, parser.nextInt(0));
+ event = parser.nextInt();
position.setTime(getTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0)));
} else if (parser.hasNext()) {
position.setTime(getTime(parser.nextInt(0)));
}
if (parser.hasNext()) {
- position.set(Position.KEY_EVENT, parser.nextInt(0));
+ event = parser.nextInt();
+ }
+
+ if (event != null) {
+ position.set(Position.KEY_EVENT, event);
}
if (parser.hasNext(6)) {
@@ -150,6 +156,12 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
attributes = sentence.substring(beginIndex, endIndex).split(";");
}
+ return decodeAttributes(channel, remoteAddress, position, attributes);
+ }
+
+ private Position decodeAttributes(
+ Channel channel, SocketAddress remoteAddress, Position position, String[] attributes) {
+
String uniqueId = null;
DeviceSession deviceSession = null;
String messageIndex = null;