You've already forked Adafruit_MQTT_Library
mirror of
https://github.com/adafruit/Adafruit_MQTT_Library.git
synced 2025-07-27 15:01:49 +03:00
adds ping to the end of the main loop in examples
This commit is contained in:
@ -104,16 +104,6 @@ void loop() {
|
||||
// connection and automatically reconnect when disconnected). See the MQTT_connect
|
||||
// function definition further below.
|
||||
MQTT_connect();
|
||||
|
||||
// Try to ping the MQTT server
|
||||
/*
|
||||
if (! mqtt.ping(3) ) {
|
||||
// MQTT pings failed, let's reconnect by forcing a watchdog reset.
|
||||
Serial.println("Ping fail! Resetting...");
|
||||
Watchdog.enable(8000);
|
||||
delay(10000);
|
||||
}
|
||||
*/
|
||||
|
||||
// this is our 'wait for incoming subscription packets' busy subloop
|
||||
Adafruit_MQTT_Subscribe *subscription;
|
||||
@ -133,6 +123,12 @@ void loop() {
|
||||
} else {
|
||||
Serial.println(F("OK!"));
|
||||
}
|
||||
|
||||
// ping the server to keep the mqtt connection alive
|
||||
if(! mqtt.ping()) {
|
||||
Serial.println(F("MQTT Ping failed."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Function to connect and reconnect as necessary to the MQTT server.
|
||||
|
Reference in New Issue
Block a user