From 4216e038468184a58e9fa10cb9eaff28450de743 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 25 Oct 2016 04:05:22 +1300 Subject: Fix U-pro decoder patter --- src/org/traccar/protocol/UproProtocolDecoder.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/UproProtocolDecoder.java b/src/org/traccar/protocol/UproProtocolDecoder.java index b4000c37a..e6cb4e132 100644 --- a/src/org/traccar/protocol/UproProtocolDecoder.java +++ b/src/org/traccar/protocol/UproProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.traccar.DeviceSession; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; +import org.traccar.helper.PatternUtil; import org.traccar.model.Position; import java.net.SocketAddress; @@ -34,8 +35,9 @@ public class UproProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN = new PatternBuilder() .text("*AI20") + .expression("[01]") // ack .number("(d+),") // device id - .expression("A.+&A") + .expression(".+&A") .number("(dd)(dd)(dd)") // time .number("(dd)(dd)(dddd)") // latitude .number("(ddd)(dd)(dddd)") // longitude @@ -49,6 +51,8 @@ public class UproProtocolDecoder extends BaseProtocolDecoder { protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { + PatternUtil.MatchResult r = PatternUtil.checkPattern(PATTERN.pattern(), (String) msg); + Parser parser = new Parser(PATTERN, (String) msg); if (!parser.matches()) { return null; -- cgit v1.2.3