aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-03-20 15:25:14 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-03-20 15:25:14 +1300
commit36733f47365f97bc912d1179004e33e0ef9ee281 (patch)
treef2ad701c011ddf86991e9ec26aeed154782a69e4
parent919dadbd4d808ea32f53b139c3d22f902f3d1e21 (diff)
downloadtraccar-server-36733f47365f97bc912d1179004e33e0ef9ee281.tar.gz
traccar-server-36733f47365f97bc912d1179004e33e0ef9ee281.tar.bz2
traccar-server-36733f47365f97bc912d1179004e33e0ef9ee281.zip
Support GL200 protocol motion report
-rw-r--r--src/org/traccar/model/Event.java3
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java16
-rw-r--r--test/org/traccar/protocol/Gl200ProtocolDecoderTest.java3
3 files changed, 16 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;
}
diff --git a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
index 13064bd0d..6e6049f4b 100644
--- a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class Gl200ProtocolDecoderTest extends ProtocolTest {
Gl200ProtocolDecoder decoder = new Gl200ProtocolDecoder(new Gl200Protocol());
verifyPosition(decoder, text(
+ "+RESP:GTNMR,210102,A10000458356CE,,0,1,1,9,0.0,8,190.7,-85.765865,42.894837,20160316123202,,,,,60,30,20160316123202,0137$"));
+
+ verifyPosition(decoder, text(
"+RESP:GTIDA,060228,862894020178276,,,01C68011010000C7,1,1,0,0.0,0,413.0,-63.169675,-17.776349,20160317222129,0736,0003,6AD4,32CF,00,34.9,,,,,20160317182130,1626$"));
verifyPosition(decoder, text(