aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java42
-rw-r--r--test/org/traccar/protocol/Gt06ProtocolDecoderTest.java9
2 files changed, 47 insertions, 4 deletions
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;
diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index 85ce9d8f2..0ac51f4b2 100644
--- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
@@ -17,6 +17,15 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
"78780D01086471700328358100093F040D0A"));
verifyAttributes(decoder, binary(
+ "797900143311070609020b00000000a0030046000109e4610d0a"));
+
+ verifyAttributes(decoder, binary(
+ "7979003e32110707083819000901fe0a060f006a1e3f24000000000000000000000000000000000000000000000000000000000000000000000000000000012116ba0d0a"));
+
+ verifyAttributes(decoder, binary(
+ "7979007632110706090217000901fe0a060f006a1c2024060f0053a429060f006a1d21060f0053a720060f006f151d0000000000000000000000003844d9e7f7e1773d60e327a9e442405cf28628b9c640a42bb0fc0d0244d855a38c220a4c802aa8da7dab50b0e235ef32dd5348ee0ce77a52540000010a205a0d0a"));
+
+ verifyAttributes(decoder, binary(
"7979006f210000000001426174746572793a352e3536562c4e4f524d414c3b20475052532a4c696e6b2055702047534d205369676e616c204c6576656c3a5374726f6e673b204750533a4f46463b2020204c4f434b3a4f46463b204254204d41433a4234413832383034343436323b007260880d0a"));
verifyPosition(decoder, binary(