diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-12-28 09:49:49 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-12-28 09:49:49 -0800 |
commit | b29bf8bcea11fb154da54b8d2f11fd2fd8517ef8 (patch) | |
tree | cac7e488bf819503749478f6f3ee13cd99734086 /src/org | |
parent | 27c565546b9f0fe820af6e46a2562f4e23319ee2 (diff) | |
download | trackermap-server-b29bf8bcea11fb154da54b8d2f11fd2fd8517ef8.tar.gz trackermap-server-b29bf8bcea11fb154da54b8d2f11fd2fd8517ef8.tar.bz2 trackermap-server-b29bf8bcea11fb154da54b8d2f11fd2fd8517ef8.zip |
Fix Wristband protocol response
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/WristbandProtocol.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/WristbandProtocolDecoder.java | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/WristbandProtocol.java b/src/org/traccar/protocol/WristbandProtocol.java index 632eb6a42..1e5ef2c01 100644 --- a/src/org/traccar/protocol/WristbandProtocol.java +++ b/src/org/traccar/protocol/WristbandProtocol.java @@ -16,7 +16,6 @@ package org.traccar.protocol; import io.netty.handler.codec.LengthFieldBasedFrameDecoder; -import io.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; import org.traccar.PipelineBuilder; import org.traccar.TrackerServer; @@ -28,7 +27,6 @@ public class WristbandProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new LengthFieldBasedFrameDecoder(1024, 3, 2, 3, 0)); - pipeline.addLast(new StringEncoder()); pipeline.addLast(new WristbandProtocolDecoder(WristbandProtocol.this)); } }); diff --git a/src/org/traccar/protocol/WristbandProtocolDecoder.java b/src/org/traccar/protocol/WristbandProtocolDecoder.java index a19dcad31..3b1c6c2d4 100644 --- a/src/org/traccar/protocol/WristbandProtocolDecoder.java +++ b/src/org/traccar/protocol/WristbandProtocolDecoder.java @@ -16,6 +16,7 @@ package org.traccar.protocol; import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; @@ -46,7 +47,16 @@ public class WristbandProtocolDecoder extends BaseProtocolDecoder { if (channel != null) { String sentence = String.format("YX%s|%s|0|{F%d#%s}\r\n", imei, version, type, data); - channel.writeAndFlush(new NetworkMessage(sentence, channel.remoteAddress())); + ByteBuf response = Unpooled.buffer(); + if (type != 91) { + response.writeBytes(new byte[]{0x00, 0x01, 0x02}); + response.writeShort(sentence.length()); + } + response.writeCharSequence(sentence, StandardCharsets.US_ASCII); + if (type != 91) { + response.writeBytes(new byte[]{(byte) 0xFF, (byte) 0xFE, (byte) 0xFC}); + } + channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress())); } } |