aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
index eac06bbfe..8d39abead 100644
--- a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -64,6 +64,27 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private String decodeAlarm(int event) {
+ switch (event) {
+ case 4:
+ return Position.ALARM_FATIGUE_DRIVING;
+ case 6:
+ return Position.ALARM_SOS;
+ case 7:
+ return Position.ALARM_BRAKING;
+ case 8:
+ return Position.ALARM_ACCELERATION;
+ case 9:
+ return Position.ALARM_CORNERING;
+ case 10:
+ return Position.ALARM_ACCIDENT;
+ case 16:
+ return Position.ALARM_REMOVING;
+ default:
+ return null;
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -118,7 +139,10 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_STATUS, status);
position.set(Position.KEY_IGNITION, BitUtil.check(status, 14));
- position.set(Position.KEY_EVENT, buf.readUnsignedShort());
+
+ int event = buf.readUnsignedShort();
+ position.set(Position.KEY_ALARM, decodeAlarm(event));
+ position.set(Position.KEY_EVENT, event);
String time = buf.readCharSequence(12, StandardCharsets.US_ASCII).toString();