back compatible ping()
This commit is contained in:
parent
286245ab62
commit
632c2f2cfe
@ -325,20 +325,21 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::readSubscription(int16_t timeout) {
|
|||||||
return subscriptions[i];
|
return subscriptions[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Adafruit_MQTT::ping() {
|
bool Adafruit_MQTT::ping(uint8_t num = 1) {
|
||||||
|
|
||||||
// Construct and send ping packet.
|
while (num--) {
|
||||||
uint8_t len = pingPacket(buffer);
|
// Construct and send ping packet.
|
||||||
if (!sendPacket(buffer, len))
|
uint8_t len = pingPacket(buffer);
|
||||||
return false;
|
if (!sendPacket(buffer, len))
|
||||||
|
return false;
|
||||||
|
|
||||||
// Process ping reply.
|
// Process ping reply.
|
||||||
len = readPacket(buffer, 2, PING_TIMEOUT_MS);
|
len = readPacket(buffer, 2, PING_TIMEOUT_MS);
|
||||||
if (buffer[0] == (MQTT_CTRL_PINGRESP << 4))
|
if (buffer[0] == (MQTT_CTRL_PINGRESP << 4))
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Packet Generation Functions /////////////////////////////////////////////////
|
// Packet Generation Functions /////////////////////////////////////////////////
|
||||||
|
@ -169,7 +169,7 @@ class Adafruit_MQTT {
|
|||||||
Adafruit_MQTT_Subscribe *readSubscription(int16_t timeout=0);
|
Adafruit_MQTT_Subscribe *readSubscription(int16_t timeout=0);
|
||||||
|
|
||||||
// Ping the server to ensure the connection is still alive.
|
// Ping the server to ensure the connection is still alive.
|
||||||
bool ping();
|
bool ping(uint8_t n);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Interface that subclasses need to implement:
|
// Interface that subclasses need to implement:
|
||||||
|
Loading…
Reference in New Issue
Block a user