From e9d77d16a99874ef4c5eb44dc15994811d724b9d Mon Sep 17 00:00:00 2001 From: Evgeny S Maksimov Date: Tue, 29 Jan 2019 19:55:31 +0300 Subject: Support for downgrading the FLEX protocol version --- src/org/traccar/protocol/NavisProtocolDecoder.java | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java index 0bebfe0d2..f6fa75c58 100644 --- a/src/org/traccar/protocol/NavisProtocolDecoder.java +++ b/src/org/traccar/protocol/NavisProtocolDecoder.java @@ -588,24 +588,26 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { flexProtocolVersion = (byte) buf.readUnsignedByte(); flexStructVersion = (byte) buf.readUnsignedByte(); - if (flexProtocolVersion != (byte) 0x0A && flexProtocolVersion != (byte) 0x14) { - return null; - } - if (flexStructVersion != (byte) 0x0A && flexStructVersion != (byte) 0x14) { - return null; - } + if ((flexProtocolVersion == (byte) 0x0A || flexProtocolVersion == (byte) 0x14) + && (flexStructVersion == (byte) 0x0A || flexStructVersion == (byte) 0x14)) { - flexBitfieldDataSize = buf.readUnsignedByte(); - if (flexBitfieldDataSize > 122) { - return null; - } - buf.readBytes(flexBitfield, 0, (int) Math.ceil((double) flexBitfieldDataSize / 8)); + flexBitfieldDataSize = buf.readUnsignedByte(); + if (flexBitfieldDataSize > 122) { + return null; + } - flexDataSize = 0; - for (int i = 0; i < flexBitfieldDataSize; i++) { - if (checkFlexBitfield(i)) { - flexDataSize += FLEX_FIELDS_SIZES[i]; + buf.readBytes(flexBitfield, 0, (int) Math.ceil((double) flexBitfieldDataSize / 8)); + + flexDataSize = 0; + for (int i = 0; i < flexBitfieldDataSize; i++) { + if (checkFlexBitfield(i)) { + flexDataSize += FLEX_FIELDS_SIZES[i]; + } } + } else { + // Prepare request for downgrade of protocol version to FLEX 2.0 + flexProtocolVersion = 0x14; + flexStructVersion = 0x14; } ByteBuf response = Unpooled.buffer(9); -- cgit v1.2.3