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 /src/org/traccar | |
parent | 6c82282da3b35b2acf46f69655cd0d097058af24 (diff) | |
download | traccar-server-1bf2353bafe3481f1deeb9e73e9bcaa1a40f0103.tar.gz traccar-server-1bf2353bafe3481f1deeb9e73e9bcaa1a40f0103.tar.bz2 traccar-server-1bf2353bafe3481f1deeb9e73e9bcaa1a40f0103.zip |
Minor MiniFinder decoder refactor
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/MiniFinderProtocolDecoder.java | 27 |
1 files changed, 9 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; |