From d3e063cf9de8a45bed4dfe87b73aadfd8d2edeab Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 18 Jul 2016 16:14:18 +1200 Subject: Decode MiniFinder status flags --- src/org/traccar/model/Position.java | 9 ++++++++ .../protocol/MiniFinderProtocolDecoder.java | 26 +++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 4e03b2097..e667f097d 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -66,6 +66,15 @@ public class Position extends Message { public static final String PREFIX_IO = "io"; public static final String PREFIX_COUNT = "count"; + public static final String ALARM_SOS = "sos"; + public static final String ALARM_VIBRATION = "vibration"; + public static final String ALARM_MOVEMENT = "movement"; + public static final String ALARM_OVERSPEED = "overspeed"; + public static final String ALARM_FALL_DOWN = "fallDown"; + public static final String ALARM_LOW_BATTERY = "lowBattery"; + public static final String ALARM_MOTION = "motion"; + public static final String ALARM_FAULT = "fault"; + private String protocol; public String getProtocol() { diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java index 089b491d2..96eaaf0fa 100644 --- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java +++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java @@ -90,9 +90,33 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { if (parser.hasNext(5)) { int flags = parser.nextInt(16); - position.set(Position.KEY_FLAGS, flags); + position.setValid(BitUtil.check(flags, 0)); + if (BitUtil.check(flags, 2)) { + position.set(Position.KEY_ALARM, Position.ALARM_FAULT); + } + if (BitUtil.check(flags, 6)) { + position.set(Position.KEY_ALARM, Position.ALARM_SOS); + } + if (BitUtil.check(flags, 7)) { + position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED); + } + if (BitUtil.check(flags, 8)) { + position.set(Position.KEY_ALARM, Position.ALARM_FALL_DOWN); + } + if (BitUtil.check(flags, 12)) { + position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY); + } + if (BitUtil.check(flags, 14)) { + position.set(Position.KEY_ALARM, Position.ALARM_MOTION); + } + if (BitUtil.check(flags, 15)) { + position.set(Position.KEY_ALARM, Position.ALARM_MOVEMENT); + } + + position.set(Position.KEY_GSM, BitUtil.between(flags, 16, 20)); + position.setAltitude(parser.nextDouble()); position.set(Position.KEY_BATTERY, parser.next()); -- cgit v1.2.3