From b90dfecfdc127d1870f5f61db177f8d63fb9a095 Mon Sep 17 00:00:00 2001 From: Anshul Jain Date: Mon, 28 Aug 2017 11:15:03 +0530 Subject: Fix for Gt06 GPS data length can not be greater than 12. Fix for Alarm packet LBS length skip for 9. --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index d8da7e6de..dbbaeaf03 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -182,6 +182,9 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } if (length > 0) { + if (length > 12) { + length = 12; + } buf.skipBytes(length - 12); // skip reserved } @@ -202,7 +205,11 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(), buf.readUnsignedByte(), buf.readUnsignedShort(), buf.readUnsignedMedium()))); if (length > 0) { - buf.skipBytes(length - 8); + if (hasLength) { + buf.skipBytes(length - 9); + } else { + buf.skipBytes(length - 8); + } } return true; -- cgit v1.2.3 From 538ef8e3f04dd4108b16dc39f3df3e535c7dea7f Mon Sep 17 00:00:00 2001 From: Anshul Jain Date: Mon, 28 Aug 2017 14:10:13 +0530 Subject: Added new column to determine for extended or basic decode. --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index dbbaeaf03..cf2b8c928 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -191,7 +191,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { return true; } - private boolean decodeLbs(Position position, ChannelBuffer buf, boolean hasLength) { + private boolean decodeLbs(Position position, ChannelBuffer buf, boolean hasLength, boolean isExtended) { int length = 0; if (hasLength) { @@ -205,7 +205,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(), buf.readUnsignedByte(), buf.readUnsignedShort(), buf.readUnsignedMedium()))); if (length > 0) { - if (hasLength) { + if (hasLength && !isExtended) { buf.skipBytes(length - 9); } else { buf.skipBytes(length - 8); @@ -468,7 +468,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } if (hasLbs(type)) { - decodeLbs(position, buf, hasStatus(type)); + decodeLbs(position, buf, hasStatus(type), false); } if (hasStatus(type)) { @@ -580,7 +580,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { getLastLocation(position, position.getDeviceTime()); } - decodeLbs(position, buf, true); + decodeLbs(position, buf, true, true); buf.skipBytes(buf.readUnsignedByte()); // additional cell towers buf.skipBytes(buf.readUnsignedByte()); // wifi access point -- cgit v1.2.3 From ac2d2723086b086d8c27a533b6f7c4888d04e63b Mon Sep 17 00:00:00 2001 From: Anshul Jain Date: Tue, 29 Aug 2017 13:22:10 +0530 Subject: Move extended LBS data to skip in decodeExtended instead of decodeLBS. --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index cf2b8c928..5c83f9348 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -191,7 +191,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { return true; } - private boolean decodeLbs(Position position, ChannelBuffer buf, boolean hasLength, boolean isExtended) { + private boolean decodeLbs(Position position, ChannelBuffer buf, boolean hasLength) { int length = 0; if (hasLength) { @@ -205,11 +205,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(), buf.readUnsignedByte(), buf.readUnsignedShort(), buf.readUnsignedMedium()))); if (length > 0) { - if (hasLength && !isExtended) { - buf.skipBytes(length - 9); - } else { - buf.skipBytes(length - 8); - } + buf.skipBytes(length - (hasLength ? 9 : 8)); } return true; @@ -468,7 +464,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } if (hasLbs(type)) { - decodeLbs(position, buf, hasStatus(type), false); + decodeLbs(position, buf, hasStatus(type)); + buf.skipBytes(-1); } if (hasStatus(type)) { @@ -580,7 +577,9 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { getLastLocation(position, position.getDeviceTime()); } - decodeLbs(position, buf, true, true); + if (decodeLbs(position, buf, true)) { + buf.skipBytes(1); //Extended data + } buf.skipBytes(buf.readUnsignedByte()); // additional cell towers buf.skipBytes(buf.readUnsignedByte()); // wifi access point -- cgit v1.2.3