aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-02-23 16:30:21 -0800
committerAnton Tananaev <anton@traccar.org>2023-02-23 16:30:21 -0800
commit9aef1bfcffa0750ba0771dd1af2ffe8667547b3a (patch)
tree33289597348cc7232d80ffc823fbe153347d42e2 /src/main/java/org/traccar
parent2ac77554f7771a014d62a6e5eeb381b4650dc4f4 (diff)
downloadtrackermap-server-9aef1bfcffa0750ba0771dd1af2ffe8667547b3a.tar.gz
trackermap-server-9aef1bfcffa0750ba0771dd1af2ffe8667547b3a.tar.bz2
trackermap-server-9aef1bfcffa0750ba0771dd1af2ffe8667547b3a.zip
Support GPTXT format
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/protocol/T55ProtocolDecoder.java40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java b/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
index 3be161fb8..4db76f601 100644
--- a/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2023 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.
@@ -150,6 +150,18 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
.number("xx") // checksum
.compile();
+ private static final Pattern PATTERN_GPTXT = new PatternBuilder()
+ .text("$GPTXT,")
+ .text("NET,")
+ .number("(d+),") // device id
+ .expression("([^,]+),") // network operator
+ .number("(-d+),") // rssi
+ .number("(d+) ") // mcc
+ .number("(d+)") // mnc
+ .text("*")
+ .number("xx") // checksum
+ .compile();
+
private Position position = null;
private Position decodeGprmc(
@@ -328,6 +340,30 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private Position decodeGptxt(Channel channel, SocketAddress remoteAddress, String sentence) {
+
+ Parser parser = new Parser(PATTERN_GPTXT, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
+ if (deviceSession == null) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+
+ getLastLocation(position, null);
+
+ position.set(Position.KEY_OPERATOR, parser.next());
+ position.set(Position.KEY_RSSI, parser.nextInt());
+ position.set("mcc", parser.nextInt());
+ position.set("mnc", parser.nextInt());
+
+ return position;
+ }
+
private Position decodePubx(Channel channel, SocketAddress remoteAddress, String sentence) {
Parser parser = new Parser(PATTERN_PUBX, sentence);
@@ -421,6 +457,8 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
return decodeQze(channel, remoteAddress, sentence);
} else if (sentence.startsWith("$PUBX")) {
return decodePubx(channel, remoteAddress, sentence);
+ } else if (sentence.startsWith("$GPTXT")) {
+ return decodeGptxt(channel, remoteAddress, sentence);
}
return null;