aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/model/Event.java3
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java16
2 files changed, 13 insertions, 6 deletions
diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java
index d0e340973..13368ef5b 100644
--- a/src/org/traccar/model/Event.java
+++ b/src/org/traccar/model/Event.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,6 +53,7 @@ public abstract class Event extends Extensible {
public static final String KEY_VIN = "vin";
public static final String KEY_APPROXIMATE = "approximate";
public static final String KEY_THROTTLE = "throttle";
+ public static final String KEY_MOTION = "motion";
public static final String KEY_OBD_SPEED = "obd-speed";
public static final String KEY_OBD_ODOMETER = "obd-odometer";
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 4b9f6837a..28b1005df 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -195,10 +195,10 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN = new PatternBuilder()
.text("+").expression("(?:RESP|BUFF):GT...,")
.number("(?:[0-9A-Z]{2}xxxx)?,") // protocol version
- .number("(d{15}),") // imei
+ .number("(d{15}|x{14}),") // imei
.expression("[^,]*,") // device name
.number("d*,")
- .number("d{1,2},") // report type
+ .number("(d{1,2}),") // report type
.number("d{1,2},") // count
.expression(PATTERN_LOCATION.pattern())
.groupBegin()
@@ -476,7 +476,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private Object decodeOther(Channel channel, SocketAddress remoteAddress, String sentence) {
+ private Object decodeOther(Channel channel, SocketAddress remoteAddress, String sentence, String type) {
Parser parser = new Parser(PATTERN, sentence);
if (!parser.matches()) {
return null;
@@ -490,6 +490,11 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(getDeviceId());
+ int reportType = parser.nextInt();
+ if (type.equals("NMR")) {
+ position.set(Event.KEY_MOTION, reportType);
+ }
+
decodeLocation(position, parser);
position.set(Event.KEY_ODOMETER, parser.next());
@@ -565,7 +570,8 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
Object result;
- switch (sentence.substring(typeIndex + 3, typeIndex + 6)) {
+ String type = sentence.substring(typeIndex + 3, typeIndex + 6);
+ switch (type) {
case "HBD":
result = decodeHbd(channel, remoteAddress, sentence);
break;
@@ -586,7 +592,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
result = decodeIda(channel, remoteAddress, sentence);
break;
default:
- result = decodeOther(channel, remoteAddress, sentence);
+ result = decodeOther(channel, remoteAddress, sentence, type);
break;
}