From 60eaf3b8dea078acc7a08318e072c335c189043a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 15 May 2019 21:52:39 -0700 Subject: No line break for binary commands --- src/main/java/org/traccar/protocol/TeltonikaProtocolEncoder.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/main/java/org') 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; -- cgit v1.2.3