aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/model/Position.java2
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java66
-rw-r--r--test/org/traccar/protocol/Gl200ProtocolDecoderTest.java18
3 files changed, 83 insertions, 3 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 3a7070083..abe8dd813 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -93,6 +93,8 @@ public class Position extends Message {
public static final String ALARM_BREAKING = "hardBreaking";
public static final String ALARM_FATIGUE_DRIVING = "fatigueDriving";
public static final String ALARM_POWER_CUT = "powerCut";
+ public static final String ALARM_JAMMING = "jamming";
+ public static final String ALARM_TEMPERATURE = "temperature";
private String protocol;
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 2d28ea199..973907235 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -50,7 +50,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
.compile();
private static final Pattern PATTERN_INF = new PatternBuilder()
- .text("+RESP:GTINF,")
+ .text("+").expression("(?:RESP|BUFF):GTINF,")
.number("[0-9A-Z]{2}xxxx,") // protocol version
.number("(d{15}),") // imei
.expression("(?:[0-9A-Z]{17},)?") // vin
@@ -88,6 +88,20 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
.text("$").optional()
.compile();
+ private static final Pattern PATTERN_VER = new PatternBuilder()
+ .text("+").expression("(?:RESP|BUFF):GTVER,")
+ .number("[0-9A-Z]{2}xxxx,") // protocol version
+ .number("(d{15}),") // imei
+ .expression("[^,]*,") // device name
+ .expression("([^,]*),") // device type
+ .number("(xxxx),") // firmware version
+ .number("(xxxx),") // hardware version
+ .number("(dddd)(dd)(dd)") // date
+ .number("(dd)(dd)(dd),") // time
+ .number("(xxxx)") // counter
+ .text("$").optional()
+ .compile();
+
private static final Pattern PATTERN_LOCATION = new PatternBuilder()
.number("(?:d{1,2})?,") // gps accuracy
.number("(d{1,3}.d)?,") // speed
@@ -331,6 +345,34 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private Object decodeVer(Channel channel, SocketAddress remoteAddress, String sentence) {
+ Parser parser = new Parser(PATTERN_VER, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
+
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
+ if (deviceSession == null) {
+ return null;
+ }
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ position.set("deviceType", parser.next());
+ position.set("firmwareVersion", parser.nextInt(16));
+ position.set("hardwareVersion", parser.nextInt(16));
+
+ DateBuilder dateBuilder = new DateBuilder()
+ .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
+ .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+
+ getLastLocation(position, dateBuilder.getDate());
+
+ return position;
+ }
+
private void decodeLocation(Position position, Parser parser) {
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
position.setCourse(parser.nextDouble());
@@ -587,7 +629,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private Object decodeBasic(Channel channel, SocketAddress remoteAddress, String sentence) {
+ private Object decodeBasic(Channel channel, SocketAddress remoteAddress, String sentence, String type) {
Parser parser = new Parser(PATTERN_BASIC, sentence);
if (!parser.matches()) {
return null;
@@ -624,6 +666,21 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
}
+ switch (type) {
+ case "BPL":
+ position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
+ break;
+ case "TEM":
+ position.set(Position.KEY_ALARM, Position.ALARM_TEMPERATURE);
+ break;
+ case "JDR":
+ case "JDS":
+ position.set(Position.KEY_ALARM, Position.ALARM_JAMMING);
+ break;
+ default:
+ break;
+ }
+
return position;
}
@@ -660,13 +717,16 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
case "IDA":
result = decodeIda(channel, remoteAddress, sentence);
break;
+ case "VER":
+ result = decodeVer(channel, remoteAddress, sentence);
+ break;
default:
result = decodeOther(channel, remoteAddress, sentence, type);
break;
}
if (result == null) {
- result = decodeBasic(channel, remoteAddress, sentence);
+ result = decodeBasic(channel, remoteAddress, sentence, type);
}
if (result != null) {
diff --git a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
index 914db782e..83f8b02f1 100644
--- a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
@@ -22,6 +22,9 @@ public class Gl200ProtocolDecoderTest extends ProtocolTest {
verifyAttributes(decoder, text(
"+RESP:GTINF,1A0800,860599000773978,GL300,41,89701016426133851978,17,0,1,26.6,,3.90,1,1,0,0,0,20161003184043,69,1,44,,,20161004040811,022C$"));
+ verifyAttributes(decoder, text(
+ "+BUFF:GTINF,1A0800,860599000773978,GL300,41,89701016426133851978,23,0,1,204.7,,3.84,1,1,0,0,0,20161006072548,62,1,38,,,20161006082343,0C98$"));
+
verifyPosition(decoder, text(
"+RESP:GTFRI,360100,864251020141408,3VWGW6AJ0FM237324,gv500,,10,1,1,0.0,0,2258.4,-99.256948,19.555800,20160929214743,0334,0020,0084,65AC,00,0.0,,,,100,410000,0,nan,,20160929214743,13BA$"));
@@ -159,6 +162,21 @@ public class Gl200ProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, text(
"+RESP:GTRTL,280100,A1000043D20139,,0,0,1,1,0.1,321,239.1,-76.661047,39.832501,20150615114455,0310,0484,00600019,0A52,,87,20150615074456,031E$"));
+
+ verifyAttributes(decoder, text(
+ "+BUFF:GTBPL,1A0800,860599000773978,GL300,3.55,0,0.0,0,257.1,60.565437,56.818277,20161006070553,,,,,204.7,20161006071028,0C75$"));
+
+ verifyAttributes(decoder, text(
+ "+RESP:GTTEM,1A0102,860599000000448,,3,33,0,5.8,0,33.4,117.201191,31.832502,20130109061410,0460,0000,5678,2079,,20130109061517,0091$"));
+
+ verifyAttributes(decoder, text(
+ "+RESP:GTJDR,0A0102,135790246811220,,0,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,20090214093254,11F0$"));
+
+ verifyAttributes(decoder, text(
+ "+RESP:GTJDS,0A0102,135790246811220,,2,0,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,20090214093254,11F0$"));
+
+ verifyAttributes(decoder, text(
+ "+RESP:GTVER,1A0800,860599000773978,GL300,GL300,0A03,0103,20161007041531,10F8$"));
verifyNothing(decoder, text(
"+ACK:GTHBD,1A0401,135790246811220,,20100214093254,11F0"));