aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/CellocatorFrameDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-06 16:51:47 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-06 16:51:47 +1200
commit562535fd538e7b05b6fe96c0f56eb2ec0ae1fd0e (patch)
tree44fa438ebc6be56ede7307b18a2116fff14d8cc8 /src/org/traccar/protocol/CellocatorFrameDecoder.java
parent9c99076dc2416c4e0725007af0e5f2f2f444c05c (diff)
downloadtrackermap-server-562535fd538e7b05b6fe96c0f56eb2ec0ae1fd0e.tar.gz
trackermap-server-562535fd538e7b05b6fe96c0f56eb2ec0ae1fd0e.tar.bz2
trackermap-server-562535fd538e7b05b6fe96c0f56eb2ec0ae1fd0e.zip
Migrate more protocols
Diffstat (limited to 'src/org/traccar/protocol/CellocatorFrameDecoder.java')
-rw-r--r--src/org/traccar/protocol/CellocatorFrameDecoder.java28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/org/traccar/protocol/CellocatorFrameDecoder.java b/src/org/traccar/protocol/CellocatorFrameDecoder.java
index b4708f5db..8cdba18e0 100644
--- a/src/org/traccar/protocol/CellocatorFrameDecoder.java
+++ b/src/org/traccar/protocol/CellocatorFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,29 +15,24 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
import org.traccar.helper.Log;
-public class CellocatorFrameDecoder extends FrameDecoder {
+public class CellocatorFrameDecoder extends BaseFrameDecoder {
private static final int MESSAGE_MINIMUM_LENGTH = 15;
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
- // Check minimum length
- int available = buf.readableBytes();
- if (available < MESSAGE_MINIMUM_LENGTH) {
+ if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) {
return null;
}
- // Size depending on message type
int length = 0;
int type = buf.getUnsignedByte(4);
switch (type) {
@@ -51,8 +46,8 @@ public class CellocatorFrameDecoder extends FrameDecoder {
length = 70;
break;
case CellocatorProtocolDecoder.MSG_CLIENT_SERIAL:
- if (available >= 19) {
- length = 19 + buf.getUnsignedShort(16);
+ if (buf.readableBytes() >= 19) {
+ length = 19 + buf.getUnsignedShortLE(16);
}
break;
case CellocatorProtocolDecoder.MSG_CLIENT_MODULAR:
@@ -63,8 +58,7 @@ public class CellocatorFrameDecoder extends FrameDecoder {
break;
}
- // Read packet
- if (length > 0 && available >= length) {
+ if (length > 0 && buf.readableBytes() >= length) {
return buf.readBytes(length);
}