aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-05-15 21:52:39 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-05-15 21:52:39 -0700
commit60eaf3b8dea078acc7a08318e072c335c189043a (patch)
tree3efad7c77ec993392642bc0daa10408a012cdf15 /src
parentc10492f8d2324fa8ba8cdf18f864326b5ca01753 (diff)
downloadtrackermap-server-60eaf3b8dea078acc7a08318e072c335c189043a.tar.gz
trackermap-server-60eaf3b8dea078acc7a08318e072c335c189043a.tar.bz2
trackermap-server-60eaf3b8dea078acc7a08318e072c335c189043a.zip
No line break for binary commands
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/TeltonikaProtocolEncoder.java8
-rw-r--r--src/test/java/org/traccar/protocol/TeltonikaProtocolEncoderTest.java2
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"));
}