aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-08-21 16:18:39 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-08-21 16:19:11 +1200
commit2a386eab0a4baed5c606113dd9a875a088f9f4e5 (patch)
treec1521c01924a353e5ee5603ee58a9ba530da26f2
parent5f3f51c20755d21784d9cfa5a9aa16474d25b1c0 (diff)
downloadtrackermap-server-2a386eab0a4baed5c606113dd9a875a088f9f4e5.tar.gz
trackermap-server-2a386eab0a4baed5c606113dd9a875a088f9f4e5.tar.bz2
trackermap-server-2a386eab0a4baed5c606113dd9a875a088f9f4e5.zip
Support codec 16 for Teltonika
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java22
-rw-r--r--test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java6
2 files changed, 22 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 1bd56c176..6eac52585 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -353,7 +353,12 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort()));
- position.set(Position.KEY_EVENT, buf.readUnsignedByte());
+ if (codec == CODEC_16) {
+ position.set(Position.KEY_EVENT, buf.readUnsignedShort());
+ buf.readUnsignedByte(); // generation type
+ } else {
+ position.set(Position.KEY_EVENT, buf.readUnsignedByte());
+ }
buf.readUnsignedByte(); // total IO data records
@@ -363,7 +368,8 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(globalMask, 1)) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- decodeParameter(position, buf.readUnsignedByte(), buf, 1, codec);
+ int id = codec == CODEC_16 ? buf.readUnsignedShort() : buf.readUnsignedByte();
+ decodeParameter(position, id, buf, 1, codec);
}
}
@@ -371,7 +377,8 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(globalMask, 2)) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- decodeParameter(position, buf.readUnsignedByte(), buf, 2, codec);
+ int id = codec == CODEC_16 ? buf.readUnsignedShort() : buf.readUnsignedByte();
+ decodeParameter(position, id, buf, 2, codec);
}
}
@@ -379,7 +386,8 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(globalMask, 3)) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- decodeParameter(position, buf.readUnsignedByte(), buf, 4, codec);
+ int id = codec == CODEC_16 ? buf.readUnsignedShort() : buf.readUnsignedByte();
+ decodeParameter(position, id, buf, 4, codec);
}
}
@@ -387,7 +395,8 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (codec == CODEC_FM4X00 || codec == CODEC_16) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- decodeOtherParameter(position, buf.readUnsignedByte(), buf, 8);
+ int id = codec == CODEC_16 ? buf.readUnsignedShort() : buf.readUnsignedByte();
+ decodeOtherParameter(position, id, buf, 8);
}
}
@@ -395,7 +404,8 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (extended) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- position.set(Position.PREFIX_IO + buf.readUnsignedByte(), ByteBufUtil.hexDump(buf.readSlice(16)));
+ int id = codec == CODEC_16 ? buf.readUnsignedShort() : buf.readUnsignedByte();
+ position.set(Position.PREFIX_IO + id, ByteBufUtil.hexDump(buf.readSlice(16)));
}
}
diff --git a/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java b/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
index a40e48d82..12eb57f35 100644
--- a/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
@@ -15,6 +15,12 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest {
"000F313233343536373839303132333435"));
verifyPositions(decoder, false, binary(
+ "000000000000009D10020000013feb55ff74000f0ea850209a690000AE00B90B00000000070A050001000002000003000004000120000200180000004601290200C700000000004C0000000001003E00000000000000000000015B198C7498000F0DBC502095872F00AE00B90B00000000070A050001000002000003000004000120000200180000004601290200C700000000004C0000000001003E000000000000000002000009A5"));
+
+ verifyPositions(decoder, false, binary(
+ "000000000000009F100100000164D855401800D5E3B744EC11C762023B011A060000000007200A010000010500010600010D00010E00010F00011600011700011800011F001301010000010700000108000001090000010A0000010B0000010C000001100000011100000112000001130000011400000115000001190000011A0000011B0000011C0000011D0000011E000003010200000000010300000000010400000000000100000D3B"));
+
+ verifyPositions(decoder, false, binary(
"000000000000008c08010000013feb55ff74000f0ea850209a690000940000120000001e09FD01FE210300040016014703f0001504c8000c0900730a00460b00501300464306d7440000b5000bb60007422e9f180000cd0386ce000107c700000000f10000601a46000001344800000bb84900000bb84a00000bb84c00000000024e0000000000000000cf00000000000000000100003fca"));
verifyPositions(decoder, false, binary(