aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/T55ProtocolDecoder.java61
-rw-r--r--src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java3
2 files changed, 63 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java b/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
index 409c7e768..1529aae29 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 - 2020 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.
@@ -125,6 +125,30 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
.expression("([01])") // ignition
.compile();
+ private static final Pattern PATTERN_PUBX = new PatternBuilder()
+ .text("$PUBX,")
+ .number("(d+),") // index
+ .number("(dd)(dd)(dd).d+,") // time (hhmmss)
+ .number("(dd)(dd.d+),([NS]),") // latitude
+ .number("(ddd)(dd.d+),([EW]),") // longitude
+ .number("(-?d+.d+),") // altitude
+ .expression("(..),") // status
+ .number("(d+.d+),") // horizontal accuracy
+ .number("d+.d+,") // vertical accuracy
+ .number("(d+.d+),") // speed
+ .number("(d+.d+),") // course
+ .number("-?d+.d+,") // vertical velocity
+ .expression("[^,]*,") // corrections age
+ .number("(d+.d+),") // hdop
+ .number("(d+.d+),") // vdop
+ .number("d+.d+,") // tdop
+ .number("(d+),") // satellites
+ .number("(d+),") // device id
+ .number("d+")
+ .text("*")
+ .number("xx") // checksum
+ .compile();
+
private Position position = null;
private Position decodeGprmc(
@@ -303,6 +327,39 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private Position decodePubx(Channel channel, SocketAddress remoteAddress, String sentence) {
+
+ Parser parser = new Parser(PATTERN_PUBX, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+
+ position.set(Position.KEY_INDEX, parser.nextInt());
+
+ position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS));
+ position.setLatitude(parser.nextCoordinate());
+ position.setLongitude(parser.nextCoordinate());
+ position.setAltitude(parser.nextDouble());
+ position.setValid(!parser.next().equals("NF"));
+ position.setAccuracy(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ position.setCourse(parser.nextDouble());
+
+ position.set(Position.KEY_HDOP, parser.nextDouble());
+ position.set(Position.KEY_VDOP, parser.nextDouble());
+ position.set(Position.KEY_SATELLITES, parser.nextInt());
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
+ if (deviceSession != null) {
+ position.setDeviceId(deviceSession.getDeviceId());
+ return position;
+ }
+
+ return null;
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -357,6 +414,8 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
return decodeGpiop(deviceSession, sentence);
} else if (sentence.startsWith("QZE")) {
return decodeQze(channel, remoteAddress, sentence);
+ } else if (sentence.startsWith("$PUBX")) {
+ return decodePubx(channel, remoteAddress, sentence);
}
return null;
diff --git a/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java
index 6ce47db94..1622f64f2 100644
--- a/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java
@@ -12,6 +12,9 @@ public class T55ProtocolDecoderTest extends ProtocolTest {
var decoder = inject(new T55ProtocolDecoder(null));
verifyPosition(decoder, text(
+ "$PUBX,00,130209.00,3650.51159,N,01346.10602,E,785.947,D3,4.1,5.2,0.163,87.43,-0.054,7.0,0.88,1.21,0.88,24,01012,0*6D"));
+
+ verifyPosition(decoder, text(
"QZE,868994033976700,35,28062020,113553,22.13673,114.57263,0,22,A,0"));
verifyNull(decoder, text(