diff options
author | Anton Tananaev <anton@traccar.org> | 2024-06-19 11:44:15 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-06-19 11:44:15 -0700 |
commit | d47da84d3bfea34266ba83ea8595a7ad9a7031b9 (patch) | |
tree | a1e2aafe9fd10c5cb32c64e7212afa59e6bd4fe8 /src/main/java/org | |
parent | 3679bcc9dc31fbab434f79a71ccb012c53b61c5e (diff) | |
download | trackermap-server-d47da84d3bfea34266ba83ea8595a7ad9a7031b9.tar.gz trackermap-server-d47da84d3bfea34266ba83ea8595a7ad9a7031b9.tar.bz2 trackermap-server-d47da84d3bfea34266ba83ea8595a7ad9a7031b9.zip |
Decode DMT alarm events
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/traccar/protocol/DmtProtocolDecoder.java | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java b/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java index 320aa1b60..f8295543f 100644 --- a/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/DmtProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2021 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2024 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -151,7 +151,9 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder { position.setDeviceTime(new Date(1356998400000L + buf.readUnsignedIntLE() * 1000)); // since 1 Jan 2013 - position.set(Position.KEY_EVENT, buf.readUnsignedByte()); + int event = buf.readUnsignedByte(); + position.set(Position.KEY_ALARM, decodeAlarm(event)); + position.set(Position.KEY_EVENT, event); while (buf.readerIndex() < recordEnd) { @@ -246,6 +248,31 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder { return positions; } + private String decodeAlarm(int value) { + switch (value) { + case 12: + return Position.ALARM_BRAKING; + case 13: + return Position.ALARM_ACCELERATION; + case 14: + return Position.ALARM_CORNERING; + case 18: + return Position.ALARM_OVERSPEED; + case 20: + return Position.ALARM_TOW; + case 23: + return Position.ALARM_ACCIDENT; + case 29: + return Position.ALARM_TAMPERING; + case 44: + return Position.ALARM_GEOFENCE_ENTER; + case 45: + return Position.ALARM_GEOFENCE_EXIT; + default: + return null; + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { |