From c9245e2dd791d115011dbb4490733fd9102415d1 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 9 Jul 2017 00:33:21 +1200 Subject: Decode AZ735 protocol status --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 42 ++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 357256d76..24bedcabf 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -187,16 +187,19 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { private boolean decodeLbs(Position position, ChannelBuffer buf, boolean hasLength) { - int lbsLength = 0; + int length = 0; if (hasLength) { - lbsLength = buf.readUnsignedByte(); + length = buf.readUnsignedByte(); + if (length == 0) { + return false; + } } position.setNetwork(new Network(CellTower.from( buf.readUnsignedShort(), buf.readUnsignedByte(), buf.readUnsignedShort(), buf.readUnsignedMedium()))); - if (lbsLength > 0) { - buf.skipBytes(lbsLength - 9); + if (length > 0) { + buf.skipBytes(length - 8); } return true; @@ -543,6 +546,37 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { decodeLbs(position, buf, true); + buf.skipBytes(buf.readUnsignedByte()); // additional cell towers + buf.skipBytes(buf.readUnsignedByte()); // wifi access point + + int status = buf.readUnsignedByte(); + position.set(Position.KEY_STATUS, status); + + if (type == MSG_AZ735_ALARM) { + switch (status) { + case 0xA0: + position.set(Position.KEY_ARMED, true); + break; + case 0xA1: + position.set(Position.KEY_ARMED, false); + break; + case 0xA2: + case 0xA3: + position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY); + break; + case 0xA4: + position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); + break; + case 0xA5: + position.set(Position.KEY_ALARM, Position.ALARM_DOOR); + break; + default: + break; + } + } + + buf.skipBytes(buf.readUnsignedByte()); // reserved extension + sendResponse(channel, true, type); return position; -- cgit v1.2.3