aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-12-14 22:48:13 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2018-12-14 22:48:13 -0800
commitcec63a8b62f20c1b23d92664676409510226a9e2 (patch)
tree38387396cf6788b6275db9b24b3bbe85bb19e714 /src/org/traccar
parent9c4dcf3c38aa1a40025df55c344cb2311e0784a5 (diff)
downloadtrackermap-server-cec63a8b62f20c1b23d92664676409510226a9e2.tar.gz
trackermap-server-cec63a8b62f20c1b23d92664676409510226a9e2.tar.bz2
trackermap-server-cec63a8b62f20c1b23d92664676409510226a9e2.zip
Additional ArknavX8 attributes
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/ArknavX8ProtocolDecoder.java55
1 files changed, 53 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
index 62ad09a52..b570f5423 100644
--- a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
+++ b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
@@ -32,7 +32,7 @@ public class ArknavX8ProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private static final Pattern PATTERN = new PatternBuilder()
+ private static final Pattern PATTERN_1G = new PatternBuilder()
.expression("(..),") // type
.number("(dd)(dd)(dd)") // date (yymmdd)
.number("(dd)(dd)(dd),") // time (hhmmss)
@@ -45,6 +45,17 @@ public class ArknavX8ProtocolDecoder extends BaseProtocolDecoder {
.number("(d+)") // status
.compile();
+ private static final Pattern PATTERN_2G = new PatternBuilder()
+ .expression("..,") // type
+ .number("(dd)(dd)(dd)") // date (yymmdd)
+ .number("(dd)(dd)(dd),") // time (hhmmss)
+ .number("(d+),") // satellites
+ .number("(d+.d+),") // altitude
+ .number("(d+.d+),") // power
+ .number("(d+.d+),") // battery
+ .number("(d+.d+)") // odometer
+ .compile();
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -56,7 +67,21 @@ public class ArknavX8ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Parser parser = new Parser(PATTERN, sentence);
+ switch (sentence.substring(0, 2)) {
+ case "1G":
+ case "1R":
+ case "1M":
+ return decode1G(channel, remoteAddress, sentence);
+ case "2G":
+ return decode2G(channel, remoteAddress, sentence);
+ default:
+ return null;
+ }
+ }
+
+ private Position decode1G(Channel channel, SocketAddress remoteAddress, String sentence) {
+
+ Parser parser = new Parser(PATTERN_1G, sentence);
if (!parser.matches()) {
return null;
}
@@ -85,4 +110,30 @@ public class ArknavX8ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private Position decode2G(Channel channel, SocketAddress remoteAddress, String sentence) {
+
+ Parser parser = new Parser(PATTERN_2G, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
+ if (deviceSession == null) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, parser.nextDateTime());
+
+ position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.setAltitude(parser.nextDouble());
+ position.set(Position.KEY_POWER, parser.nextDouble());
+ position.set(Position.KEY_BATTERY, parser.nextDouble());
+ position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1852 / 3600);
+
+ return position;
+ }
+
}