From 1bf2353bafe3481f1deeb9e73e9bcaa1a40f0103 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 30 Apr 2017 13:47:48 +1200 Subject: Minor MiniFinder decoder refactor --- .../protocol/MiniFinderProtocolDecoder.java | 27 ++++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java index bb0057964..9b4372c5b 100644 --- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java +++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2014 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,12 +48,6 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // battery (percentage) .compile(); - private static final Pattern PATTERN_GPS_PRECISION = new PatternBuilder() - .number("(d+),") // satellites in use - .number("(d+),") // satellites in view - .number("(d+.?d*)") // hdop - .compile(); - private static final Pattern PATTERN_A = new PatternBuilder() .text("!A,") .expression(PATTERN_FIX.pattern()) @@ -67,12 +61,13 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { .any() // unknown 3 fields .compile(); - // The !B (buffered data) records are the same as !D (live data) records. private static final Pattern PATTERN_BD = new PatternBuilder() - .expression("![BD],") + .expression("![BD],") // B - buffered, D - live .expression(PATTERN_FIX.pattern()) .expression(PATTERN_STATE.pattern()) - .expression(PATTERN_GPS_PRECISION.pattern()) + .number("(d+),") // satellites in use + .number("(d+),") // satellites in view + .number("(d+.?d*)") // hdop .compile(); private void decodeFix(Position position, Parser parser) { @@ -128,13 +123,6 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_BATTERY, parser.nextInt(0)); } - private void decodeGPSPrecision(Position position, Parser parser) { - - position.set(Position.KEY_SATELLITES, parser.nextInt(0)); - position.set(Position.KEY_SATELLITES_VISIBLE, parser.nextInt(0)); - position.set(Position.KEY_HDOP, parser.nextDouble(0)); - } - @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -167,7 +155,10 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { decodeFix(position, parser); decodeState(position, parser); - decodeGPSPrecision(position, parser); + + position.set(Position.KEY_SATELLITES, parser.nextInt(0)); + position.set(Position.KEY_SATELLITES_VISIBLE, parser.nextInt(0)); + position.set(Position.KEY_HDOP, parser.nextDouble(0)); return position; -- cgit v1.2.3