aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/AplicomProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/AplicomProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/AplicomProtocolDecoder.java82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java
index e649b52a6..54b15700a 100644
--- a/src/org/traccar/protocol/AplicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java
@@ -15,9 +15,9 @@
*/
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.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
@@ -82,7 +82,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
private static final int EVENT_DATA = 119;
- private void decodeEventData(Position position, ChannelBuffer buf, int event) {
+ private void decodeEventData(Position position, ByteBuf buf, int event) {
switch (event) {
case 2:
case 40:
@@ -117,7 +117,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeCanData(ChannelBuffer buf, Position position) {
+ private void decodeCanData(ByteBuf buf, Position position) {
buf.readUnsignedMedium(); // packet identifier
position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte());
@@ -128,63 +128,63 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(8);
- ArrayList<ChannelBuffer> values = new ArrayList<>(count);
+ ArrayList<ByteBuf> values = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
- values.add(buf.readBytes(8));
+ values.add(buf.readSlice(8));
}
for (int i = 0; i < count; i++) {
- ChannelBuffer value = values.get(i);
+ ByteBuf value = values.get(i);
switch (buf.readInt()) {
case 0x20D:
- position.set(Position.KEY_RPM, ChannelBuffers.swapShort(value.readShort()));
- position.set("dieselTemperature", ChannelBuffers.swapShort(value.readShort()) * 0.1);
- position.set("batteryVoltage", ChannelBuffers.swapShort(value.readShort()) * 0.01);
- position.set("supplyAirTempDep1", ChannelBuffers.swapShort(value.readShort()) * 0.1);
+ position.set(Position.KEY_RPM, value.readShortLE());
+ position.set("dieselTemperature", value.readShortLE() * 0.1);
+ position.set("batteryVoltage", value.readShortLE() * 0.01);
+ position.set("supplyAirTempDep1", value.readShortLE() * 0.1);
break;
case 0x30D:
- position.set("activeAlarm", ChannelBuffers.hexDump(value));
+ position.set("activeAlarm", ByteBufUtil.hexDump(value));
break;
case 0x40C:
- position.set("airTempDep1", ChannelBuffers.swapShort(value.readShort()) * 0.1);
- position.set("airTempDep2", ChannelBuffers.swapShort(value.readShort()) * 0.1);
+ position.set("airTempDep1", value.readShortLE() * 0.1);
+ position.set("airTempDep2", value.readShortLE() * 0.1);
break;
case 0x40D:
- position.set("coldUnitState", ChannelBuffers.hexDump(value));
+ position.set("coldUnitState", ByteBufUtil.hexDump(value));
break;
case 0x50C:
- position.set("defrostTempDep1", ChannelBuffers.swapShort(value.readShort()) * 0.1);
- position.set("defrostTempDep2", ChannelBuffers.swapShort(value.readShort()) * 0.1);
+ position.set("defrostTempDep1", value.readShortLE() * 0.1);
+ position.set("defrostTempDep2", value.readShortLE() * 0.1);
break;
case 0x50D:
- position.set("condenserPressure", ChannelBuffers.swapShort(value.readShort()) * 0.1);
- position.set("suctionPressure", ChannelBuffers.swapShort(value.readShort()) * 0.1);
+ position.set("condenserPressure", value.readShortLE() * 0.1);
+ position.set("suctionPressure", value.readShortLE() * 0.1);
break;
case 0x58C:
value.readByte();
value.readShort(); // index
switch (value.readByte()) {
case 0x01:
- position.set("setpointZone1", ChannelBuffers.swapInt(value.readInt()) * 0.1);
+ position.set("setpointZone1", value.readIntLE() * 0.1);
break;
case 0x02:
- position.set("setpointZone2", ChannelBuffers.swapInt(value.readInt()) * 0.1);
+ position.set("setpointZone2", value.readIntLE() * 0.1);
break;
case 0x05:
- position.set("unitType", ChannelBuffers.swapInt(value.readInt()));
+ position.set("unitType", value.readIntLE());
break;
case 0x13:
- position.set("dieselHours", ChannelBuffers.swapInt(value.readInt()) / 60 / 60);
+ position.set("dieselHours", value.readIntLE() / 60 / 60);
break;
case 0x14:
- position.set("electricHours", ChannelBuffers.swapInt(value.readInt()) / 60 / 60);
+ position.set("electricHours", value.readIntLE() / 60 / 60);
break;
case 0x17:
- position.set("serviceIndicator", ChannelBuffers.swapInt(value.readInt()));
+ position.set("serviceIndicator", value.readIntLE());
break;
case 0x18:
- position.set("softwareVersion", ChannelBuffers.swapInt(value.readInt()) * 0.01);
+ position.set("softwareVersion", value.readIntLE() * 0.01);
break;
default:
break;
@@ -197,7 +197,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeD(Position position, ChannelBuffer buf, int selector, int event) {
+ private void decodeD(Position position, ByteBuf buf, int selector, int event) {
if ((selector & 0x0008) != 0) {
position.setValid((buf.readUnsignedByte() & 0x40) != 0);
@@ -292,12 +292,12 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
if (Context.getConfig().getBoolean(getProtocolName() + ".can")
- && buf.readable() && (selector & 0x1000) != 0 && event == EVENT_DATA) {
+ && buf.isReadable() && (selector & 0x1000) != 0 && event == EVENT_DATA) {
decodeCanData(buf, position);
}
}
- private void decodeE(Position position, ChannelBuffer buf, int selector) {
+ private void decodeE(Position position, ByteBuf buf, int selector) {
if ((selector & 0x0008) != 0) {
position.set("tachographEvent", buf.readUnsignedShort());
@@ -349,13 +349,13 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
if ((selector & 0x0800) != 0) {
- position.set(Position.KEY_VIN, buf.readBytes(18).toString(StandardCharsets.US_ASCII).trim());
+ position.set(Position.KEY_VIN, buf.readSlice(18).toString(StandardCharsets.US_ASCII).trim());
}
if ((selector & 0x2000) != 0) {
buf.readUnsignedByte(); // card 1 type
buf.readUnsignedByte(); // card 1 country code
- String card = buf.readBytes(20).toString(StandardCharsets.US_ASCII).trim();
+ String card = buf.readSlice(20).toString(StandardCharsets.US_ASCII).trim();
if (!card.isEmpty()) {
position.set("card1", card);
}
@@ -364,7 +364,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
if ((selector & 0x4000) != 0) {
buf.readUnsignedByte(); // card 2 type
buf.readUnsignedByte(); // card 2 country code
- String card = buf.readBytes(20).toString(StandardCharsets.US_ASCII).trim();
+ String card = buf.readSlice(20).toString(StandardCharsets.US_ASCII).trim();
if (!card.isEmpty()) {
position.set("card2", card);
}
@@ -373,13 +373,13 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
if ((selector & 0x10000) != 0) {
int count = buf.readUnsignedByte();
for (int i = 1; i <= count; i++) {
- position.set("driver" + i, buf.readBytes(22).toString(StandardCharsets.US_ASCII).trim());
+ position.set("driver" + i, buf.readSlice(22).toString(StandardCharsets.US_ASCII).trim());
position.set("driverTime" + i, buf.readUnsignedInt());
}
}
}
- private void decodeH(Position position, ChannelBuffer buf, int selector) {
+ private void decodeH(Position position, ByteBuf buf, int selector) {
if ((selector & 0x0004) != 0) {
getLastLocation(position, new Date(buf.readUnsignedInt() * 1000));
@@ -457,7 +457,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeEB(Position position, ChannelBuffer buf) {
+ private void decodeEB(Position position, ByteBuf buf) {
if (buf.readByte() != (byte) 'E' || buf.readByte() != (byte) 'B') {
return;
@@ -477,7 +477,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
switch (type) {
case 0x01:
- position.set("brakeFlags", ChannelBuffers.hexDump(buf.readBytes(length)));
+ position.set("brakeFlags", ByteBufUtil.hexDump(buf.readSlice(length)));
break;
case 0x02:
position.set("wheelSpeed", buf.readUnsignedShort() / 256.0);
@@ -507,10 +507,10 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
position.set("vdcActiveCounter", buf.readUnsignedShort());
break;
case 0x0B:
- position.set("brakeMinMaxData", ChannelBuffers.hexDump(buf.readBytes(length)));
+ position.set("brakeMinMaxData", ByteBufUtil.hexDump(buf.readSlice(length)));
break;
case 0x0C:
- position.set("missingPgn", ChannelBuffers.hexDump(buf.readBytes(length)));
+ position.set("missingPgn", ByteBufUtil.hexDump(buf.readSlice(length)));
break;
case 0x0D:
buf.readUnsignedByte();
@@ -526,7 +526,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeF(Position position, ChannelBuffer buf, int selector) {
+ private void decodeF(Position position, ByteBuf buf, int selector) {
getLastLocation(position, null);
@@ -636,7 +636,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
char protocol = (char) buf.readByte();
int version = buf.readUnsignedByte();