diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/TeltonikaProtocolEncoder.java | 8 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/TeltonikaProtocolEncoderTest.java | 2 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolEncoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolEncoder.java index 705d01d07..5380cf3a0 100644 --- a/src/main/java/org/traccar/protocol/TeltonikaProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolEncoder.java @@ -32,14 +32,12 @@ public class TeltonikaProtocolEncoder extends BaseProtocolEncoder { ByteBuf buf = Unpooled.buffer(); buf.writeInt(0); - buf.writeInt(content.length + 10); + buf.writeInt(content.length + 8); buf.writeByte(TeltonikaProtocolDecoder.CODEC_12); buf.writeByte(1); // quantity buf.writeByte(5); // type - buf.writeInt(content.length + 2); + buf.writeInt(content.length); buf.writeBytes(content); - buf.writeByte('\r'); - buf.writeByte('\n'); buf.writeByte(1); // quantity buf.writeInt(Checksum.crc16(Checksum.CRC16_IBM, buf.nioBuffer(8, buf.writerIndex() - 8))); @@ -54,7 +52,7 @@ public class TeltonikaProtocolEncoder extends BaseProtocolEncoder { if (data.matches("(\\p{XDigit}{2})+")) { return encodeContent(DataConverter.parseHex(data)); } else { - return encodeContent(data.getBytes(StandardCharsets.US_ASCII)); + return encodeContent((data + "\r\n").getBytes(StandardCharsets.US_ASCII)); } } else { return null; diff --git a/src/test/java/org/traccar/protocol/TeltonikaProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/TeltonikaProtocolEncoderTest.java index 0bd4efb72..5dc78c012 100644 --- a/src/test/java/org/traccar/protocol/TeltonikaProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/TeltonikaProtocolEncoderTest.java @@ -19,7 +19,7 @@ public class TeltonikaProtocolEncoderTest extends ProtocolTest { verifyCommand(encoder, command, binary("00000000000000160C01050000000E7365746469676F75742031310D0A010000E258")); command.set(Command.KEY_DATA, "03030000000185E8"); - verifyCommand(encoder, command, binary("00000000000000120c01050000000a03030000000185e80d0a010000cf19")); + verifyCommand(encoder, command, binary("00000000000000100c01050000000803030000000185e8010000da8b")); } |