diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-03-20 15:25:14 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-03-20 15:25:14 +1300 |
commit | 36733f47365f97bc912d1179004e33e0ef9ee281 (patch) | |
tree | f2ad701c011ddf86991e9ec26aeed154782a69e4 /src/org/traccar/protocol | |
parent | 919dadbd4d808ea32f53b139c3d22f902f3d1e21 (diff) | |
download | traccar-server-36733f47365f97bc912d1179004e33e0ef9ee281.tar.gz traccar-server-36733f47365f97bc912d1179004e33e0ef9ee281.tar.bz2 traccar-server-36733f47365f97bc912d1179004e33e0ef9ee281.zip |
Support GL200 protocol motion report
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/Gl200ProtocolDecoder.java | 16 |
1 files changed, 11 insertions, 5 deletions
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; } |