aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-11-17 07:11:20 -0800
committerAnton Tananaev <anton@traccar.org>2023-11-17 07:11:20 -0800
commit962371fe50c9f2189ee5452def16c6fbd09a63f5 (patch)
tree0e0e19af6097bc4c16d91c8cbec2d3d77589c0d9
parent53de5422119c993d3fe8ed5b476c65cc01d340c5 (diff)
downloadtrackermap-server-962371fe50c9f2189ee5452def16c6fbd09a63f5.tar.gz
trackermap-server-962371fe50c9f2189ee5452def16c6fbd09a63f5.tar.bz2
trackermap-server-962371fe50c9f2189ee5452def16c6fbd09a63f5.zip
Support Queclink GT501MA devices
-rw-r--r--src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java25
-rw-r--r--src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java4
2 files changed, 26 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
index 530ab836a..a4ace7a1c 100644
--- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -260,7 +260,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
}
private void skipLocation(Parser parser) {
- parser.skip(19);
+ parser.skip(20);
}
private static final Pattern PATTERN_LOCATION = new PatternBuilder()
@@ -272,6 +272,10 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
.number("(-?d{1,2}.d{6})?,") // latitude
.number("(dddd)(dd)(dd)") // date (yyyymmdd)
.number("(dd)(dd)(dd)").optional(2) // time (hhmmss)
+ .groupBegin()
+ .number(",d+") // wifi count
+ .number("((?:,x{12},-d+,,,)+)") // wifi
+ .groupEnd("?")
.text(",")
.number("(d+)?,") // mcc
.number("(d+)?,") // mnc
@@ -303,17 +307,32 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
}
+ Network network = new Network();
+
+ if (parser.hasNext()) {
+ String[] values = parser.next().split(",");
+ for (int i = 0; i < values.length; i += 5) {
+ String mac = values[i + 1].replaceAll("(..)", "$1:");
+ network.addWifiAccessPoint(WifiAccessPoint.from(
+ mac.substring(0, mac.length() - 1), Integer.parseInt(values[i + 2])));
+ }
+ }
+
if (parser.hasNext(6)) {
int mcc = parser.nextInt();
int mnc = parser.nextInt();
if (parser.hasNext(2)) {
- position.setNetwork(new Network(CellTower.from(mcc, mnc, parser.nextInt(), parser.nextInt())));
+ network.addCellTower(CellTower.from(mcc, mnc, parser.nextInt(), parser.nextInt()));
}
if (parser.hasNext(2)) {
- position.setNetwork(new Network(CellTower.from(mcc, mnc, parser.nextHexInt(), parser.nextHexInt())));
+ network.addCellTower(CellTower.from(mcc, mnc, parser.nextHexInt(), parser.nextHexInt()));
}
}
+ if (network.getWifiAccessPoints() != null || network.getCellTowers() != null) {
+ position.setNetwork(network);
+ }
+
if (parser.hasNext()) {
position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
}
diff --git a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
index 3f8a4d0c2..a23b87fe5 100644
--- a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
@@ -11,6 +11,10 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest {
var decoder = inject(new Gl200TextProtocolDecoder(null));
+ verifyAttribute(decoder, buffer(
+ "+RESP:GTFRI,423037,866884047716519,GT501,0,1,1,5,12,0.1,0,46.8,-95.559173,30.109955,20231110185836,6,0e36c9916485,-50,,,,e831cd5eb79d,-73,,,,ccf4110c4bd5,-79,,,,acdb48973168,-79,,,,80ab4dc323c4,-82,,,,ec8eb5cfa1c6,-89,,,,310,10,711D,81ECF0F,00,,93,20231110185839,0005$"),
+ Position.KEY_BATTERY_LEVEL, 93);
+
verifyNull(decoder, buffer(
"+RESP:GTFRI,8020040200,866314060109269,,,10,1,1,0.0,0,9.0,-71.596601,-33.524595,20230722145338,0730,0001,772A,052B253E,00,0.0,,,,,100,210100,,,,20230722145341,0F4C$"));