aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/HuabaoProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-08-16 13:48:07 +0300
committerGitHub <noreply@github.com>2016-08-16 13:48:07 +0300
commit376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3 (patch)
tree3e1336a0597ca649f54e2b271a96df4b37273c9b /src/org/traccar/protocol/HuabaoProtocolDecoder.java
parent70bea1304ded17bb8a94ce8495d1e395e7cdf748 (diff)
parent96f0143b2cbbb93f1c325e1df7c66a2fc3d55b7e (diff)
downloadtraccar-server-376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3.tar.gz
traccar-server-376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3.tar.bz2
traccar-server-376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3.zip
Merge pull request #2219 from Abyss777/alarms_2
Alarm decoding for next protocols
Diffstat (limited to 'src/org/traccar/protocol/HuabaoProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/HuabaoProtocolDecoder.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/org/traccar/protocol/HuabaoProtocolDecoder.java
index e4c9a9860..9223ea9a5 100644
--- a/src/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -70,6 +70,32 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
sendResponse(channel, remoteAddress, MSG_GENERAL_RESPONSE, id, response);
}
+ private String decodeAlarm(long value) {
+ if (BitUtil.check(value, 0)) {
+ return Position.ALARM_SOS;
+ }
+ if (BitUtil.check(value, 1)) {
+ return Position.ALARM_OVERSPEED;
+ }
+ if (BitUtil.check(value, 5)) {
+ return Position.ALARM_GPS_ANTENNA_CUT;
+ }
+ if (BitUtil.check(value, 4) || BitUtil.check(value, 9)
+ || BitUtil.check(value, 10) || BitUtil.check(value, 11)) {
+ return Position.ALARM_FAULT;
+ }
+ if (BitUtil.check(value, 8)) {
+ return Position.ALARM_POWER_OFF;
+ }
+ if (BitUtil.check(value, 20)) {
+ return Position.ALARM_GEOFENCE;
+ }
+ if (BitUtil.check(value, 29)) {
+ return Position.ALARM_ACCIDENT;
+ }
+ return null;
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -105,7 +131,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_ALARM, buf.readUnsignedInt());
+ position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedInt()));
int flags = buf.readInt();