From 354bd0ee9074c6b6ba6f29eead1bd07f978d880f Mon Sep 17 00:00:00 2001 From: jon-stumpf Date: Thu, 16 Feb 2017 21:31:11 -0500 Subject: Implemented changes to pull request as recommended by Anton; --- .../protocol/MiniFinderProtocolDecoder.java | 27 +++++----------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java index 009b3cc9f..37acbfd2d 100644 --- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java +++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java @@ -34,24 +34,16 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - // The !A record is not in the documentation for MiniFinder or EV-07S. - // Eview, the manufacturer, indicated that resellers could implement new record types. - // Using the data in MiniFinderProtocolDecoderTest.java as a guide private static final Pattern PATTERN_A = new PatternBuilder() .expression("!A,") .number("(d+)/(d+)/(d+),") // date .number("(d+):(d+):(d+),") // time .number("(-?d+.d+),") // latitude .number("(-?d+.d+),") // longitude - .number("(d+.?d*),") // unknown - .number("(d+.?d*),") // unknown - .number("(d+.?d*)") // unknown + .any() .compile(); - // The !C record is not in the documentation for MiniFinder or EV-07S - // Eview, the manufacturer, indicated that resellers could implement new record types. - // Using the data in MiniFinderProtocolDecoderTest.java as a guide - private static final Pattern PATTERN_C = new PatternBuilder() + private static final Pattern PATTERN_C = new PatternBuilder() .expression("!C,") .number("(d+)/(d+)/(d+),") // date .number("(d+):(d+):(d+),") // time @@ -62,9 +54,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { .number("(x+),") // flags .number("(-?d+.d+),") // altitude (meters) .number("(d+),") // battery (percentage) - .number("(d+.?d*),") // unknown - .number("(d+.?d*),") // unknown - .number("(d+.?d*)") // unknown + .any() .compile(); // The !B (buffered data) records are the same as !D (live data) records. @@ -82,7 +72,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // battery (percentage) .number("(d+),") // satellites in use .number("(d+),") // satellites in view - .number("(d+.?d*)") // HDOP, confirmed with Eview manufacturer + .number("(d+.?d*)") // hdop .compile(); private void decodeFlags(Position position, int flags) { @@ -201,9 +191,6 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_BATTERY, parser.nextInt()); - // Ignoring last three fields, unknown - position.set("unknown", parser.next() + "," + parser.next() + "," + parser.next()); - position.set(Position.KEY_TYPE, sentence.substring(1, 2)); return position; @@ -227,14 +214,12 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { position.setLatitude(parser.nextDouble()); position.setLongitude(parser.nextDouble()); - // Ignoring last three fields, unknown - position.set("unknown", parser.next() + "," + parser.next() + "," + parser.next()); + position.set(Position.KEY_TYPE, sentence.substring(1, 2)); return position; } - // If we get here, we didn't understand the message - return null; } + } -- cgit v1.2.3