From 664cc129f1a5ad13fab966d3c293e7aa6ce12ab6 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 5 Oct 2016 14:20:59 +0500 Subject: - Remove hardcoded password from commands - Authenticate device on heardbeat stage --- src/org/traccar/protocol/Gl200ProtocolDecoder.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/protocol/Gl200ProtocolDecoder.java') diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 385039399..362e3fb38 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -39,7 +39,8 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN_HBD = new PatternBuilder() .text("+ACK:GTHBD,") - .number("([0-9A-Z]{2}xxxx),") + .number("([0-9A-Z]{2}xxxx),") // protocol version + .number("(d{15}),") // imei .any().text(",") .number("(xxxx)") .text("$").optional() @@ -245,7 +246,11 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { private Object decodeHbd(Channel channel, SocketAddress remoteAddress, String sentence) { Parser parser = new Parser(PATTERN_HBD, sentence); if (parser.matches() && channel != null) { - channel.write("+SACK:GTHBD," + parser.next() + "," + parser.next() + "$", remoteAddress); + String protocolVersion = parser.next(); + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + if (deviceSession != null) { + channel.write("+SACK:GTHBD," + protocolVersion + "," + parser.next() + "$", remoteAddress); + } } return null; } -- cgit v1.2.3