aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/TeltonikaProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 72e06c083..15c5b8e80 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -18,8 +18,8 @@ package org.traccar.protocol;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.socket.DatagramChannel;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
@@ -35,8 +35,17 @@ import java.util.List;
public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
- public TeltonikaProtocolDecoder(TeltonikaProtocol protocol) {
+ private boolean connectionless;
+ private boolean extended;
+
+ public void setExtended(boolean extended) {
+ this.extended = extended;
+ }
+
+ public TeltonikaProtocolDecoder(TeltonikaProtocol protocol, boolean connectionless) {
super(protocol);
+ this.connectionless = connectionless;
+ this.extended = Context.getConfig().getBoolean(getProtocolName() + ".extended");
}
private DeviceSession parseIdentification(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
@@ -243,13 +252,21 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
}
+ // Read 16 byte data
+ if (extended) {
+ int cnt = buf.readUnsignedByte();
+ for (int j = 0; j < cnt; j++) {
+ position.set(Position.PREFIX_IO + buf.readUnsignedByte(), ChannelBuffers.hexDump(buf.readBytes(16)));
+ }
+ }
+
}
private List<Position> parseData(
Channel channel, SocketAddress remoteAddress, ChannelBuffer buf, int locationPacketId, String... imei) {
List<Position> positions = new LinkedList<>();
- if (!(channel instanceof DatagramChannel)) {
+ if (!connectionless) {
buf.readUnsignedInt(); // data length
}
@@ -278,7 +295,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
if (channel != null) {
- if (channel instanceof DatagramChannel) {
+ if (connectionless) {
ChannelBuffer response = ChannelBuffers.dynamicBuffer();
response.writeShort(5);
response.writeShort(0);
@@ -301,7 +318,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
ChannelBuffer buf = (ChannelBuffer) msg;
- if (channel instanceof DatagramChannel) {
+ if (connectionless) {
return decodeUdp(channel, remoteAddress, buf);
} else {
return decodeTcp(channel, remoteAddress, buf);