From 36733f47365f97bc912d1179004e33e0ef9ee281 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 20 Mar 2016 15:25:14 +1300 Subject: Support GL200 protocol motion report --- src/org/traccar/protocol/Gl200ProtocolDecoder.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/org/traccar/protocol/Gl200ProtocolDecoder.java') 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; } -- cgit v1.2.3