From ca8397232467ca70db44b3b3b089409f7e9ee21a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 12 Jan 2017 02:37:54 +1300 Subject: Avoid sending duplicate acks --- src/org/traccar/protocol/At2000FrameDecoder.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/At2000FrameDecoder.java b/src/org/traccar/protocol/At2000FrameDecoder.java index 4c849afb7..f87dc3885 100644 --- a/src/org/traccar/protocol/At2000FrameDecoder.java +++ b/src/org/traccar/protocol/At2000FrameDecoder.java @@ -30,6 +30,9 @@ public class At2000FrameDecoder extends FrameDecoder { private boolean firstPacket = true; + private ChannelBuffer currentBuffer; + private int acknowledgedBytes; + private void sendResponse(Channel channel) { if (channel != null) { ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 2 * BLOCK_LENGTH); @@ -63,7 +66,11 @@ public class At2000FrameDecoder extends FrameDecoder { } if (buf.readableBytes() >= length || buf.readableBytes() % ACK_LENGTH == 0) { - sendResponse(channel); + if (buf != currentBuffer || buf.readableBytes() > acknowledgedBytes) { + sendResponse(channel); + currentBuffer = buf; + acknowledgedBytes = buf.readableBytes(); + } } if (buf.readableBytes() >= length) { -- cgit v1.2.3