aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/UlbotechFrameDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-01-21 22:19:20 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-01-21 22:19:20 +1300
commitfc0a26137fbd00339fcbf28b10b2afae6242d094 (patch)
tree33b8764b40a55af68a2d52bd81b35cf48a56731a /src/org/traccar/protocol/UlbotechFrameDecoder.java
parent39de5581b92a505a19cf1929a52bc562c48c3e2f (diff)
downloadtrackermap-server-fc0a26137fbd00339fcbf28b10b2afae6242d094.tar.gz
trackermap-server-fc0a26137fbd00339fcbf28b10b2afae6242d094.tar.bz2
trackermap-server-fc0a26137fbd00339fcbf28b10b2afae6242d094.zip
Fix Ulbotech frame and protocol decoders
Diffstat (limited to 'src/org/traccar/protocol/UlbotechFrameDecoder.java')
-rw-r--r--src/org/traccar/protocol/UlbotechFrameDecoder.java41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/org/traccar/protocol/UlbotechFrameDecoder.java b/src/org/traccar/protocol/UlbotechFrameDecoder.java
index f0671c717..09c1db717 100644
--- a/src/org/traccar/protocol/UlbotechFrameDecoder.java
+++ b/src/org/traccar/protocol/UlbotechFrameDecoder.java
@@ -33,25 +33,36 @@ public class UlbotechFrameDecoder extends FrameDecoder {
return null;
}
- int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0xF8);
- if (index != -1) {
- ChannelBuffer result = ChannelBuffers.buffer(index + 1 - buf.readerIndex());
-
- while (buf.readerIndex() <= index) {
- int b = buf.readUnsignedByte();
- if (b == 0xF7) {
- int ext = buf.readUnsignedByte();
- if (ext == 0x00) {
- result.writeByte(0xF7);
- } else if (ext == 0x0F) {
- result.writeByte(0xF8);
+ if (buf.getUnsignedByte(buf.readerIndex()) == 0xF8) {
+
+ int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0xF8);
+ if (index != -1) {
+ ChannelBuffer result = ChannelBuffers.buffer(index + 1 - buf.readerIndex());
+
+ while (buf.readerIndex() <= index) {
+ int b = buf.readUnsignedByte();
+ if (b == 0xF7) {
+ int ext = buf.readUnsignedByte();
+ if (ext == 0x00) {
+ result.writeByte(0xF7);
+ } else if (ext == 0x0F) {
+ result.writeByte(0xF8);
+ }
+ } else {
+ result.writeByte(b);
}
- } else {
- result.writeByte(b);
}
+
+ return result;
+ }
+
+ } else {
+
+ int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '#');
+ if (index != -1) {
+ return buf.readBytes(index + 1 - buf.readerIndex());
}
- return result;
}
return null;