diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-15 22:59:50 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-15 22:59:50 +1300 |
commit | a99aeb0236cc2cf44e31e9adeb6fbb827c30b1ad (patch) | |
tree | 6d60ed1cbe1753a76976ee6ce1cdd8f4a434fe0a /src/org/traccar | |
parent | fcc70df74b1fb17280b837b2a31722c2f3fc8ad2 (diff) | |
download | traccar-server-a99aeb0236cc2cf44e31e9adeb6fbb827c30b1ad.tar.gz traccar-server-a99aeb0236cc2cf44e31e9adeb6fbb827c30b1ad.tar.bz2 traccar-server-a99aeb0236cc2cf44e31e9adeb6fbb827c30b1ad.zip |
Implement upro protocol response
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/UproProtocolDecoder.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/UproProtocolDecoder.java b/src/org/traccar/protocol/UproProtocolDecoder.java index 02a241ddd..d5a00c6df 100644 --- a/src/org/traccar/protocol/UproProtocolDecoder.java +++ b/src/org/traccar/protocol/UproProtocolDecoder.java @@ -36,10 +36,10 @@ public class UproProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN = new PatternBuilder() .text("*") .expression("..20") - .expression("[01]") // ack + .expression("([01])") // ack .number("(d+),") // device id - .expression(".") // type - .expression(".") // subtype + .expression("(.)") // type + .expression("(.)") // subtype .expression("(.*)") // content .expression("#?") // delimiter .compile(); @@ -93,6 +93,8 @@ public class UproProtocolDecoder extends BaseProtocolDecoder { return null; } + boolean reply = parser.next().equals("1"); + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); if (deviceSession == null) { return null; @@ -102,6 +104,13 @@ public class UproProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); + String type = parser.next(); + String subtype = parser.next(); + + if (reply && channel != null) { + channel.write("*MG20Y" + type + subtype + "#"); + } + String[] data = parser.next().split("&"); for (int i = 0; i < data.length; i++) { if (i != 0) { |