From 7ee06b08511754a941893f73bf49409cfa7c713f Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 18 Apr 2021 17:20:13 -0700 Subject: Login and heartbeat responses --- .../java/org/traccar/protocol/ItsProtocolDecoder.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/main/java/org') 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)); } -- cgit v1.2.3