aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java6
-rw-r--r--test/org/traccar/protocol/Tk103ProtocolDecoderTest.java3
2 files changed, 7 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index 9d04483c1..d3bc0efdc 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -113,9 +113,11 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
String type = sentence.substring(12, 16);
if (type.equals("BP00") || type.equals("BP05")) {
String content = sentence.substring(16);
- getDeviceSession(channel, remoteAddress, content.substring(0, 15));
+ if (content.length() >= 15) {
+ getDeviceSession(channel, remoteAddress, content.substring(0, 15));
+ }
if (type.equals("BP00")) {
- channel.write("(" + id + "AP01" + content.substring(15) + ")");
+ channel.write("(" + id + "AP01HSO)");
return null;
} else if (type.equals("BP05")) {
channel.write("(" + id + "AP05)");
diff --git a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
index 4c6f0e004..1875e4ac5 100644
--- a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class Tk103ProtocolDecoderTest extends ProtocolTest {
Tk103ProtocolDecoder decoder = new Tk103ProtocolDecoder(new Tk103Protocol());
verifyNothing(decoder, text(
+ "(087073005534BP00HSO"));
+
+ verifyNothing(decoder, text(
"(027028258309BQ86,0,05550c21b10d1d0f431008bd114c0ea5078400010007a100423932,161117005322,01000001)"));
verifyNothing(decoder, text(