aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/KhdProtocolDecoder.java47
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;