aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2024-06-10 21:04:24 -0700
committerGitHub <noreply@github.com>2024-06-10 21:04:24 -0700
commit0bb9e28cf771a60db06a33b4967a2049bea72af5 (patch)
tree696f098730209799de5e6582884fb51e2c806e00 /src/main
parente92dea78ebad3f921c031a974378a218c6bd90b1 (diff)
parent7e80c11158a046045484affe9406adfde7219697 (diff)
downloadtrackermap-server-0bb9e28cf771a60db06a33b4967a2049bea72af5.tar.gz
trackermap-server-0bb9e28cf771a60db06a33b4967a2049bea72af5.tar.bz2
trackermap-server-0bb9e28cf771a60db06a33b4967a2049bea72af5.zip
Merge pull request #5339 from jcardus/patch-1
Ignition messages not correctly decoded
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
index 8edce9346..cfed351f2 100644
--- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -1033,36 +1033,34 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
return positions;
}
- private static final Pattern PATTERN_IGN = new PatternBuilder()
- .text("+").expression("(?:RESP|BUFF):GT[IV]G[NF],")
- .expression("(?:.{6}|.{10})?,") // protocol version
- .number("(d{15}|x{14}),") // imei
- .expression("[^,]*,") // device name
- .number("d+,") // ignition off duration
- .expression(PATTERN_LOCATION.pattern())
- .number("(d{5}:dd:dd)?,") // hour meter
- .number("(d{1,7}.d)?,") // odometer
- .number("(dddd)(dd)(dd)") // date (yyyymmdd)
- .number("(dd)(dd)(dd)").optional(2) // time (hhmmss)
- .text(",")
- .number("(xxxx)") // count number
- .text("$").optional()
- .compile();
-
- private Object decodeIgn(Channel channel, SocketAddress remoteAddress, String sentence) {
- Parser parser = new Parser(PATTERN_IGN, sentence);
- Position position = initPosition(parser, channel, remoteAddress);
- if (position == null) {
+ private Object decodeIgn(
+ Channel channel, SocketAddress remoteAddress, String[] v, String type) throws ParseException {
+ int index = 0;
+ index += 1; // header
+ String protocolVersion = v[index++]; // protocol version
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, v[index++]);
+ if (deviceSession == null) {
return null;
}
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
- decodeLocation(position, parser);
+ String model = getDeviceModel(deviceSession, protocolVersion);
+ index += 1; // device name
+ index += 1; // duration of ignition on/off
- position.set(Position.KEY_IGNITION, sentence.contains("GN"));
- position.set(Position.KEY_HOURS, parseHours(parser.next()));
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ decodeLocation(position, model, v, index);
- decodeDeviceTime(position, parser);
+ position.set(Position.KEY_IGNITION, type.contains("GN"));
+ position.set(Position.KEY_HOURS, parseHours(v[index++]));
+ position.set(Position.KEY_ODOMETER, Double.parseDouble(v[index]) * 1000);
+
+ Date time = dateFormat.parse(v[v.length - 2]);
+ if (ignoreFixTime) {
+ position.setTime(time);
+ } else {
+ position.setDeviceTime(time);
+ }
return position;
}
@@ -1682,7 +1680,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
case "IGF":
case "VGN":
case "VGF":
- result = decodeIgn(channel, remoteAddress, sentence);
+ result = decodeIgn(channel, remoteAddress, values, type);
break;
case "LSW":
case "TSW":