diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-07-19 21:23:48 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-07-19 21:23:48 +1200 |
commit | 5b56c2cc17fa23251b1985aa4d8f56dd6552b970 (patch) | |
tree | e46015396235f9d391ab78106ccdf8703b554fb1 | |
parent | 73fb44dfb7dea5cdddcb3ab939e9b7a64ae49abb (diff) | |
download | traccar-server-5b56c2cc17fa23251b1985aa4d8f56dd6552b970.tar.gz traccar-server-5b56c2cc17fa23251b1985aa4d8f56dd6552b970.tar.bz2 traccar-server-5b56c2cc17fa23251b1985aa4d8f56dd6552b970.zip |
Implement JV200 ignition support
-rw-r--r-- | src/org/traccar/protocol/Gt06ProtocolDecoder.java | 10 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 3 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 24bedcabf..aea3a29f4 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -336,7 +336,6 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1); buf.readUnsignedShort(); // type - // Timezone offset if (dataLength > 10) { int extensionBits = buf.readUnsignedShort(); int hours = (extensionBits >> 4) / 100; @@ -405,7 +404,6 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { int mcc = buf.readUnsignedShort(); int mnc = buf.readUnsignedByte(); - Network network = new Network(); for (int i = 0; i < 7; i++) { network.addCellTower(CellTower.from( @@ -441,10 +439,16 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { decodeStatus(position, buf); } - if (type == MSG_GPS_LBS_1 && buf.readableBytes() == 4 + 6) { + if (type == MSG_GPS_LBS_1 && buf.readableBytes() >= 4 + 6) { position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); } + if (type == MSG_GPS_LBS_2 && buf.readableBytes() >= 3 + 6) { + position.set(Position.KEY_IGNITION, buf.readUnsignedByte() > 0); + position.set(Position.KEY_EVENT, buf.readUnsignedByte()); // reason + position.set(Position.KEY_ARCHIVE, buf.readUnsignedByte() > 0); + } + } else { buf.skipBytes(dataLength); diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 0ac51f4b2..2e6a53b06 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -16,6 +16,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyPosition(decoder, binary( + "787822221106160a1016c60278019407c7783800040001940504700046fc01030100065f570d0a")); + verifyAttributes(decoder, binary( "797900143311070609020b00000000a0030046000109e4610d0a")); |