aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <atananaev@lyft.com>2019-09-03 09:25:59 -0600
committerAnton Tananaev <atananaev@lyft.com>2019-09-03 09:25:59 -0600
commit6202fdd44ece635f2b97386d1db82e0572e838c0 (patch)
tree296349e668439ebd52aaf1f71e6448577b59bb18 /src/main/java/org/traccar/protocol
parente99f61a3d9a2a7708aaabc047cb73adb0ceb0cac (diff)
downloadtrackermap-server-6202fdd44ece635f2b97386d1db82e0572e838c0.tar.gz
trackermap-server-6202fdd44ece635f2b97386d1db82e0572e838c0.tar.bz2
trackermap-server-6202fdd44ece635f2b97386d1db82e0572e838c0.zip
Add missing response
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/RaceDynamicsProtocolDecoder.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/RaceDynamicsProtocolDecoder.java b/src/main/java/org/traccar/protocol/RaceDynamicsProtocolDecoder.java
index 33b08115d..0261199a3 100644
--- a/src/main/java/org/traccar/protocol/RaceDynamicsProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/RaceDynamicsProtocolDecoder.java
@@ -26,6 +26,7 @@ import org.traccar.helper.PatternBuilder;
import org.traccar.model.Position;
import java.net.SocketAddress;
+import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
@@ -73,6 +74,16 @@ public class RaceDynamicsProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private String imei;
+
+ private void sendResponse(Channel channel, SocketAddress remoteAddress, int type) {
+ if (channel != null) {
+ String response = String.format(
+ "$GPRMC,%1$d,%2$td%2$tm%2$ty,%2$tH%2$tM%2$tS,%3$s,\r\n", type, new Date(), imei);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -85,10 +96,9 @@ public class RaceDynamicsProtocolDecoder extends BaseProtocolDecoder {
Parser parser = new Parser(PATTERN_LOGIN, sentence);
if (parser.matches()) {
- getDeviceSession(channel, remoteAddress, parser.next());
- if (channel != null) {
- channel.writeAndFlush(new NetworkMessage(sentence + "\r\n", remoteAddress));
- }
+ imei = parser.next();
+ getDeviceSession(channel, remoteAddress, imei);
+ sendResponse(channel, remoteAddress, type);
}
} else if (type == MSG_LOCATION) {
@@ -131,6 +141,8 @@ public class RaceDynamicsProtocolDecoder extends BaseProtocolDecoder {
}
}
+ sendResponse(channel, remoteAddress, type);
+
return positions;
}