diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index aa344b4b..549d2b76 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -316,6 +316,25 @@ void _mqttBackwards() { } } +void _mqttInfo() { + DEBUG_MSG_P(PSTR("[MQTT] Async %s, SSL %s, Autoconnect %s\n"), + MQTT_USE_ASYNC ? "ENABLED" : "DISABLED", + ASYNC_TCP_SSL_ENABLED ? "ENABLED" : "DISABLED", + MQTT_AUTOCONNECT ? "ENABLED" : "DISABLED" + ); + DEBUG_MSG_P(PSTR("[MQTT] Client %s, %s\n"), + _mqtt_enabled ? "ENABLED" : "DISABLED", + _mqtt.connected() ? "CONNECTED" : "DISCONNECTED" + ); + DEBUG_MSG_P(PSTR("[MQTT] Retry %s (Now %u, Last %u, Delay %u, Step %u)\n"), + _mqtt_connecting ? "CONNECTING" : "WAITING", + millis(), + _mqtt_last_connection, + _mqtt_reconnect_delay, + MQTT_RECONNECT_DELAY_STEP + ); +} + // ----------------------------------------------------------------------------- // WEB // ----------------------------------------------------------------------------- @@ -363,6 +382,11 @@ void _mqttInitCommands() { terminalOK(); }); + terminalRegisterCommand(F("MQTT.INFO"), [](Embedis* e) { + _mqttInfo(); + terminalOK(); + }); + } #endif // TERMINAL_SUPPORT @@ -405,6 +429,7 @@ void _mqttOnConnect() { _mqtt_reconnect_delay = MQTT_RECONNECT_DELAY_MIN; _mqtt_last_connection = millis(); + _mqtt_connecting = false; // Clean subscriptions mqttUnsubscribeRaw("#"); @@ -766,12 +791,7 @@ void mqttSetBrokerIfNone(IPAddress ip, unsigned int port) { void mqttSetup() { _mqttBackwards(); - - DEBUG_MSG_P(PSTR("[MQTT] Async %s, SSL %s, Autoconnect %s\n"), - MQTT_USE_ASYNC ? "ENABLED" : "DISABLED", - ASYNC_TCP_SSL_ENABLED ? "ENABLED" : "DISABLED", - MQTT_AUTOCONNECT ? "ENABLED" : "DISABLED" - ); + _mqttInfo(); #if MQTT_USE_ASYNC