From a99aeb0236cc2cf44e31e9adeb6fbb827c30b1ad Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 15 Nov 2016 22:59:50 +1300 Subject: Implement upro protocol response --- src/org/traccar/protocol/UproProtocolDecoder.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/protocol') 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) { -- cgit v1.2.3