aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/OigoProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-08 21:00:31 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-08 21:00:31 +1200
commitecb7bb33fcec52491f917dbc65a82990dcddb808 (patch)
tree1d47e8310a7e7eabad06d40548c941a6e237da20 /src/org/traccar/protocol/OigoProtocolDecoder.java
parent4d9187e2ee98eee17d4adbcb84379e2c68fe2bcd (diff)
downloadtrackermap-server-ecb7bb33fcec52491f917dbc65a82990dcddb808.tar.gz
trackermap-server-ecb7bb33fcec52491f917dbc65a82990dcddb808.tar.bz2
trackermap-server-ecb7bb33fcec52491f917dbc65a82990dcddb808.zip
Migrate O and P protocols
Diffstat (limited to 'src/org/traccar/protocol/OigoProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/OigoProtocolDecoder.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/OigoProtocolDecoder.java b/src/org/traccar/protocol/OigoProtocolDecoder.java
index 2874d0455..e00079210 100644
--- a/src/org/traccar/protocol/OigoProtocolDecoder.java
+++ b/src/org/traccar/protocol/OigoProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 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,11 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
@@ -39,7 +41,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_ACKNOWLEDGEMENT = 0xE0;
- private Position decodeArMessage(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private Position decodeArMessage(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
buf.skipBytes(1); // header
buf.readUnsignedShort(); // length
@@ -51,7 +53,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
DeviceSession deviceSession;
switch (BitUtil.to(tag, 3)) {
case 0:
- String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1);
+ String imei = ByteBufUtil.hexDump(buf.readBytes(8)).substring(1);
deviceSession = getDeviceSession(channel, remoteAddress, imei);
break;
case 1:
@@ -159,7 +161,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
return negative ? -degrees : degrees;
}
- private Position decodeMgMessage(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private Position decodeMgMessage(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
buf.readUnsignedByte(); // tag
int flags = buf.getUnsignedByte(buf.readerIndex());
@@ -169,7 +171,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // flags
deviceSession = getDeviceSession(channel, remoteAddress);
} else {
- String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1);
+ String imei = ByteBufUtil.hexDump(buf.readBytes(8)).substring(1);
deviceSession = getDeviceSession(channel, remoteAddress, imei);
}
@@ -211,11 +213,11 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, (long) (buf.readUnsignedInt() * 1609.34));
if (channel != null && BitUtil.check(flags, 7)) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte(MSG_ACKNOWLEDGEMENT);
response.writeByte(index);
response.writeByte(0x00);
- channel.write(response, remoteAddress);
+ channel.write(new NetworkMessage(response, remoteAddress));
}
return position;
@@ -225,7 +227,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (buf.getUnsignedByte(buf.readerIndex()) == 0x7e) {
return decodeArMessage(channel, remoteAddress, buf);