diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-03-28 14:19:43 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-03-28 14:19:50 -0700 |
commit | 8ecc4af154ec67a8818a21b96a9f10a74bfc919c (patch) | |
tree | b75c61841aec1dc9ebfe2c0c543a88369f63a152 /src | |
parent | ec3b29589d9006e270dad5f1f4fecf8997f3128d (diff) | |
download | trackermap-server-8ecc4af154ec67a8818a21b96a9f10a74bfc919c.tar.gz trackermap-server-8ecc4af154ec67a8818a21b96a9f10a74bfc919c.tar.bz2 trackermap-server-8ecc4af154ec67a8818a21b96a9f10a74bfc919c.zip |
Decode Futurecom alarms
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/KhdProtocolDecoder.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java b/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java index 1f3798bd2..b4fce5cbe 100644 --- a/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java @@ -24,6 +24,7 @@ import org.traccar.DeviceSession; import org.traccar.NetworkMessage; import org.traccar.Protocol; import org.traccar.helper.BcdUtil; +import org.traccar.helper.BitUtil; import org.traccar.helper.Checksum; import org.traccar.helper.DateBuilder; import org.traccar.helper.UnitsConverter; @@ -65,6 +66,42 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_SMS_ALARM_SWITCH = 0x86; public static final int MSG_PERIPHERAL = 0xA3; + private void decodeAlarmStatus(Position position, byte[] status) { + if (BitUtil.check(status[0], 4)) { + position.set(Position.KEY_ALARM, Position.ALARM_LOW_POWER); + } else if (BitUtil.check(status[0], 6)) { + position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE_EXIT); + } else if (BitUtil.check(status[0], 7)) { + position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE_ENTER); + } else if (BitUtil.check(status[1], 1)) { + position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED); + } else if (BitUtil.check(status[1], 3)) { + position.set(Position.KEY_ALARM, Position.ALARM_POWER_CUT); + } else if (BitUtil.check(status[1], 6)) { + position.set(Position.KEY_ALARM, Position.ALARM_TOW); + } else if (BitUtil.check(status[1], 7)) { + position.set(Position.KEY_ALARM, Position.ALARM_DOOR); + } else if (BitUtil.check(status[2], 2)) { + position.set(Position.KEY_ALARM, Position.ALARM_TEMPERATURE); + } else if (BitUtil.check(status[2], 4)) { + position.set(Position.KEY_ALARM, Position.ALARM_TAMPERING); + } else if (BitUtil.check(status[2], 6)) { + position.set(Position.KEY_ALARM, Position.ALARM_FATIGUE_DRIVING); + } else if (BitUtil.check(status[2], 7)) { + position.set(Position.KEY_ALARM, Position.ALARM_IDLE); + } else if (BitUtil.check(status[6], 3)) { + position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION); + } else if (BitUtil.check(status[6], 4)) { + position.set(Position.KEY_ALARM, Position.ALARM_BRAKING); + } else if (BitUtil.check(status[6], 5)) { + position.set(Position.KEY_ALARM, Position.ALARM_ACCELERATION); + } else if (BitUtil.check(status[6], 6)) { + position.set(Position.KEY_ALARM, Position.ALARM_CORNERING); + } else if (BitUtil.check(status[6], 7)) { + position.set(Position.KEY_ALARM, Position.ALARM_ACCIDENT); + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -178,6 +215,16 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { } + } else { + + buf.readUnsignedByte(); // overloaded state + buf.readUnsignedByte(); // logging status + + byte[] alarmStatus = new byte[8]; + buf.readBytes(alarmStatus); + + decodeAlarmStatus(position, alarmStatus); + } return position; |