aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/CalAmpProtocolDecoder.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/CalAmpProtocolDecoder.java
parent9c99076dc2416c4e0725007af0e5f2f2f444c05c (diff)
downloadtraccar-server-562535fd538e7b05b6fe96c0f56eb2ec0ae1fd0e.tar.gz
traccar-server-562535fd538e7b05b6fe96c0f56eb2ec0ae1fd0e.tar.bz2
traccar-server-562535fd538e7b05b6fe96c0f56eb2ec0ae1fd0e.zip
Migrate more protocols
Diffstat (limited to 'src/org/traccar/protocol/CalAmpProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/CalAmpProtocolDecoder.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
index f717d3c5d..9e9bd1336 100644
--- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 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;
@@ -52,7 +54,7 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
private void sendResponse(Channel channel, SocketAddress remoteAddress, int type, int index, int result) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(10);
+ ByteBuf response = Unpooled.buffer(10);
response.writeByte(SERVICE_RESPONSE);
response.writeByte(MSG_ACK);
response.writeShort(index);
@@ -60,11 +62,11 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
response.writeByte(result);
response.writeByte(0);
response.writeMedium(0);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
- private Position decodePosition(DeviceSession deviceSession, int type, ChannelBuffer buf) {
+ private Position decodePosition(DeviceSession deviceSession, int type, ByteBuf buf) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -143,14 +145,14 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (BitUtil.check(buf.getByte(buf.readerIndex()), 7)) {
int content = buf.readUnsignedByte();
if (BitUtil.check(content, 0)) {
- String id = ChannelBuffers.hexDump(buf.readBytes(buf.readUnsignedByte()));
+ String id = ByteBufUtil.hexDump(buf.readBytes(buf.readUnsignedByte()));
getDeviceSession(channel, remoteAddress, id);
}