diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-09-28 14:15:23 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-09-28 14:15:23 -0700 |
commit | 95d9122a4f5ac22ea25d2eb555beab11fd2c3408 (patch) | |
tree | 312bb2c82988f529e4680859c66900e70a8c18c4 /src/main/java/org/traccar/protocol | |
parent | fa99ec021a056dfb953b29a23e8b02c13fa1267e (diff) | |
download | traccar-server-95d9122a4f5ac22ea25d2eb555beab11fd2c3408.tar.gz traccar-server-95d9122a4f5ac22ea25d2eb555beab11fd2c3408.tar.bz2 traccar-server-95d9122a4f5ac22ea25d2eb555beab11fd2c3408.zip |
Implement ACK message
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r-- | src/main/java/org/traccar/protocol/RstProtocolDecoder.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/RstProtocolDecoder.java b/src/main/java/org/traccar/protocol/RstProtocolDecoder.java index 7b6d2f042..071200d6d 100644 --- a/src/main/java/org/traccar/protocol/RstProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RstProtocolDecoder.java @@ -18,6 +18,7 @@ package org.traccar.protocol; import io.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; +import org.traccar.NetworkMessage; import org.traccar.Protocol; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; @@ -35,12 +36,12 @@ public class RstProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN = new PatternBuilder() .text("RST;") - .expression("[AL];") - .expression("[^,]+;") // model - .expression(".{5};") // firmware + .expression("([AL]);") // archive + .expression("([^,]+);") // model + .expression("(.{5});") // firmware .number("(d{9});") // serial number - .number("d+;") // index - .number("d+;") // type + .number("(d+);") // index + .number("(d+);") // type .number("(dd)-(dd)-(dddd) ") // event date .number("(dd):(dd):(dd);") // event time .number("(dd)-(dd)-(dddd) ") // fix date @@ -78,7 +79,19 @@ public class RstProtocolDecoder extends BaseProtocolDecoder { return null; } - DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + String archive = parser.next(); + String model = parser.next(); + String firmware = parser.next(); + String serial = parser.next(); + int index = parser.nextInt(); + int type = parser.nextInt(); + + if (channel != null && archive.equals("A")) { + String response = "RST;A;" + model + ";" + firmware + ";" + serial + ";" + index + ";" + type + ";FIM;"; + channel.writeAndFlush(new NetworkMessage(response, remoteAddress)); + } + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, serial); if (deviceSession == null) { return null; } |