From 33773135d333605059f0cb78282edd3a9438440e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 29 Jun 2015 11:01:41 +1200 Subject: Improved gps103 protocol identification (fix #1272) --- src/org/traccar/protocol/Gps103ProtocolDecoder.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index 5dadd10e4..3f21beea8 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -59,6 +59,8 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { "([^,;]+)?,?" + ".*"); + private static final Pattern handshakePattern = Pattern.compile("##,imei:(\\d+),A"); + @Override protected Object decode( ChannelHandlerContext ctx, Channel channel, SocketAddress remoteAddress, Object msg) @@ -70,6 +72,10 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { if (sentence.contains("##")) { if (channel != null) { channel.write("LOAD", remoteAddress); + Matcher handshakeMatcher = handshakePattern.matcher(sentence); + if(handshakeMatcher.matches()) { + identify(handshakeMatcher.group(1), channel); + } } return null; } -- cgit v1.2.3