From 473e671a14bb826cdbf73f732fbd8b8eec6f3986 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 5 Jun 2020 23:33:48 -0700 Subject: Support Teltonika codec 13 --- src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java | 9 ++++++++- .../java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java index ab7aa4b43..be7a01ee0 100644 --- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -78,6 +78,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { public static final int CODEC_8 = 0x08; public static final int CODEC_8_EXT = 0x8E; public static final int CODEC_12 = 0x0C; + public static final int CODEC_13 = 0x0D; public static final int CODEC_16 = 0x10; private void sendImageRequest(Channel channel, SocketAddress remoteAddress, long id, int offset, int size) { @@ -598,7 +599,13 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); position.setValid(true); - if (codec == CODEC_12) { + if (codec == CODEC_13) { + buf.readUnsignedByte(); // type + int length = buf.readInt() - 4; + getLastLocation(position, new Date(buf.readUnsignedInt() * 1000)); + position.set(Position.KEY_RESULT, + buf.readCharSequence(length, StandardCharsets.US_ASCII).toString().trim()); + } else if (codec == CODEC_12) { decodeSerial(channel, remoteAddress, position, buf); } else { decodeLocation(position, buf, codec); diff --git a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java index 827e12a96..5b2df38db 100644 --- a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java @@ -15,6 +15,12 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "000F313233343536373839303132333435")); + verifyPositions(decoder, false, binary( + "000000000000001C0D01050000001056E924222347455420444154414F524445520D0A0100004990")); + + verifyPositions(decoder, false, binary( + "00000000000000170D01050000000F0000016C0A81C320676574696E666F0100006855")); + verifyPositions(decoder, false, binary( "000000000000004f0c01060000004755555555777730362e343b30342e323b30302e303b30302e303b30302e303b30302e303b30302e303b30302e303b30312e333b30302e303b31302e373b30302e303b5353530d0a010000e371")); -- cgit v1.2.3