From 464348b91591a684bc16cf3c207f38ca3f923daa Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 26 Oct 2018 07:19:42 +0400 Subject: Support MiniFinder command result --- src/org/traccar/protocol/MiniFinderProtocolDecoder.java | 12 ++++++++++-- test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java index 9ea8de0bf..2b7a960c4 100644 --- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java +++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java @@ -143,7 +143,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { } DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); - if (deviceSession == null || !sentence.matches("![A-D],.*")) { + if (deviceSession == null || !sentence.matches("![3A-D],.*")) { return null; } @@ -153,7 +153,15 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { String type = sentence.substring(1, 2); position.set(Position.KEY_TYPE, type); - if (type.equals("B") || type.equals("D")) { + if (type.equals("3")) { + + getLastLocation(position, null); + + position.set(Position.KEY_RESULT, sentence.substring(3)); + + return position; + + } else if (type.equals("B") || type.equals("D")) { Parser parser = new Parser(PATTERN_BD, sentence); if (!parser.matches()) { diff --git a/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java b/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java index e1f957c8a..afa930e5b 100644 --- a/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java @@ -13,6 +13,9 @@ public class MiniFinderProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, text( "!1,867273023933661,V07S.5701.1621,100")); + verifyAttributes(decoder, text( + "!3,ok")); + verifyNull(decoder, text( "!1,123456789012345")); -- cgit v1.2.3