Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Removing warnings
  • Loading branch information
brentru committed Aug 17, 2018
commit eb537cc08566cf8fc8206528437fe97720ef9a70
21 changes: 12 additions & 9 deletions Adafruit_MQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ int8_t Adafruit_MQTT::connect() {
success = true;
break;
}
//Serial.println("\t**failed, retrying!");
}
if (! success) return -2; // failed to sub for some reason
}
Expand All @@ -206,15 +205,20 @@ int8_t Adafruit_MQTT::connect(const char *user, const char *pass)

uint16_t Adafruit_MQTT::processPacketsUntil(uint8_t *buffer, uint8_t waitforpackettype, uint16_t timeout) {
uint16_t len;
while (len = readFullPacket(buffer, MAXBUFFERSIZE, timeout)) {

//DEBUG_PRINT("Packet read size: "); DEBUG_PRINTLN(len);
// TODO: add subscription reading & call back processing here
while(true) {
len = readFullPacket(buffer, MAXBUFFERSIZE, timeout);

if ((buffer[0] >> 4) == waitforpackettype) {
//DEBUG_PRINTLN(F("Found right packet"));
if(len == 0){
break;
}

if ((buffer[0] >> 4) == waitforpackettype)
{
return len;
} else {
}
else
{
ERROR_PRINTLN(F("Dropped a packet"));
}
}
Expand Down Expand Up @@ -407,7 +411,6 @@ bool Adafruit_MQTT::unsubscribe(Adafruit_MQTT_Subscribe *sub) {
}

void Adafruit_MQTT::processPackets(int16_t timeout) {
uint16_t len;

uint32_t elapsed = 0, endtime, starttime = millis();

Expand Down Expand Up @@ -482,7 +485,7 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::readSubscription(int16_t timeout) {
if (i==MAXSUBSCRIPTIONS) return NULL; // matching sub not found ???

uint8_t packet_id_len = 0;
uint16_t packetid;
uint16_t packetid = 0;
// Check if it is QoS 1, TODO: we dont support QoS 2
if ((buffer[0] & 0x6) == 0x2) {
packet_id_len = 2;
Expand Down