aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-06 16:22:23 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-06 16:22:23 +1300
commit2bf8597601c9ab2d9569a7cd63c5bf351ce44763 (patch)
treeabf2d02c0d063157214f6917c0e4e522bc78878c /src/org/traccar/protocol/MiniFinderProtocolDecoder.java
parentdbcfd8488213623e68607fa946df63256dbabf18 (diff)
downloadtrackermap-server-2bf8597601c9ab2d9569a7cd63c5bf351ce44763.tar.gz
trackermap-server-2bf8597601c9ab2d9569a7cd63c5bf351ce44763.tar.bz2
trackermap-server-2bf8597601c9ab2d9569a7cd63c5bf351ce44763.zip
Replace EV603 decoder with MiniFinder
Diffstat (limited to 'src/org/traccar/protocol/MiniFinderProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/MiniFinderProtocolDecoder.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
index 9f4febccb..5a5ef3964 100644
--- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
+++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
@@ -33,19 +33,23 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
}
private static final Pattern PATTERN = new PatternBuilder()
- .text("!D,")
+ .expression("![AD],")
.number("(d+)/(d+)/(d+),") // date
.number("(d+):(d+):(d+),") // time
.number("(-?d+.d+),") // latitude
.number("(-?d+.d+),") // longitude
.number("(d+.?d*),") // speed
.number("(d+.?d*),") // course
+ .groupBegin()
.number("(x+),") // flags
.number("(-?d+.d+),") // altitude
.number("(d+),") // battery
.number("(d+),") // satellites in use
.number("(d+),") // satellites in view
.text("0")
+ .or()
+ .any()
+ .groupEnd()
.compile();
@Override
@@ -58,7 +62,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
identify(sentence.substring(3, sentence.length()), channel);
- } else if (sentence.startsWith("!D") && hasDeviceId()) {
+ } else if ((sentence.startsWith("!D") || sentence.startsWith("!A")) && hasDeviceId()) {
Parser parser = new Parser(PATTERN, sentence);
if (!parser.matches()) {
@@ -77,16 +81,24 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextDouble());
position.setLongitude(parser.nextDouble());
position.setSpeed(parser.nextDouble());
+
position.setCourse(parser.nextDouble());
+ if (position.getCourse() > 360) {
+ position.setCourse(0);
+ }
+
+ if (parser.hasNext(5)) {
- int flags = parser.nextInt(16);
- position.set(Event.KEY_FLAGS, flags);
- position.setValid(BitUtil.check(flags, 0));
+ int flags = parser.nextInt(16);
+ position.set(Event.KEY_FLAGS, flags);
+ position.setValid(BitUtil.check(flags, 0));
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble());
- position.set(Event.KEY_BATTERY, parser.next());
- position.set(Event.KEY_SATELLITES, parser.next());
+ position.set(Event.KEY_BATTERY, parser.next());
+ position.set(Event.KEY_SATELLITES, parser.next());
+
+ }
return position;