diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-05-08 22:59:58 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-05-08 22:59:58 +1200 |
commit | 986912687a15f3d1376beae751a9160c3db5dc7a (patch) | |
tree | fef077321f44d2de04a1457b7ef87bd8ecf0df1e | |
parent | 86796b2c2c46e866af63c599a83b4de0112b78f1 (diff) | |
download | traccar-server-986912687a15f3d1376beae751a9160c3db5dc7a.tar.gz traccar-server-986912687a15f3d1376beae751a9160c3db5dc7a.tar.bz2 traccar-server-986912687a15f3d1376beae751a9160c3db5dc7a.zip |
Add IO support for Teltonika (fix #143)
-rw-r--r-- | src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 4d9e72588..a7bdf6132 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -87,12 +87,31 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { extendedInfo.set("event", buf.readUnsignedByte()); - // Skip IO data buf.readUnsignedByte(); // total IO data records - buf.skipBytes(buf.readUnsignedByte() * (1 + 1)); - buf.skipBytes(buf.readUnsignedByte() * (1 + 2)); - buf.skipBytes(buf.readUnsignedByte() * (1 + 4)); - buf.skipBytes(buf.readUnsignedByte() * (1 + 8)); + + // Read 1 byte data + int cnt = buf.readUnsignedByte(); + for (int j = 0; j < cnt; j++) { + extendedInfo.set("io" + buf.readUnsignedByte(), buf.readUnsignedByte()); + } + + // Read 2 byte data + cnt = buf.readUnsignedByte(); + for (int j = 0; j < cnt; j++) { + extendedInfo.set("io" + buf.readUnsignedByte(), buf.readUnsignedShort()); + } + + // Read 4 byte data + cnt = buf.readUnsignedByte(); + for (int j = 0; j < cnt; j++) { + extendedInfo.set("io" + buf.readUnsignedByte(), buf.readUnsignedInt()); + } + + // Read 8 byte data + cnt = buf.readUnsignedByte(); + for (int j = 0; j < cnt; j++) { + extendedInfo.set("io" + buf.readUnsignedByte(), buf.readLong()); + } position.setExtendedInfo(extendedInfo.toString()); positions.add(position); |