aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java52
-rw-r--r--test/org/traccar/protocol/Gl200ProtocolDecoderTest.java12
2 files changed, 52 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index b55f4e606..7cbd76007 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -23,6 +23,7 @@ import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.helper.PatternUtil;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -50,23 +51,35 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
.text("+RESP:GTINF,")
.number("[0-9A-Z]{2}xxxx,") // protocol version
.number("(d{15}),") // imei
- .expression("[0-9A-Z]{17},") // vin
- .expression("[^,]{0,20},") // device name
+ .expression("(?:[0-9A-Z]{17},)?") // vin
+ .expression("(?:[^,]+)?,") // device name
.number("(xx),") // state
.expression("[0-9F]{20},") // iccid
.number("d{1,2},")
.number("d{1,2},")
- .expression("[01],")
- .number("(d{1,5}),") // power
- .text(",")
+ .expression("[01],") // external power
+ .number("([d.]+)?,") // odometer or external power
+ .number("[01]?,") // backup battery
.number("(d+.d+),") // battery
.expression("([01]),") // charging
- .expression("[01],")
- .text(",,")
+ .number("(?:d),") // led
+ .number("(?:d)?,") // gps on need
+ .number("(?:d)?,") // gps antenna type
+ .number("(?:d),").optional() // gps antenna state
.number("d{14},") // last fix time
- .text(",,,,,")
+ .groupBegin()
+ .number("(d+),") // battery percentage
+ .expression("(?:[01]),") // flash type
+ .number("(-?[d.]+)?,,,") // temperature
+ .or()
+ .expression("(?:[01])?,").optional() // pin15 mode
+ .number("(d+)?,") // adc1
+ .number("(d+)?,").optional() // adc2
+ .number("(xx)?,") // digital input
+ .number("(xx)?,") // digital output
.number("[-+]dddd,") // timezone
.expression("[01],") // daylight saving
+ .groupEnd()
.number("(dddd)(dd)(dd)") // date
.number("(dd)(dd)(dd),") // time
.number("(xxxx)") // counter
@@ -256,6 +269,9 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
private Object decodeInf(Channel channel, SocketAddress remoteAddress, String sentence) {
+
+ PatternUtil.MatchResult r = PatternUtil.checkPattern(PATTERN_INF.pattern(), sentence);
+
Parser parser = new Parser(PATTERN_INF, sentence);
if (!parser.matches()) {
return null;
@@ -271,9 +287,21 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
position.set(Position.KEY_STATUS, parser.next());
- position.set(Position.KEY_POWER, parser.next());
- position.set(Position.KEY_BATTERY, parser.next());
- position.set(Position.KEY_CHARGE, parser.next());
+
+ parser.next(); // odometer or external power
+
+ position.set(Position.KEY_BATTERY, parser.nextDouble());
+ position.set(Position.KEY_CHARGE, parser.nextInt() == 1);
+
+ parser.next(); // battery percentage
+
+ position.set(Position.PREFIX_TEMP + 1, parser.next());
+
+ position.set(Position.PREFIX_ADC + 1, parser.next());
+ position.set(Position.PREFIX_ADC + 2, parser.next());
+
+ position.set(Position.KEY_INPUT, parser.next());
+ position.set(Position.KEY_OUTPUT, parser.next());
DateBuilder dateBuilder = new DateBuilder()
.setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
@@ -281,7 +309,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, dateBuilder.getDate());
- position.set(Position.KEY_INDEX, parser.next());
+ position.set(Position.KEY_INDEX, parser.nextInt(16));
return position;
}
diff --git a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
index b59782ac5..68c4b66a0 100644
--- a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
@@ -10,6 +10,18 @@ public class Gl200ProtocolDecoderTest extends ProtocolTest {
Gl200ProtocolDecoder decoder = new Gl200ProtocolDecoder(new Gl200Protocol());
+ verifyAttributes(decoder, text(
+ "+RESP:GTINF,080100,135790246811220,,16,898600810906F8048812,16,0,1,11870,,4.1,0,0,0,,20090214013254,,12340,,00,00,+0800,0,20090214093254,11F0$"));
+
+ verifyAttributes(decoder, text(
+ "+RESP:GTINF,040100,135790246811220,,16,898600810906F8048812,16,0,1,,0,4.4,0,0,0,0,20090214013254,13000,00,00,+0800,0,20090214093254,11F0$"));
+
+ verifyAttributes(decoder, text(
+ "+RESP:GTINF,060100,135790246811220,,16,898600810906F8048812,16,0,1,12000,,4.4,0,0,0,0,20090214013254,0,1300,2000,00,00,+0800,0,20090214093254,11F0$"));
+
+ 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$"));
+
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$"));