diff options
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/AtrackProtocolDecoder.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java index ac208c0f2..b0f094103 100644 --- a/src/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java @@ -21,6 +21,7 @@ import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.Context; import org.traccar.DeviceSession; +import org.traccar.helper.DataConverter; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; @@ -410,16 +411,21 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { return positions; } + private void sendResponse(Channel channel, SocketAddress remoteAddress) { + if (channel != null) { + channel.write(ChannelBuffers.wrappedBuffer(DataConverter.parseHex("fe02")), remoteAddress); + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { ChannelBuffer buf = (ChannelBuffer) msg; + sendResponse(channel, remoteAddress); + if (buf.getUnsignedShort(buf.readerIndex()) == 0xfe02) { - if (channel != null) { - channel.write(buf, remoteAddress); // keep-alive message - } return null; } else if (buf.getByte(buf.readerIndex()) == '$') { return decodeInfo(channel, remoteAddress, buf.toString(StandardCharsets.US_ASCII).trim()); |