only check for suback if using MQTT 3.1.1 or higher

This commit is contained in:
Todd Treece 2015-10-05 11:32:10 -04:00
parent b9c9a28883
commit e70e2367b6

View File

@ -125,13 +125,16 @@ int8_t Adafruit_MQTT::connect() {
if (!sendPacket(buffer, len))
return -1;
// Get SUBACK
len = readPacket(buffer, 5, CONNECT_TIMEOUT_MS);
DEBUG_PRINT(F("SUBACK:\t"));
DEBUG_PRINTBUFFER(buffer, len);
if ((len != 5) || (buffer[0] != (MQTT_CTRL_SUBACK << 4))) {
return 6; // failure to subscribe
// Check for SUBACK if using MQTT 3.1.1 or higher
if(MQTT_PROTOCOL_LEVEL > 3) {
len = readPacket(buffer, 5, CONNECT_TIMEOUT_MS);
DEBUG_PRINT(F("SUBACK:\t"));
DEBUG_PRINTBUFFER(buffer, len);
if ((len != 5) || (buffer[0] != (MQTT_CTRL_SUBACK << 4))) {
return 6; // failure to subscribe
}
}
}
return 0;