aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-10-18 15:19:53 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-10-18 15:19:53 -0700
commit01429a90583b221a84e5d40a9acc654377b41f52 (patch)
tree9611c9942e873c223eb66bc10925a9f0913fd492 /src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
parent9e25f74ac2ad8193cc45236403cceea5becb37ff (diff)
downloadtrackermap-server-01429a90583b221a84e5d40a9acc654377b41f52.tar.gz
trackermap-server-01429a90583b221a84e5d40a9acc654377b41f52.tar.bz2
trackermap-server-01429a90583b221a84e5d40a9acc654377b41f52.zip
Support custom protocol
Diffstat (limited to 'src/main/java/org/traccar/protocol/T55ProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/T55ProtocolDecoder.java48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java b/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
index b75addfae..230d29216 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 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2020 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.
@@ -24,6 +24,7 @@ import org.traccar.Protocol;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -109,6 +110,20 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private static final Pattern PATTERN_QZE = new PatternBuilder()
+ .text("QZE,")
+ .number("(d{15}),") // imei
+ .number("(d+),") // event
+ .number("(dd)(dd)(dddd),") // date (mmddyyyy)
+ .number("(dd)(dd)(dd),") // time (hhmmss)
+ .number("(-?d+.d+),") // latitude
+ .number("(-?d+.d+),") // longitude
+ .number("(d+),") // speed
+ .number("(d+),") // course
+ .expression("([AV]),") // validity
+ .expression("([01])") // ignition
+ .compile();
+
private Position position = null;
private Position decodeGprmc(
@@ -256,6 +271,35 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private Position decodeQze(Channel channel, SocketAddress remoteAddress, String sentence) {
+
+ Parser parser = new Parser(PATTERN_QZE, 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());
+
+ position.set(Position.KEY_EVENT, parser.nextInt());
+
+ position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
+ position.setLatitude(parser.nextDouble());
+ position.setLongitude(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt()));
+ position.setCourse(parser.nextInt());
+ position.setValid(parser.next().equals("A"));
+
+ position.set(Position.KEY_IGNITION, parser.nextInt() > 0);
+
+ return position;
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -308,6 +352,8 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
return decodeTrccr(deviceSession, sentence);
} else if (sentence.startsWith("$GPIOP")) {
return decodeGpiop(deviceSession, sentence);
+ } else if (sentence.startsWith("QZE")) {
+ return decodeQze(channel, remoteAddress, sentence);
}
return null;