diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-04-14 19:15:59 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-04-14 19:15:59 -0700 |
commit | e2531fc5c0d1d28c190ceeba6a0e8627b26d6c60 (patch) | |
tree | e3e4cd21c5b037fc13a2462326607c67bf65b225 /src | |
parent | 90c2f67629064126834450aafcaffdc4187fe55a (diff) | |
download | traccar-server-e2531fc5c0d1d28c190ceeba6a0e8627b26d6c60.tar.gz traccar-server-e2531fc5c0d1d28c190ceeba6a0e8627b26d6c60.tar.bz2 traccar-server-e2531fc5c0d1d28c190ceeba6a0e8627b26d6c60.zip |
Decode fault codes
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java | 14 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java | 3 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java index 716589e00..74b4be8d5 100644 --- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2020 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2021 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -537,7 +537,11 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { int id = buf.readUnsignedShort(); int length = buf.readUnsignedShort(); if (id == 256) { - position.set(Position.KEY_VIN, buf.readSlice(length).toString(StandardCharsets.US_ASCII)); + position.set(Position.KEY_VIN, + buf.readSlice(length).toString(StandardCharsets.US_ASCII)); + } else if (id == 281) { + position.set(Position.KEY_DTCS, + buf.readSlice(length).toString(StandardCharsets.US_ASCII).replace(',', ' ')); } else if (id == 385) { ByteBuf data = buf.readSlice(length); data.readUnsignedByte(); // data part @@ -617,19 +621,17 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { } if (channel != null && codec != CODEC_12 && codec != CODEC_13) { + ByteBuf response = Unpooled.buffer(); if (connectionless) { - ByteBuf response = Unpooled.buffer(); response.writeShort(5); response.writeShort(0); response.writeByte(0x01); response.writeByte(locationPacketId); response.writeByte(count); - channel.writeAndFlush(new NetworkMessage(response, remoteAddress)); } else { - ByteBuf response = Unpooled.buffer(); response.writeInt(count); - channel.writeAndFlush(new NetworkMessage(response, remoteAddress)); } + channel.writeAndFlush(new NetworkMessage(response, remoteAddress)); } return positions.isEmpty() ? null : positions; diff --git a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java index bd4058d2e..5577a08ac 100644 --- a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java @@ -15,6 +15,9 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest { "000F313233343536373839303132333435")); verifyPositions(decoder, binary( + "00000000000000a38e0100000178b11c9e1000040bbbc91f03190c002100e113001300000010000600ef0100f00100150300c800004501001e070005004237e00018000a00ce166200430f970024059f000300f10000665900c70000001e00100000a1b500000002010000115756315a5a5a32455a38363031353338380119002950303239392c50303637352c50303637342c50303637322c50303637312c50303437312c50324241430100001ad8")); + + verifyPositions(decoder, binary( "00000000000000858e0200000174431aadc100061d888f21000e8a0032002e0c000001810001000000000000000000010181001711210102030405060708090a0b0c0d0e0f10020b010ad000000174431a389100061d888f21000e8a0033002e0d000001810001000000000000000000010181001711210102030405060708090a0b0c0d0e0f10020b010ad2020000492b")); verifyPositions(decoder, false, binary( |