aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-26 12:22:23 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-26 12:22:23 +1300
commit96f529e32083d916883c3757ac88012758fdc90c (patch)
tree9e5eed13666d3f5ecb5c15cfc6d9c3c69971a472 /src/org/traccar
parentd227bf37681dcfad55a9365e166b1a71742d3ae1 (diff)
downloadtrackermap-server-96f529e32083d916883c3757ac88012758fdc90c.tar.gz
trackermap-server-96f529e32083d916883c3757ac88012758fdc90c.tar.bz2
trackermap-server-96f529e32083d916883c3757ac88012758fdc90c.zip
Modify H02 frame decoder
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/H02FrameDecoder.java18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/H02FrameDecoder.java b/src/org/traccar/protocol/H02FrameDecoder.java
index ce27b406f..253363357 100644
--- a/src/org/traccar/protocol/H02FrameDecoder.java
+++ b/src/org/traccar/protocol/H02FrameDecoder.java
@@ -28,28 +28,26 @@ public class H02FrameDecoder extends FrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
- String marker = buf.toString(buf.readerIndex(), 1, Charset.defaultCharset());
+ char marker = (char) buf.getByte(buf.readerIndex());
- while (!marker.equals("*") && !marker.equals("$") && buf.readableBytes() > 0) {
+ while (marker != '*' && marker != '$' && buf.readableBytes() > 0) {
buf.skipBytes(1);
if (buf.readableBytes() > 0) {
- marker = buf.toString(buf.readerIndex(), 1, Charset.defaultCharset());
+ marker = (char) buf.getByte(buf.readerIndex());
}
}
- if (marker.equals("*")) {
+ if (marker == '*') {
// Return text message
- Integer index = ChannelBufferTools.find(buf, buf.readerIndex(), buf.readableBytes(), "#");
- if (index != null) {
+ int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '#');
+ if (index != -1) {
return buf.readBytes(index + 1 - buf.readerIndex());
}
- } else if (marker.equals("$") && buf.readableBytes() >= MESSAGE_LENGTH) {
+ } else if (marker == '$' && buf.readableBytes() >= MESSAGE_LENGTH) {
// Return binary message
return buf.readBytes(MESSAGE_LENGTH);