From 08f05456ec6d93b62d0f087e9c76e5830a4a0a42 Mon Sep 17 00:00:00 2001 From: Tony DiCola Date: Fri, 12 Jun 2015 12:59:14 -0700 Subject: [PATCH] Update default keepalive to 5 minutes, add reset on ping fail to CC3k sketch. --- Adafruit_MQTT.h | 4 ++-- examples/mqtt_cc3k/mqtt_cc3k.ino | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Adafruit_MQTT.h b/Adafruit_MQTT.h index ba4b39f..513df80 100644 --- a/Adafruit_MQTT.h +++ b/Adafruit_MQTT.h @@ -62,8 +62,8 @@ #define PUBLISH_TIMEOUT_MS 500 #define PING_TIMEOUT_MS 500 -// Adjust as necessary, in seconds -#define MQTT_CONN_KEEPALIVE 15 +// Adjust as necessary, in seconds. Default to 5 minutes. +#define MQTT_CONN_KEEPALIVE 300 // Largest full packet we're able to send. // Need to be able to store at least ~90 chars for a connect packet with full diff --git a/examples/mqtt_cc3k/mqtt_cc3k.ino b/examples/mqtt_cc3k/mqtt_cc3k.ino index d1f1da8..762a13f 100644 --- a/examples/mqtt_cc3k/mqtt_cc3k.ino +++ b/examples/mqtt_cc3k/mqtt_cc3k.ino @@ -129,8 +129,10 @@ void loop() { // Try to ping the MQTT server /* if (! mqtt.ping(3) ) { - // MQTT pings failed, lets reconnect - Serial.println("Ping fail!"); + // MQTT pings failed, let's reconnect by forcing a watchdog reset. + Serial.println("Ping fail! Resetting..."); + Watchdog.enable(8000); + delay(10000); } */