1
0
mirror of https://github.com/adafruit/Adafruit_MQTT_Library.git synced 2025-07-27 15:01:49 +03:00

smarter packet reading makes for faster publish-handling! also, retries subscriptions 3 times

This commit is contained in:
ladyada
2016-05-18 15:23:41 -04:00
parent 7068ef5afe
commit ab1a0938b9
5 changed files with 33 additions and 52 deletions

View File

@ -100,8 +100,7 @@ class Adafruit_MQTT_CC3000 : public Adafruit_MQTT {
return mqttclient.connected();
}
uint16_t readPacket(uint8_t *buffer, uint8_t maxlen, int16_t timeout,
bool checkForValidPubPacket = false) {
uint16_t readPacket(uint8_t *buffer, uint8_t maxlen, int16_t timeout) {
/* Read data until either the connection is closed, or the idle timeout is reached. */
uint16_t len = 0;
int16_t t = timeout;
@ -120,16 +119,6 @@ class Adafruit_MQTT_CC3000 : public Adafruit_MQTT {
DEBUG_PRINTBUFFER(buffer, len);
return len;
}
// special case where we just one one publication packet at a time
if (checkForValidPubPacket) {
if ((buffer[0] == (MQTT_CTRL_PUBLISH << 4)) && (buffer[1] == len-2)) {
// oooh a valid publish packet!
DEBUG_PRINT(F("Read PUBLISH packet:\t"));
DEBUG_PRINTBUFFER(buffer, len);
return len;
}
}
}
Watchdog.reset();
timeout -= MQTT_CC3000_INTERAVAILDELAY;