aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorValerii Vyshniak <valeravi@vi-soft.com.ua>2017-12-03 03:10:26 +0100
committerValerii Vyshniak <valeravi@vi-soft.com.ua>2017-12-03 03:10:26 +0100
commitf58fe1fcbfcc2be5a0a8113e9e561794eb9b2491 (patch)
tree33dbaf4af16a8febbf23ced695da72d096d8bdbe /src/org/traccar/protocol
parent388b61f289d849848961abb8f454a163b6abc944 (diff)
downloadtraccar-server-f58fe1fcbfcc2be5a0a8113e9e561794eb9b2491.tar.gz
traccar-server-f58fe1fcbfcc2be5a0a8113e9e561794eb9b2491.tar.bz2
traccar-server-f58fe1fcbfcc2be5a0a8113e9e561794eb9b2491.zip
T580W: start and stop frame symbols in data output from tk103 frame decoder
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Tk103FrameDecoder.java4
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java10
2 files changed, 9 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/Tk103FrameDecoder.java b/src/org/traccar/protocol/Tk103FrameDecoder.java
index e6f37981e..e8e0325da 100644
--- a/src/org/traccar/protocol/Tk103FrameDecoder.java
+++ b/src/org/traccar/protocol/Tk103FrameDecoder.java
@@ -38,7 +38,6 @@ public class Tk103FrameDecoder extends FrameDecoder {
buf.clear();
return null;
}
- frameStartIndex++;
int frameEndIndex, freeTextSymbolCounter;
for (frameEndIndex = frameStartIndex, freeTextSymbolCounter = 0;; frameEndIndex++) {
@@ -71,8 +70,7 @@ public class Tk103FrameDecoder extends FrameDecoder {
}
buf.readerIndex(frameStartIndex);
- ChannelBuffer result = buf.readBytes(frameEndIndex - frameStartIndex);
- buf.readerIndex(buf.readerIndex() + 1);
+ ChannelBuffer result = buf.readBytes(frameEndIndex + 1 - frameStartIndex);
return result;
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index d75e019c8..7e2cb06cb 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -41,6 +41,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
}
private static final Pattern PATTERN = new PatternBuilder()
+ .text("(").optional()
.number("(d+)(,)?") // device id
.expression("(.{4}),?") // command
.number("(d*)")
@@ -72,6 +73,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.compile();
private static final Pattern PATTERN_BATTERY = new PatternBuilder()
+ .text("(").optional()
.number("(d+),") // device id
.text("ZC20,")
.number("(dd)(dd)(dd),") // date (ddmmyy)
@@ -80,9 +82,11 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),") // battery voltage
.number("(d+),") // power voltage
.number("d+") // installed
+ .any()
.compile();
private static final Pattern PATTERN_NETWORK = new PatternBuilder()
+ .text("(").optional()
.number("(d{12})") // device id
.text("BZ00,")
.number("(d+),") // mcc
@@ -93,6 +97,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.compile();
private static final Pattern PATTERN_LBSWIFI = new PatternBuilder()
+ .text("(").optional()
.number("(d+),") // device id
.expression("(.{4}),") // command
.number("(d+),") // mcc
@@ -107,6 +112,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.compile();
private static final Pattern PATTERN_COMMAND_RESULT = new PatternBuilder()
+ .text("(").optional()
.number("(d+),") // device id
.expression(".{4},") // command
.number("(dd)(dd)(dd),") // date (ddmmyy)
@@ -349,8 +355,8 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
String sentence = (String) msg;
if (channel != null) {
- String id = sentence.substring(0, 12);
- String type = sentence.substring(12, 16);
+ String id = sentence.substring(1, 13);
+ String type = sentence.substring(13, 17);
if (type.equals("BP00")) {
channel.write("(" + id + "AP01HSO)");
return null;