Browse Source

Merge pull request #1757 from mcspr/mqtt/retry-states

MQTT connection state
master
Xose Pérez 5 years ago
committed by GitHub
parent
commit
c57a0abf7b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 6 deletions
  1. +26
    -6
      code/espurna/mqtt.ino

+ 26
- 6
code/espurna/mqtt.ino View File

@ -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


Loading…
Cancel
Save