From d8e06f0f17f3c82c4410b7dc9e540e8c75e4faa7 Mon Sep 17 00:00:00 2001 From: Srgian Danity Date: Thu, 19 Jan 2017 13:06:47 +0200 Subject: Switched from getXxx to readXxx on buffer --- src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 2c5e31afb..bc1a4704e 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -214,11 +214,9 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { } private List parseData( - Channel channel, SocketAddress remoteAddress, ChannelBuffer buf, int offset, int packetId, String... imei) { + Channel channel, SocketAddress remoteAddress, ChannelBuffer buf, int packetId, String... imei) { List positions = new LinkedList<>(); - buf.skipBytes(offset); // marker - if (!(channel instanceof DatagramChannel)) { buf.readUnsignedInt(); // data length } @@ -281,7 +279,8 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { if (buf.getUnsignedShort(0) > 0) { parseIdentification(channel, remoteAddress, buf); } else { - return parseData(channel, remoteAddress, buf, 4, 0); + buf.skipBytes(4); + return parseData(channel, remoteAddress, buf, 0); } return null; @@ -289,12 +288,14 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { protected Object decodeUdp(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception { - int packetId = buf.getShort(2); - int imeiLength = buf.getUnsignedShort(6); + buf.skipBytes(2); + int packetId = buf.readUnsignedShort(); + buf.skipBytes(2); + int imeiLength = buf.readUnsignedShort(); String imei = buf.toString(8, imeiLength, StandardCharsets.US_ASCII); - int offset = 8 + imeiLength; + buf.skipBytes(imeiLength); - return parseData(channel, remoteAddress, buf, offset, packetId, imei); + return parseData(channel, remoteAddress, buf, packetId, imei); } -- cgit v1.2.3