diff options
Diffstat (limited to 'src/org/traccar/protocol/UproProtocolDecoder.java')
-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) { |