aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-06-17 12:13:17 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-06-17 12:13:17 +1200
commit6ded2f7b1fc1e6593512f3b2b24400a90991aa89 (patch)
tree0ace65d98717573bb33616f2d448525b990d8288 /src/org
parent3f5122cbaf1710ae8d6c1c7ca9cf6a647f9a3f94 (diff)
downloadtrackermap-server-6ded2f7b1fc1e6593512f3b2b24400a90991aa89.tar.gz
trackermap-server-6ded2f7b1fc1e6593512f3b2b24400a90991aa89.tar.bz2
trackermap-server-6ded2f7b1fc1e6593512f3b2b24400a90991aa89.zip
Implement Atrack command response
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/AtrackProtocolDecoder.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java
index 456ae7bee..3566631f0 100644
--- a/src/org/traccar/protocol/AtrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java
@@ -195,6 +195,31 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private Position decodeString(Channel channel, SocketAddress remoteAddress, String sentence) {
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
+ if (deviceSession == null) {
+ return null;
+ }
+
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, null);
+
+ if (sentence.startsWith("$INFO")) {
+
+ return null;
+
+ } else {
+
+ position.set(Position.KEY_RESULT, sentence);
+
+ }
+
+ return position;
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -206,6 +231,8 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
channel.write(buf, remoteAddress); // keep-alive message
}
return null;
+ } else if (buf.getByte(buf.readerIndex()) == '$') {
+ return decodeString(channel, remoteAddress, buf.toString(StandardCharsets.US_ASCII).trim());
}
buf.skipBytes(2); // prefix