aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-14 01:56:26 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-11-14 01:56:26 +1300
commit4066c24ed1ba8749a1a682acb5b027401d0df70f (patch)
tree1a1a6499fc2b9fff57dc7067f6dd8101b22efad0 /src/org/traccar/protocol
parentb87fa6f361fd0c27383d78a503ed2c28a8bdef1a (diff)
downloadtrackermap-server-4066c24ed1ba8749a1a682acb5b027401d0df70f.tar.gz
trackermap-server-4066c24ed1ba8749a1a682acb5b027401d0df70f.tar.bz2
trackermap-server-4066c24ed1ba8749a1a682acb5b027401d0df70f.zip
Another attempt to fix H02 frame decoder
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/H02FrameDecoder.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/H02FrameDecoder.java b/src/org/traccar/protocol/H02FrameDecoder.java
index d461c9219..a22252a57 100644
--- a/src/org/traccar/protocol/H02FrameDecoder.java
+++ b/src/org/traccar/protocol/H02FrameDecoder.java
@@ -54,16 +54,18 @@ public class H02FrameDecoder extends FrameDecoder {
} else if (marker == '$') {
- if (messageLength > 0 && buf.readableBytes() >= messageLength) {
- return buf.readBytes(messageLength);
- } else if (buf.readableBytes() >= MESSAGE_SHORT) {
- if (buf.getUnsignedByte(buf.readerIndex() + MESSAGE_SHORT - 1) == 0) {
- return buf.readBytes(MESSAGE_SHORT);
- } else if (buf.readableBytes() >= MESSAGE_LONG) {
- return buf.readBytes(MESSAGE_LONG);
+ if (messageLength == 0) {
+ if (buf.readableBytes() == MESSAGE_LONG) {
+ messageLength = MESSAGE_LONG;
+ } else {
+ messageLength = MESSAGE_SHORT;
}
}
+ if (buf.readableBytes() >= messageLength) {
+ return buf.readBytes(messageLength);
+ }
+
}
return null;