diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-15 17:21:07 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-15 17:21:07 +1200 |
commit | d4ef43999690896d317f6d798b94596ccda53f1a (patch) | |
tree | 33bc8b0c619920879b772cc36530c62c7e0b2014 /src/org/traccar/protocol/Gt06ProtocolDecoder.java | |
parent | db86eb01e0e82fe79343b3e86d4605509ba8ad1b (diff) | |
download | trackermap-server-d4ef43999690896d317f6d798b94596ccda53f1a.tar.gz trackermap-server-d4ef43999690896d317f6d798b94596ccda53f1a.tar.bz2 trackermap-server-d4ef43999690896d317f6d798b94596ccda53f1a.zip |
Improve GT06 alarm decoding
Diffstat (limited to 'src/org/traccar/protocol/Gt06ProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/Gt06ProtocolDecoder.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 20b2c8eab..c697191ee 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -157,10 +157,30 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { private void decodeStatus(Position position, ChannelBuffer buf) { - int flags = buf.readUnsignedByte(); + int status = buf.readUnsignedByte(); + + position.set(Position.KEY_STATUS, status); + position.set(Position.KEY_IGNITION, BitUtil.check(status, 1)); + position.set(Position.KEY_CHARGE, BitUtil.check(status, 2)); + position.set(Position.KEY_BLOCKED, BitUtil.check(status, 7)); + + switch (BitUtil.between(status, 3, 6)) { + case 1: + position.set(Position.KEY_ALARM, Position.ALARM_SHOCK); + break; + case 2: + position.set(Position.KEY_ALARM, Position.ALARM_POWER_CUT); + break; + case 3: + position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY); + break; + case 4: + position.set(Position.KEY_ALARM, Position.ALARM_SOS); + break; + default: + break; + } - position.set(Position.KEY_IGNITION, BitUtil.check(flags, 1)); - position.set(Position.KEY_STATUS, flags); position.set(Position.KEY_BATTERY, buf.readUnsignedByte()); position.set(Position.KEY_RSSI, buf.readUnsignedByte()); position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); |