diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-03-27 03:29:48 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-03-27 11:47:31 +1300 |
commit | fecb7efe2bbe868ccbb66bb157fcb64d7e78eaac (patch) | |
tree | 2295a25c9b6d561d756f8b95affe24331c51a31d /src | |
parent | 661ff639ad42c9aafbee918cc374d39b9aee871b (diff) | |
download | traccar-server-fecb7efe2bbe868ccbb66bb157fcb64d7e78eaac.tar.gz traccar-server-fecb7efe2bbe868ccbb66bb157fcb64d7e78eaac.tar.bz2 traccar-server-fecb7efe2bbe868ccbb66bb157fcb64d7e78eaac.zip |
Fix Teltonika UDP acknowledgement
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 30a3f4cda..3f5b68f67 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -246,7 +246,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { } private List<Position> parseData( - Channel channel, SocketAddress remoteAddress, ChannelBuffer buf, int packetId, String... imei) { + Channel channel, SocketAddress remoteAddress, ChannelBuffer buf, int locationPacketId, String... imei) { List<Position> positions = new LinkedList<>(); if (!(channel instanceof DatagramChannel)) { @@ -279,13 +279,15 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { if (channel != null) { if (channel instanceof DatagramChannel) { - ChannelBuffer response = ChannelBuffers.directBuffer(5); - response.writeShort(3); - response.writeShort(packetId); - response.writeByte(0x02); + ChannelBuffer response = ChannelBuffers.dynamicBuffer(); + response.writeShort(5); + response.writeShort(0); + response.writeByte(0x01); + response.writeByte(locationPacketId); + response.writeByte(count); channel.write(response, remoteAddress); } else { - ChannelBuffer response = ChannelBuffers.directBuffer(4); + ChannelBuffer response = ChannelBuffers.dynamicBuffer(); response.writeInt(count); channel.write(response); } @@ -320,12 +322,13 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { private Object decodeUdp(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception { - buf.skipBytes(2); - int packetId = buf.readUnsignedShort(); - buf.skipBytes(2); + buf.readUnsignedShort(); // length + buf.readUnsignedShort(); // packet id + buf.readUnsignedByte(); // packet type + int locationPacketId = buf.readUnsignedByte(); String imei = buf.readBytes(buf.readUnsignedShort()).toString(StandardCharsets.US_ASCII); - return parseData(channel, remoteAddress, buf, packetId, imei); + return parseData(channel, remoteAddress, buf, locationPacketId, imei); } |