You've already forked Adafruit_MQTT_Library
mirror of
https://github.com/adafruit/Adafruit_MQTT_Library.git
synced 2025-06-11 22:48:09 +03:00
ping flushes input, tries multiple times
This commit is contained in:
@ -368,13 +368,20 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::readSubscription(int16_t timeout) {
|
||||
return subscriptions[i];
|
||||
}
|
||||
|
||||
bool Adafruit_MQTT::ping(uint8_t num = 1) {
|
||||
void Adafruit_MQTT::flushIncoming(uint16_t timeout) {
|
||||
// flush input!
|
||||
DEBUG_PRINTLN(F("Flushing input buffer"));
|
||||
while (readPacket(buffer, MAXBUFFERSIZE, timeout));
|
||||
}
|
||||
|
||||
bool Adafruit_MQTT::ping(uint8_t num) {
|
||||
flushIncoming(100);
|
||||
|
||||
while (num--) {
|
||||
// Construct and send ping packet.
|
||||
uint8_t len = pingPacket(buffer);
|
||||
if (!sendPacket(buffer, len))
|
||||
return false;
|
||||
continue;
|
||||
|
||||
// Process ping reply.
|
||||
len = readPacket(buffer, 2, PING_TIMEOUT_MS);
|
||||
|
Reference in New Issue
Block a user