diff options
-rw-r--r-- | src/org/traccar/protocol/WatchFrameDecoder.java | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/WatchFrameDecoder.java b/src/org/traccar/protocol/WatchFrameDecoder.java index 26aba68c7..826a8b4d0 100644 --- a/src/org/traccar/protocol/WatchFrameDecoder.java +++ b/src/org/traccar/protocol/WatchFrameDecoder.java @@ -36,7 +36,35 @@ public class WatchFrameDecoder extends FrameDecoder { buf.getBytes(buf.readerIndex() + MESSAGE_HEADER - 4 - 1, lengthBuffer, 4); int length = Integer.parseInt(lengthBuffer.toString(StandardCharsets.US_ASCII), 16) + MESSAGE_HEADER + 1; if (buf.readableBytes() >= length) { - return buf.readBytes(length); + ChannelBuffer frame = ChannelBuffers.dynamicBuffer(); + int endIndex = buf.readerIndex() + length; + while (buf.readerIndex() < endIndex) { + byte b = buf.readByte(); + if (b == 0x7D) { + switch (buf.readByte()) { + case 0x01: + frame.writeByte(0x7D); + break; + case 0x02: + frame.writeByte(0x5B); + break; + case 0x03: + frame.writeByte(0x5D); + break; + case 0x04: + frame.writeByte(0x2C); + break; + case 0x05: + frame.writeByte(0x2A); + break; + default: + throw new IllegalArgumentException(); + } + } else { + frame.writeByte(b); + } + } + return frame; } } |