diff --git a/README.md b/README.md index a420b00..1963cde 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Finally, the long announced Tonuino-PCB for Wemos' Lolin32 is [there](https://gi * 05.12.2020: Added filebrowser to webgui (thanks @mariolukas for contribution!) * 05.12.2020: Moved all user-relevant settings to src/settings.h * 06.12.2020: Added PCB for Wemos Lolin32 +* 08.12.2020: Reworked MQTT-timeout-Management More to come... ## Disclaimer diff --git a/src/main.cpp b/src/main.cpp index 74a2b9b..4f27ce5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -151,6 +151,7 @@ uint8_t nightLedBrightness = 2; // Brightness of Neopixe bool enableMqtt = true; #ifdef MQTT_ENABLE uint8_t const stillOnlineInterval = 60; // Interval 'I'm still alive' is sent via MQTT (in seconds) + uint32_t mqttLastRetryTimestamp = 0; #endif uint8_t const cardIdSize = 4; // RFID @@ -807,8 +808,6 @@ void postHeartbeatViaMqtt(void) { /* Connects/reconnects to MQTT-Broker unless connection is not already available. Manages MQTT-subscriptions. */ -uint32_t mqttLastRetryTimestamp = 0; - bool reconnect() { uint8_t connect = false; uint8_t i = 0; diff --git a/src/settings.h b/src/settings.h index 7f68bb1..95ffa90 100644 --- a/src/settings.h +++ b/src/settings.h @@ -132,24 +132,24 @@ float voltageIndicatorHigh = 4.2; // Upper range for Neopixel- #ifdef MQTT_ENABLE uint16_t mqttRetryInterval = 15; // Try to reconnect to MQTT-server every (n) seconds if connection is broken uint8_t mqttMaxRetriesPerInterval = 1; // Number of retries per time-interval (mqttRetryInterval). mqttRetryInterval 15 / mqttMaxRetriesPerInterval 1 => once every 15s - #define DEVICE_HOSTNAME "ESP32-Tonuino-Leonie" // Name that that is used for MQTT - static const char topicSleepCmnd[] PROGMEM = "Cmnd/Tonuino-Leonie/Sleep"; - static const char topicSleepState[] PROGMEM = "State/Tonuino-Leonie/Sleep"; - static const char topicTrackCmnd[] PROGMEM = "Cmnd/Tonuino-Leonie/Track"; - static const char topicTrackState[] PROGMEM = "State/Tonuino-Leonie/Track"; - static const char topicTrackControlCmnd[] PROGMEM = "Cmnd/Tonuino-Leonie/TrackControl"; - static const char topicLoudnessCmnd[] PROGMEM = "Cmnd/Tonuino-Leonie/Loudness"; - static const char topicLoudnessState[] PROGMEM = "State/Tonuino-Leonie/Loudness"; - static const char topicSleepTimerCmnd[] PROGMEM = "Cmnd/Tonuino-Leonie/SleepTimer"; - static const char topicSleepTimerState[] PROGMEM = "State/Tonuino-Leonie/SleepTimer"; - static const char topicState[] PROGMEM = "State/Tonuino-Leonie/State"; - static const char topicCurrentIPv4IP[] PROGMEM = "State/Tonuino-Leonie/IPv4"; - static const char topicLockControlsCmnd[] PROGMEM ="Cmnd/Tonuino-Leonie/LockControls"; - static const char topicLockControlsState[] PROGMEM ="State/Tonuino-Leonie/LockControls"; - static const char topicPlaymodeState[] PROGMEM = "State/Tonuino-Leonie/Playmode"; - static const char topicRepeatModeCmnd[] PROGMEM = "Cmnd/Tonuino-Leonie/RepeatMode"; - static const char topicRepeatModeState[] PROGMEM = "State/Tonuino-Leonie/RepeatMode"; - static const char topicLedBrightnessCmnd[] PROGMEM = "Cmnd/Tonuino-Leonie/LedBrightness"; - static const char topicLedBrightnessState[] PROGMEM = "State/Tonuino-Leonie/LedBrightness"; - static const char topicBatteryVoltage[] PROGMEM = "State/Tonuino-Leonie/Voltage"; + #define DEVICE_HOSTNAME "ESP32-Tonuino" // Name that that is used for MQTT + static const char topicSleepCmnd[] PROGMEM = "Cmnd/Tonuino/Sleep"; + static const char topicSleepState[] PROGMEM = "State/Tonuino/Sleep"; + static const char topicTrackCmnd[] PROGMEM = "Cmnd/Tonuino/Track"; + static const char topicTrackState[] PROGMEM = "State/Tonuino/Track"; + static const char topicTrackControlCmnd[] PROGMEM = "Cmnd/Tonuino/TrackControl"; + static const char topicLoudnessCmnd[] PROGMEM = "Cmnd/Tonuino/Loudness"; + static const char topicLoudnessState[] PROGMEM = "State/Tonuino/Loudness"; + static const char topicSleepTimerCmnd[] PROGMEM = "Cmnd/Tonuino/SleepTimer"; + static const char topicSleepTimerState[] PROGMEM = "State/Tonuino/SleepTimer"; + static const char topicState[] PROGMEM = "State/Tonuino/State"; + static const char topicCurrentIPv4IP[] PROGMEM = "State/Tonuino/IPv4"; + static const char topicLockControlsCmnd[] PROGMEM ="Cmnd/Tonuino/LockControls"; + static const char topicLockControlsState[] PROGMEM ="State/Tonuino/LockControls"; + static const char topicPlaymodeState[] PROGMEM = "State/Tonuino/Playmode"; + static const char topicRepeatModeCmnd[] PROGMEM = "Cmnd/Tonuino/RepeatMode"; + static const char topicRepeatModeState[] PROGMEM = "State/Tonuino/RepeatMode"; + static const char topicLedBrightnessCmnd[] PROGMEM = "Cmnd/Tonuino/LedBrightness"; + static const char topicLedBrightnessState[] PROGMEM = "State/Tonuino/LedBrightness"; + static const char topicBatteryVoltage[] PROGMEM = "State/Tonuino/Voltage"; #endif