aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-06-14 04:30:27 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-06-14 04:30:27 +1200
commitb84d627b57181907c73d2c4ebb46ed011be8cfab (patch)
tree44c68cddebb1a7d47c3182341a6e35cf2fee2b1b /src
parent3b5f9807239ea45087b1c01c98a8ffc467d13619 (diff)
downloadtraccar-server-b84d627b57181907c73d2c4ebb46ed011be8cfab.tar.gz
traccar-server-b84d627b57181907c73d2c4ebb46ed011be8cfab.tar.bz2
traccar-server-b84d627b57181907c73d2c4ebb46ed011be8cfab.zip
Fix Watch frame decoder
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/WatchFrameDecoder.java30
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;
}
}