aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-08-20 09:00:27 -0700
committerAnton Tananaev <anton@traccar.org>2022-08-20 09:00:27 -0700
commit1fb6c86ea12f325bfdb372d98400c8a904c6e927 (patch)
tree96ae1986eb024145eae836c59ecb369ab20c0190 /src/main/java/org/traccar/protocol
parent3899dddebcee96b80d5c939f50b846ef5042a7ff (diff)
downloadtrackermap-server-1fb6c86ea12f325bfdb372d98400c8a904c6e927.tar.gz
trackermap-server-1fb6c86ea12f325bfdb372d98400c8a904c6e927.tar.bz2
trackermap-server-1fb6c86ea12f325bfdb372d98400c8a904c6e927.zip
Support TK103 cell info (fix #4925)
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java49
1 files changed, 47 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
index e197a8a41..b343c3b33 100644
--- a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -99,6 +99,16 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private static final Pattern PATTERN_CELL = new PatternBuilder()
+ .text("(")
+ .number("(d{12})") // device id
+ .expression(".{4}") // type
+ .number("(?:d{15})?,") // imei
+ .expression("(.+),") // cell
+ .number("(d{8})") // odometer
+ .text(")")
+ .compile();
+
private static final Pattern PATTERN_NETWORK = new PatternBuilder()
.text("(").optional()
.number("(d{12})") // device id
@@ -297,6 +307,39 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private Position decodeCell(Channel channel, SocketAddress remoteAddress, String sentence) {
+ Parser parser = new Parser(PATTERN_CELL, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
+ if (deviceSession == null) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, null);
+
+ Network network = new Network();
+
+ String[] cells = parser.next().split("\n");
+ for (String cell : cells) {
+ String[] values = cell.substring(1, cell.length() - 1).split(",");
+ network.addCellTower(CellTower.from(
+ Integer.parseInt(values[0]), Integer.parseInt(values[1]),
+ Integer.parseInt(values[2]), Integer.parseInt(values[3])));
+ }
+
+ position.setNetwork(network);
+
+ position.set(Position.KEY_ODOMETER, parser.nextLong(16, 0));
+
+ return position;
+ }
+
private Position decodeNetwork(Channel channel, SocketAddress remoteAddress, String sentence) {
Parser parser = new Parser(PATTERN_NETWORK, sentence);
if (!parser.matches()) {
@@ -422,7 +465,9 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
}
}
- if (sentence.contains("ZC20")) {
+ if (sentence.indexOf('{') > 0 && sentence.indexOf('}') > 0) {
+ return decodeCell(channel, remoteAddress, sentence);
+ } else if (sentence.contains("ZC20")) {
return decodeBattery(channel, remoteAddress, sentence);
} else if (sentence.contains("BZ00")) {
return decodeNetwork(channel, remoteAddress, sentence);