aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-06-12 21:14:31 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-06-12 21:14:31 -0700
commit94c04282f1b3792bc2c16758049a57f4c42941c9 (patch)
treef159ef5fca62225d1e4b12f5efa18f365e29b9f0 /src/main/java/org/traccar
parentc0c7a664cac7af96ac20ca2819d1575c537508de (diff)
downloadtrackermap-server-94c04282f1b3792bc2c16758049a57f4c42941c9.tar.gz
trackermap-server-94c04282f1b3792bc2c16758049a57f4c42941c9.tar.bz2
trackermap-server-94c04282f1b3792bc2c16758049a57f4c42941c9.zip
Decode Huasheng alarms
Diffstat (limited to 'src/main/java/org/traccar')
-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();