diff options
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/NavisProtocolDecoder.java | 32 |
1 files changed, 17 insertions, 15 deletions
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); |