aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TytanProtocolDecoder.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2018-06-08 17:04:44 +0500
committerAbyss777 <abyss@fox5.ru>2018-06-08 17:04:44 +0500
commitc176b7b4bf4eef6f71767f92ada2591ef27c1cfa (patch)
treefd7ef0e30a4644760154ffc14101749311040d85 /src/org/traccar/protocol/TytanProtocolDecoder.java
parentecb7bb33fcec52491f917dbc65a82990dcddb808 (diff)
downloadtrackermap-server-c176b7b4bf4eef6f71767f92ada2591ef27c1cfa.tar.gz
trackermap-server-c176b7b4bf4eef6f71767f92ada2591ef27c1cfa.tar.bz2
trackermap-server-c176b7b4bf4eef6f71767f92ada2591ef27c1cfa.zip
Migrate part of T protocols
Diffstat (limited to 'src/org/traccar/protocol/TytanProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TytanProtocolDecoder.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java
index a65ad4cfc..221df6081 100644
--- a/src/org/traccar/protocol/TytanProtocolDecoder.java
+++ b/src/org/traccar/protocol/TytanProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 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.UnitsConverter;
import org.traccar.model.Position;
@@ -36,7 +38,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private void decodeExtraData(Position position, ChannelBuffer buf, int end) {
+ private void decodeExtraData(Position position, ByteBuf buf, int end) {
while (buf.readerIndex() < end) {
int type = buf.readUnsignedByte();
@@ -73,10 +75,10 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
position.set("antihijack", buf.readUnsignedByte());
break;
case 9:
- position.set("unauthorized", ChannelBuffers.hexDump(buf.readBytes(8)));
+ position.set("unauthorized", ByteBufUtil.hexDump(buf.readBytes(8)));
break;
case 10:
- position.set("authorized", ChannelBuffers.hexDump(buf.readBytes(8)));
+ position.set("authorized", ByteBufUtil.hexDump(buf.readBytes(8)));
break;
case 24:
for (int i = 0; i < length / 2; i++) {
@@ -124,16 +126,16 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.readUnsignedByte(); // protocol
buf.readUnsignedShort(); // length
int index = buf.readUnsignedByte() >> 3;
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.copiedBuffer(
+ ByteBuf response = Unpooled.copiedBuffer(
"^" + index, StandardCharsets.US_ASCII);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
String id = String.valueOf(buf.readUnsignedInt());