aboutsummaryrefslogtreecommitdiff
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
parent3ecba816b23e278cac690a9ceb366b9637bba775 (diff)
downloadtrackermap-server-7ee06b08511754a941893f73bf49409cfa7c713f.tar.gz
trackermap-server-7ee06b08511754a941893f73bf49409cfa7c713f.tar.bz2
trackermap-server-7ee06b08511754a941893f73bf49409cfa7c713f.zip
Login and heartbeat responses
-rw-r--r--src/main/java/org/traccar/protocol/ItsProtocolDecoder.java19
-rw-r--r--src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java3
2 files changed, 21 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));
}
diff --git a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java
index 9d38a66d9..8277b8843 100644
--- a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java
@@ -12,6 +12,9 @@ public class ItsProtocolDecoderTest extends ProtocolTest {
var decoder = new ItsProtocolDecoder(null);
verifyNull(decoder, text(
+ "$,LGN,MARK,000000000,358980100077446,V0.0.1,AIS140,19.804487,N,75.225876,E,*"));
+
+ verifyNull(decoder, text(
"$LGN,,869867037009679,3.2AIH,9.99546000,N,76.35886167,E"));
verifyAttribute(decoder, text(