aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-19 10:35:57 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-19 10:35:57 +1300
commit5d919c8489ea3c88d3182fab77b6b24b9dd86bef (patch)
treebbb38522c7966698f6f74735b0da37b6d87c9eb1 /src/org/traccar
parentcc5d60ff499c39fb4db7e06b2e62fefe2a324f77 (diff)
downloadtraccar-server-5d919c8489ea3c88d3182fab77b6b24b9dd86bef.tar.gz
traccar-server-5d919c8489ea3c88d3182fab77b6b24b9dd86bef.tar.bz2
traccar-server-5d919c8489ea3c88d3182fab77b6b24b9dd86bef.zip
Implement LBS support for TK103
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index 95728c447..6fa4edb06 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -64,6 +64,16 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.number("d+") // installed
.compile();
+ private static final Pattern PATTERN_NETWORK = new PatternBuilder()
+ .number("(d{12})") // device id
+ .text("BZ00,")
+ .number("(d+),") // mcc
+ .number("(d+),") // mnc
+ .number("(x+),") // lac
+ .number("(x+),") // cid
+ .any()
+ .compile();
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -88,11 +98,11 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
}
}
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
+
Parser parser = new Parser(PATTERN_BATTERY, sentence);
if (parser.matches()) {
- Position position = new Position();
- position.setProtocol(getProtocolName());
-
if (!identify(parser.next(), channel)) {
return null;
}
@@ -117,14 +127,28 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ parser = new Parser(PATTERN_NETWORK, sentence);
+ if (parser.matches()) {
+ if (!identify(parser.next(), channel)) {
+ return null;
+ }
+ position.setDeviceId(getDeviceId());
+
+ getLastLocation(position, null);
+
+ position.set(Event.KEY_MCC, parser.nextInt());
+ position.set(Event.KEY_MNC, parser.nextInt());
+ position.set(Event.KEY_LAC, parser.nextInt(16));
+ position.set(Event.KEY_CID, parser.nextInt(16));
+
+ return position;
+ }
+
parser = new Parser(PATTERN, sentence);
if (!parser.matches()) {
return null;
}
- Position position = new Position();
- position.setProtocol(getProtocolName());
-
if (!identify(parser.next(), channel)) {
return null;
}