aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-04-18 17:20:13 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-04-18 17:20:13 -0700
commit7ee06b08511754a941893f73bf49409cfa7c713f (patch)
tree0da23e0a1d45e1657f9eb564d7cf4640f3507ae3 /src/main/java/org/traccar/protocol
parent3ecba816b23e278cac690a9ceb366b9637bba775 (diff)
downloadtrackermap-server-7ee06b08511754a941893f73bf49409cfa7c713f.tar.gz
trackermap-server-7ee06b08511754a941893f73bf49409cfa7c713f.tar.bz2
trackermap-server-7ee06b08511754a941893f73bf49409cfa7c713f.zip
Login and heartbeat responses
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/ItsProtocolDecoder.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java
index 94c9a3038..7bdf59277 100644
--- a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 - 2021 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,10 @@ import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
import java.util.regex.Pattern;
public class ItsProtocolDecoder extends BaseProtocolDecoder {
@@ -137,6 +141,19 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
String sentence = (String) msg;
+ if (channel != null) {
+ if (sentence.startsWith("$,01,")) {
+ channel.writeAndFlush(new NetworkMessage("$,1,*", remoteAddress));
+ } else if (sentence.startsWith("$,LGN,")) {
+ DateFormat dateFormat = new SimpleDateFormat("ddMMyyyyHHmmss");
+ dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+ String time = dateFormat.format(new Date());
+ channel.writeAndFlush(new NetworkMessage("$,LGN," + time + ",*", remoteAddress));
+ } else if (sentence.startsWith("$,HBT,")) {
+ channel.writeAndFlush(new NetworkMessage("$,HBT,*", remoteAddress));
+ }
+ }
+
if (channel != null && sentence.startsWith("$,01,")) {
channel.writeAndFlush(new NetworkMessage("$,1,*", remoteAddress));
}