From c354057c1e887e73159a4c28ce038c35370df5b6 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 31 Jul 2015 10:49:32 +1200 Subject: Implement Box ACK response --- src/org/traccar/protocol/BoxProtocol.java | 2 ++ src/org/traccar/protocol/BoxProtocolDecoder.java | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/BoxProtocol.java b/src/org/traccar/protocol/BoxProtocol.java index 7e5f83ebe..ae8207002 100644 --- a/src/org/traccar/protocol/BoxProtocol.java +++ b/src/org/traccar/protocol/BoxProtocol.java @@ -18,6 +18,7 @@ package org.traccar.protocol; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.handler.codec.string.StringDecoder; +import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; import org.traccar.CharacterDelimiterFrameDecoder; import org.traccar.TrackerServer; @@ -37,6 +38,7 @@ public class BoxProtocol extends BaseProtocol { protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r')); pipeline.addLast("stringDecoder", new StringDecoder()); + pipeline.addLast("stringEncoder", new StringEncoder()); pipeline.addLast("objectDecoder", new BoxProtocolDecoder(BoxProtocol.this)); } }); diff --git a/src/org/traccar/protocol/BoxProtocolDecoder.java b/src/org/traccar/protocol/BoxProtocolDecoder.java index 2230b1356..7f915824d 100644 --- a/src/org/traccar/protocol/BoxProtocolDecoder.java +++ b/src/org/traccar/protocol/BoxProtocolDecoder.java @@ -61,8 +61,16 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder { String id = sentence.substring(index, sentence.indexOf(',', index)); identify(id, channel); } + + else if (sentence.startsWith("E,")) { + + if (channel != null) { + channel.write("A," + sentence.substring(2) + "\r"); + } + + } - else if (hasDeviceId() && sentence.startsWith("L,")) { + else if (sentence.startsWith("L,") && hasDeviceId()) { // Parse message Matcher parser = pattern.matcher(sentence); -- cgit v1.2.3