From 5741cd0fdbddb623f1807463d9a8d26cf5cc8f4d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 24 Feb 2016 00:22:20 +1300 Subject: Finish new GL200 decoder implementation --- src/org/traccar/protocol/Gl200ProtocolDecoder.java | 33 +++++++++++++++++----- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index c6881d035..9098cbd8c 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -82,10 +82,17 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { .number("(dddd)(dd)(dd)") // date .number("(dd)(dd)(dd)").optional(2) // time .text(",") + .groupBegin() .number("(0ddd)?,") // mcc .number("(0ddd)?,") // mnc .number("(xxxx)?,") // lac .number("(xxxx)?,") // cell + .or() + .number("(d+)?,") // mcc + .number("(d+)?,") // mnc + .number("(d+)?,") // lac + .number("(d+)?,") // cell + .groupEnd() .number("d*,") // reserved .compile(); @@ -126,14 +133,14 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN_FRI = new PatternBuilder() .text("+RESP:GTFRI,") .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*,") .number("d{1,2},") // report type .number("d{1,2},") // count - .expression("(") + .expression("((?:") .expression(PATTERN_LOCATION.pattern()) - .expression(")+") + .expression(")+)") .groupBegin() .number("(d{1,3})?,") // battery .or() @@ -157,7 +164,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { .number("(?:[0-9A-Z]{2}xxxx)?,") // protocol version .number("(d{15}),") // imei .expression("[^,]*,") // device name - .number("d?,") + .number("d*,") .number("d{1,2},") // report type .number("d{1,2},") // count .expression(PATTERN_LOCATION.pattern()) @@ -254,6 +261,8 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set(Event.KEY_LAC, parser.nextInt(16)); position.set(Event.KEY_CID, parser.nextInt(16)); } + + parser.skip(4); // alternative networks } private Object decodeObd(Channel channel, SocketAddress remoteAddress, String sentence) { @@ -304,7 +313,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { return null; } - List positions = new LinkedList<>(); + LinkedList positions = new LinkedList<>(); if (!identify(parser.next(), channel, remoteAddress)) { return null; @@ -321,7 +330,17 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { positions.add(position); } - parser.skip(15); + Position position = positions.getLast(); + + decodeLocation(position, parser); + + position.set(Event.KEY_BATTERY, parser.next()); + + position.set(Event.KEY_ODOMETER, parser.next()); + position.set(Event.PREFIX_ADC + 1, parser.next()); + position.set(Event.PREFIX_ADC + 2, parser.next()); + position.set(Event.KEY_BATTERY, parser.next()); + position.set(Event.KEY_STATUS, parser.next()); return positions; } -- cgit v1.2.3