diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-30 13:47:48 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-30 13:47:48 +1200 |
commit | 1bf2353bafe3481f1deeb9e73e9bcaa1a40f0103 (patch) | |
tree | 739137cbcce4cfc37daa83870ce32203e5de60ab | |
parent | 6c82282da3b35b2acf46f69655cd0d097058af24 (diff) | |
download | trackermap-server-1bf2353bafe3481f1deeb9e73e9bcaa1a40f0103.tar.gz trackermap-server-1bf2353bafe3481f1deeb9e73e9bcaa1a40f0103.tar.bz2 trackermap-server-1bf2353bafe3481f1deeb9e73e9bcaa1a40f0103.zip |
Minor MiniFinder decoder refactor
-rw-r--r-- | src/org/traccar/protocol/MiniFinderProtocolDecoder.java | 27 | ||||
-rw-r--r-- | test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java | 3 |
2 files changed, 12 insertions, 18 deletions
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; diff --git a/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java b/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java index f2d3f2ade..c3b5dd674 100644 --- a/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java @@ -20,6 +20,9 @@ public class MiniFinderProtocolDecoderTest extends ProtocolTest { "!1,860719027585011")); verifyPosition(decoder, text( + "!D,15/04/17,13:58:53,51.483067,-0.452548,60,180,140001,28.7,47,4,13,0")); + + verifyPosition(decoder, text( "!D,07/04/17,05:42:26,-37.588970,145.121231,0,0,0c0001,185.2,92,7,14,1.2")); verifyPosition(decoder, text( |