aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-24 22:37:09 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-11-24 22:37:09 +1300
commitab8fc4daef86295f9bab39890aa6de2e51342400 (patch)
tree0886ad035e26ffa50e58cfbee58ac4112ec91789
parentb1b5e5ce805064229f0c22ee7e898efa32d22e1a (diff)
downloadtrackermap-server-ab8fc4daef86295f9bab39890aa6de2e51342400.tar.gz
trackermap-server-ab8fc4daef86295f9bab39890aa6de2e51342400.tar.bz2
trackermap-server-ab8fc4daef86295f9bab39890aa6de2e51342400.zip
Fix exception in TK103 protocol (fix #2598)
-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(