From 3dc2ecf209013f26996d307be2cbeb666476a7df Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 20 Jan 2017 22:29:15 +1300 Subject: Minor Teltonika decoder improvements --- src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index bc1a4704e..6f3af0bb2 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2017 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. @@ -274,7 +274,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { } } - protected Object decodeTcp(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception { + private Object decodeTcp(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception { if (buf.getUnsignedShort(0) > 0) { parseIdentification(channel, remoteAddress, buf); @@ -286,14 +286,12 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { return null; } - protected Object decodeUdp(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception { + private Object decodeUdp(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception { buf.skipBytes(2); int packetId = buf.readUnsignedShort(); buf.skipBytes(2); - int imeiLength = buf.readUnsignedShort(); - String imei = buf.toString(8, imeiLength, StandardCharsets.US_ASCII); - buf.skipBytes(imeiLength); + String imei = buf.readBytes(buf.readUnsignedShort()).toString(StandardCharsets.US_ASCII); return parseData(channel, remoteAddress, buf, packetId, imei); -- cgit v1.2.3