From edeb03b40d04be2c75eb736e35afc3b324da0cf2 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 14 Jul 2020 22:22:52 -0700 Subject: Support acknowledgement --- .../java/org/traccar/protocol/EasyTrackProtocolDecoder.java | 10 +++++++++- .../org/traccar/protocol/EasyTrackProtocolDecoderTest.java | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/EasyTrackProtocolDecoder.java index 81a31e1d1..889e2bf09 100644 --- a/src/main/java/org/traccar/protocol/EasyTrackProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/EasyTrackProtocolDecoder.java @@ -18,6 +18,7 @@ package org.traccar.protocol; import io.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; +import org.traccar.NetworkMessage; import org.traccar.Protocol; import org.traccar.helper.BitUtil; import org.traccar.helper.DateBuilder; @@ -93,7 +94,14 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder { protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { - Parser parser = new Parser(PATTERN, (String) msg); + String sentence = (String) msg; + String type = sentence.substring(20, 22); + + if (type.equals("TX") && channel != null) { + channel.writeAndFlush(new NetworkMessage(sentence + "#", remoteAddress)); + } + + Parser parser = new Parser(PATTERN, sentence); if (!parser.matches()) { return null; } diff --git a/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java index 1ea608b04..c86e14db2 100644 --- a/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class EasyTrackProtocolDecoderTest extends ProtocolTest { EasyTrackProtocolDecoder decoder = new EasyTrackProtocolDecoder(null); + verifyNull(decoder, text( + "*ET,354522180045564,TX,V,14070E,122336")); + verifyPosition(decoder, text( "*ET,135790246811221,HB,A,050915,0C2A27,00CE5954,04132263,0000,F000,01000000,20,4,0000,00F123,100,4845423835,0091564212,0B45,10.00,9")); -- cgit v1.2.3