diff options
Diffstat (limited to 'src/org/traccar/protocol/RecodaProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/RecodaProtocolDecoder.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/RecodaProtocolDecoder.java b/src/org/traccar/protocol/RecodaProtocolDecoder.java index 7bd4d3dae..eef1cb5af 100644 --- a/src/org/traccar/protocol/RecodaProtocolDecoder.java +++ b/src/org/traccar/protocol/RecodaProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 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,8 +15,8 @@ */ package org.traccar.protocol; -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.channel.Channel; +import io.netty.buffer.ByteBuf; +import io.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.helper.BitUtil; @@ -43,19 +43,19 @@ public class RecodaProtocolDecoder extends BaseProtocolDecoder { protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { - ChannelBuffer buf = (ChannelBuffer) msg; + ByteBuf buf = (ByteBuf) msg; - int type = buf.readInt(); - buf.readUnsignedInt(); // length + int type = buf.readIntLE(); + buf.readUnsignedIntLE(); // length if (type != MSG_HEARTBEAT) { - buf.readUnsignedShort(); // version - buf.readUnsignedShort(); // index + buf.readUnsignedShortLE(); // version + buf.readUnsignedShortLE(); // index } if (type == MSG_SIGNAL_LINK_REGISTRATION) { - getDeviceSession(channel, remoteAddress, buf.readBytes(12).toString(StandardCharsets.US_ASCII)); + getDeviceSession(channel, remoteAddress, buf.readSlice(12).toString(StandardCharsets.US_ASCII)); } else if (type == MSG_GPS_DATA) { @@ -67,21 +67,21 @@ public class RecodaProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - position.setTime(new Date(buf.readLong())); + position.setTime(new Date(buf.readLongLE())); int flags = buf.readUnsignedByte(); if (BitUtil.check(flags, 0)) { - buf.readUnsignedShort(); // declination + buf.readUnsignedShortLE(); // declination - position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort())); + position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShortLE())); position.setLongitude(buf.readUnsignedByte() + buf.readUnsignedByte() / 60.0); position.setLatitude(buf.readUnsignedByte() + buf.readUnsignedByte() / 60.0); - position.setLongitude(position.getLongitude() + buf.readUnsignedInt() / 3600.0); - position.setLatitude(position.getLatitude() + buf.readUnsignedInt() / 3600.0); + position.setLongitude(position.getLongitude() + buf.readUnsignedIntLE() / 3600.0); + position.setLatitude(position.getLatitude() + buf.readUnsignedIntLE() / 3600.0); int status = buf.readUnsignedByte(); |