diff --git a/usermods/Animated_Staircase/Animated_Staircase.h b/usermods/Animated_Staircase/Animated_Staircase.h index 1ef2c959..151cf1d4 100644 --- a/usermods/Animated_Staircase/Animated_Staircase.h +++ b/usermods/Animated_Staircase/Animated_Staircase.h @@ -92,12 +92,14 @@ class Animated_Staircase : public Usermod { static const char _bottomEchoCm[]; void publishMqtt(bool bottom, const char* state) { +#ifndef WLED_DISABLE_MQTT //Check if MQTT Connected, otherwise it will crash the 8266 if (WLED_MQTT_CONNECTED){ char subuf[64]; sprintf_P(subuf, PSTR("%s/motion/%d"), mqttDeviceTopic, (int)bottom); mqtt->publish(subuf, 0, false, state); } +#endif } void updateSegments() { @@ -345,6 +347,7 @@ class Animated_Staircase : public Usermod { uint16_t getId() { return USERMOD_ID_ANIMATED_STAIRCASE; } +#ifndef WLED_DISABLE_MQTT /** * handling of MQTT message * topic only contains stripped topic (part after /wled/MAC) @@ -382,6 +385,7 @@ class Animated_Staircase : public Usermod { mqtt->subscribe(subuf, 0); } } +#endif void addToJsonState(JsonObject& root) { JsonObject staircase = root[FPSTR(_name)]; diff --git a/usermods/BH1750_v2/usermod_bh1750.h b/usermods/BH1750_v2/usermod_bh1750.h index a69e2751..b65332bc 100644 --- a/usermods/BH1750_v2/usermod_bh1750.h +++ b/usermods/BH1750_v2/usermod_bh1750.h @@ -1,6 +1,10 @@ // force the compiler to show a warning to confirm that this file is included #warning **** Included USERMOD_BH1750 **** +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + #pragma once #include "wled.h" @@ -156,6 +160,7 @@ public: { lastLux = lux; lastSend = millis(); +#ifndef WLED_DISABLE_MQTT if (WLED_MQTT_CONNECTED) { if (!mqttInitialized) @@ -170,6 +175,7 @@ public: { DEBUG_PRINTLN(F("Missing MQTT connection. Not publishing data")); } +#endif } } diff --git a/usermods/BME280_v2/usermod_bme280.h b/usermods/BME280_v2/usermod_bme280.h index c27adfc8..e643e62b 100644 --- a/usermods/BME280_v2/usermod_bme280.h +++ b/usermods/BME280_v2/usermod_bme280.h @@ -1,6 +1,10 @@ // force the compiler to show a warning to confirm that this file is included #warning **** Included USERMOD_BME280 version 2.0 **** +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + #pragma once #include "wled.h" diff --git a/usermods/Battery/usermod_v2_Battery.h b/usermods/Battery/usermod_v2_Battery.h index ac34a7e4..2dc85424 100644 --- a/usermods/Battery/usermod_v2_Battery.h +++ b/usermods/Battery/usermod_v2_Battery.h @@ -224,6 +224,7 @@ class UsermodBattery : public Usermod if (autoOffEnabled && (autoOffThreshold >= batteryLevel)) turnOff(); +#ifndef WLED_DISABLE_MQTT // SmartHome stuff // still don't know much about MQTT and/or HA if (WLED_MQTT_CONNECTED) { @@ -231,6 +232,7 @@ class UsermodBattery : public Usermod snprintf_P(buf, 63, PSTR("%s/voltage"), mqttDeviceTopic); mqtt->publish(buf, 0, false, String(voltage).c_str()); } +#endif } diff --git a/usermods/DHT/usermod_dht.h b/usermods/DHT/usermod_dht.h index 6253b85f..b6142f43 100644 --- a/usermods/DHT/usermod_dht.h +++ b/usermods/DHT/usermod_dht.h @@ -1,6 +1,10 @@ #pragma once #include "wled.h" +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + #include diff --git a/usermods/Enclosure_with_OLED_temp_ESP07/usermod.cpp b/usermods/Enclosure_with_OLED_temp_ESP07/usermod.cpp index 0a2662aa..1ca16050 100644 --- a/usermods/Enclosure_with_OLED_temp_ESP07/usermod.cpp +++ b/usermods/Enclosure_with_OLED_temp_ESP07/usermod.cpp @@ -1,3 +1,7 @@ +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + #include "wled.h" #include #include // from https://github.com/olikraus/u8g2/ diff --git a/usermods/Enclosure_with_OLED_temp_ESP07/usermod_bme280.cpp b/usermods/Enclosure_with_OLED_temp_ESP07/usermod_bme280.cpp index 88d49790..d5fd4a0c 100644 --- a/usermods/Enclosure_with_OLED_temp_ESP07/usermod_bme280.cpp +++ b/usermods/Enclosure_with_OLED_temp_ESP07/usermod_bme280.cpp @@ -1,3 +1,7 @@ +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + #include "wled.h" #include #include // from https://github.com/olikraus/u8g2/ diff --git a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h index f4d69996..af81170a 100644 --- a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h +++ b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h @@ -159,6 +159,7 @@ private: void publishMqtt(const char* state) { + #ifndef WLED_DISABLE_MQTT //Check if MQTT Connected, otherwise it will crash the 8266 if (WLED_MQTT_CONNECTED) { char subuf[64]; @@ -166,11 +167,13 @@ private: strcat_P(subuf, PSTR("/motion")); mqtt->publish(subuf, 0, false, state); } + #endif } // Create an MQTT Binary Sensor for Home Assistant Discovery purposes, this includes a pointer to the topic that is published to in the Loop. void publishHomeAssistantAutodiscovery() { + #ifndef WLED_DISABLE_MQTT if (WLED_MQTT_CONNECTED) { StaticJsonDocument<600> doc; char uid[24], json_str[1024], buf[128]; @@ -200,6 +203,7 @@ private: mqtt->publish(buf, 0, true, json_str, payload_size); // do we really need to retain? } + #endif } /** diff --git a/usermods/SN_Photoresistor/usermod_sn_photoresistor.h b/usermods/SN_Photoresistor/usermod_sn_photoresistor.h index 9c3be7cc..60861e4c 100644 --- a/usermods/SN_Photoresistor/usermod_sn_photoresistor.h +++ b/usermods/SN_Photoresistor/usermod_sn_photoresistor.h @@ -109,6 +109,7 @@ public: { lastLDRValue = currentLDRValue; +#ifndef WLED_DISABLE_MQTT if (WLED_MQTT_CONNECTED) { char subuf[45]; @@ -121,6 +122,7 @@ public: DEBUG_PRINTLN("Missing MQTT connection. Not publishing data"); } } +#endif } uint16_t getLastLDRValue() diff --git a/usermods/Si7021_MQTT_HA/usermod_si7021_mqtt_ha.h b/usermods/Si7021_MQTT_HA/usermod_si7021_mqtt_ha.h index 71c22da1..4a42a7d5 100644 --- a/usermods/Si7021_MQTT_HA/usermod_si7021_mqtt_ha.h +++ b/usermods/Si7021_MQTT_HA/usermod_si7021_mqtt_ha.h @@ -1,3 +1,7 @@ +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + #pragma once // this is remixed from usermod_v2_SensorsToMqtt.h (sensors_to_mqtt usermod) diff --git a/usermods/Temperature/usermod_temperature.h b/usermods/Temperature/usermod_temperature.h index a666639f..8950f928 100644 --- a/usermods/Temperature/usermod_temperature.h +++ b/usermods/Temperature/usermod_temperature.h @@ -134,6 +134,7 @@ class UsermodTemperature : public Usermod { return false; } +#ifndef WLED_DISABLE_MQTT void publishHomeAssistantAutodiscovery() { if (!WLED_MQTT_CONNECTED) return; @@ -155,6 +156,7 @@ class UsermodTemperature : public Usermod { mqtt->publish(buf, 0, true, json_str, payload_size); HApublished = true; } +#endif public: @@ -212,6 +214,7 @@ class UsermodTemperature : public Usermod { } errorCount = 0; +#ifndef WLED_DISABLE_MQTT if (WLED_MQTT_CONNECTED) { char subuf[64]; strcpy(subuf, mqttDeviceTopic); @@ -227,6 +230,7 @@ class UsermodTemperature : public Usermod { // publish something else to indicate status? } } +#endif } } @@ -236,6 +240,7 @@ class UsermodTemperature : public Usermod { */ //void connected() {} +#ifndef WLED_DISABLE_MQTT /** * subscribe to MQTT topic if needed */ @@ -246,6 +251,7 @@ class UsermodTemperature : public Usermod { publishHomeAssistantAutodiscovery(); } } +#endif /* * API calls te enable data exchange between WLED modules diff --git a/usermods/Wemos_D1_mini+Wemos32_mini_shield/usermod.cpp b/usermods/Wemos_D1_mini+Wemos32_mini_shield/usermod.cpp index c7eb8ee0..78cc32a8 100644 --- a/usermods/Wemos_D1_mini+Wemos32_mini_shield/usermod.cpp +++ b/usermods/Wemos_D1_mini+Wemos32_mini_shield/usermod.cpp @@ -101,6 +101,7 @@ void userLoop() { if (temptimer - lastMeasure > 60000) { lastMeasure = temptimer; +#ifndef WLED_DISABLE_MQTT //Check if MQTT Connected, otherwise it will crash the 8266 if (mqtt != nullptr) { @@ -116,6 +117,7 @@ void userLoop() { t += "/temperature"; mqtt->publish(t.c_str(), 0, true, String(board_temperature).c_str()); } + #endif } // Check if we time interval for redrawing passes. diff --git a/usermods/Wemos_D1_mini+Wemos32_mini_shield/usermod_bme280.cpp b/usermods/Wemos_D1_mini+Wemos32_mini_shield/usermod_bme280.cpp index 05d4e77a..c9d9a527 100644 --- a/usermods/Wemos_D1_mini+Wemos32_mini_shield/usermod_bme280.cpp +++ b/usermods/Wemos_D1_mini+Wemos32_mini_shield/usermod_bme280.cpp @@ -103,6 +103,7 @@ void userLoop() { { lastMeasure = tempTimer; +#ifndef WLED_DISABLE_MQTT // Check if MQTT Connected, otherwise it will crash the 8266 if (mqtt != nullptr) { @@ -122,6 +123,7 @@ void userLoop() { h += "/humidity"; mqtt->publish(h.c_str(), 0, true, String(board_humidity).c_str()); } + #endif } // Check if we time interval for redrawing passes. diff --git a/usermods/boblight/boblight.h b/usermods/boblight/boblight.h index 263d8743..a1e25775 100644 --- a/usermods/boblight/boblight.h +++ b/usermods/boblight/boblight.h @@ -219,6 +219,7 @@ class BobLightUsermod : public Usermod { void enable(bool en) { enabled = en; } +#ifndef WLED_DISABLE_MQTT /** * handling of MQTT message * topic only contains stripped topic (part after /wled/MAC) @@ -249,6 +250,7 @@ class BobLightUsermod : public Usermod { // mqtt->subscribe(subuf, 0); //} } +#endif void addToJsonInfo(JsonObject& root) { diff --git a/usermods/multi_relay/usermod_multi_relay.h b/usermods/multi_relay/usermod_multi_relay.h index 7381a00d..b8bd4f6e 100644 --- a/usermods/multi_relay/usermod_multi_relay.h +++ b/usermods/multi_relay/usermod_multi_relay.h @@ -66,12 +66,14 @@ class MultiRelay : public Usermod { static const char _HAautodiscovery[]; void publishMqtt(int relay) { +#ifndef WLED_DISABLE_MQTT //Check if MQTT Connected, otherwise it will crash the 8266 if (WLED_MQTT_CONNECTED){ char subuf[64]; sprintf_P(subuf, PSTR("%s/relay/%d"), mqttDeviceTopic, relay); mqtt->publish(subuf, 0, false, _relay[relay].state ? "on" : "off"); } +#endif } /** @@ -232,6 +234,7 @@ class MultiRelay : public Usermod { //Functions called by WLED +#ifndef WLED_DISABLE_MQTT /** * handling of MQTT message * topic only contains stripped topic (part after /wled/MAC) @@ -313,6 +316,7 @@ class MultiRelay : public Usermod { mqtt->publish(buf, 0, true, json_str, payload_size); } } +#endif /** * setup() is called once at boot. WiFi is not yet connected at this point. diff --git a/usermods/sensors_to_mqtt/usermod_v2_SensorsToMqtt.h b/usermods/sensors_to_mqtt/usermod_v2_SensorsToMqtt.h index dd7aedc1..972e2c86 100644 --- a/usermods/sensors_to_mqtt/usermod_v2_SensorsToMqtt.h +++ b/usermods/sensors_to_mqtt/usermod_v2_SensorsToMqtt.h @@ -1,3 +1,7 @@ +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + #pragma once #include "wled.h" diff --git a/usermods/seven_segment_display/usermod_v2_seven_segment_display.h b/usermods/seven_segment_display/usermod_v2_seven_segment_display.h index 5c0022e0..e5b726e5 100644 --- a/usermods/seven_segment_display/usermod_v2_seven_segment_display.h +++ b/usermods/seven_segment_display/usermod_v2_seven_segment_display.h @@ -1,3 +1,7 @@ +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + #pragma once #include "wled.h" diff --git a/usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h b/usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h index b1a271a6..27977405 100644 --- a/usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h +++ b/usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h @@ -1,3 +1,7 @@ +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + #pragma once #include "wled.h" diff --git a/usermods/sht/usermod_sht.h b/usermods/sht/usermod_sht.h index 721cb7f0..4637d7a3 100644 --- a/usermods/sht/usermod_sht.h +++ b/usermods/sht/usermod_sht.h @@ -1,3 +1,7 @@ +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + #pragma once #include "SHT85.h" diff --git a/usermods/smartnest/usermod_smartnest.h b/usermods/smartnest/usermod_smartnest.h index 82673578..8d2b04ff 100644 --- a/usermods/smartnest/usermod_smartnest.h +++ b/usermods/smartnest/usermod_smartnest.h @@ -1,3 +1,7 @@ +#ifndef WLED_ENABLE_MQTT +#error "This user mod requires MQTT to be enabled." +#endif + #pragma once #include "wled.h" diff --git a/wled00/button.cpp b/wled00/button.cpp index 1be3e6df..fce21424 100644 --- a/wled00/button.cpp +++ b/wled00/button.cpp @@ -24,12 +24,14 @@ void shortPressAction(uint8_t b) applyPreset(macroButton[b], CALL_MODE_BUTTON_PRESET); } +#ifndef WLED_DISABLE_MQTT // publish MQTT message if (buttonPublishMqtt && WLED_MQTT_CONNECTED) { char subuf[64]; sprintf_P(subuf, _mqtt_topic_button, mqttDeviceTopic, (int)b); mqtt->publish(subuf, 0, false, "short"); } +#endif } void longPressAction(uint8_t b) @@ -43,12 +45,14 @@ void longPressAction(uint8_t b) applyPreset(macroLongPress[b], CALL_MODE_BUTTON_PRESET); } +#ifndef WLED_DISABLE_MQTT // publish MQTT message if (buttonPublishMqtt && WLED_MQTT_CONNECTED) { char subuf[64]; sprintf_P(subuf, _mqtt_topic_button, mqttDeviceTopic, (int)b); mqtt->publish(subuf, 0, false, "long"); } +#endif } void doublePressAction(uint8_t b) @@ -62,12 +66,14 @@ void doublePressAction(uint8_t b) applyPreset(macroDoublePress[b], CALL_MODE_BUTTON_PRESET); } +#ifndef WLED_DISABLE_MQTT // publish MQTT message if (buttonPublishMqtt && WLED_MQTT_CONNECTED) { char subuf[64]; sprintf_P(subuf, _mqtt_topic_button, mqttDeviceTopic, (int)b); mqtt->publish(subuf, 0, false, "double"); } +#endif } bool isButtonPressed(uint8_t i) @@ -119,6 +125,7 @@ void handleSwitch(uint8_t b) } } +#ifndef WLED_DISABLE_MQTT // publish MQTT message if (buttonPublishMqtt && WLED_MQTT_CONNECTED) { char subuf[64]; @@ -126,6 +133,7 @@ void handleSwitch(uint8_t b) else sprintf_P(subuf, _mqtt_topic_button, mqttDeviceTopic, (int)b); mqtt->publish(subuf, 0, false, !buttonPressedBefore[b] ? "off" : "on"); } +#endif buttonLongPressed[b] = buttonPressedBefore[b]; //save the last "long term" switch state } diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index 45989e58..1f7823a7 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -1,18 +1,17 @@ #ifndef WLED_FCN_DECLARE_H #define WLED_FCN_DECLARE_H -#include -#include "src/dependencies/espalexa/EspalexaDevice.h" -#include "src/dependencies/e131/ESPAsyncE131.h" /* * All globally accessible functions are declared here */ //alexa.cpp +#ifndef WLED_DISABLE_ALEXA void onAlexaChange(EspalexaDevice* dev); void alexaInit(); void handleAlexa(); void onAlexaChange(EspalexaDevice* dev); +#endif //blynk.cpp #ifndef WLED_DISABLE_BLYNK diff --git a/wled00/led.cpp b/wled00/led.cpp index e9e108e4..3c878b35 100644 --- a/wled00/led.cpp +++ b/wled00/led.cpp @@ -180,7 +180,9 @@ void handleTransitions() { //handle still pending interface update if (interfaceUpdateCallMode && millis() - lastInterfaceUpdate > INTERFACE_UPDATE_COOLDOWN) updateInterfaces(interfaceUpdateCallMode); +#ifndef WLED_DISABLE_MQTT if (doPublishMqtt) publishMqtt(); +#endif if (transitionActive && transitionDelayTemp > 0) { diff --git a/wled00/mqtt.cpp b/wled00/mqtt.cpp index 1690341b..eca9fccf 100644 --- a/wled00/mqtt.cpp +++ b/wled00/mqtt.cpp @@ -177,8 +177,4 @@ bool initMqtt() mqtt->connect(); return true; } - -#else -bool initMqtt(){return false;} -void publishMqtt(){} #endif diff --git a/wled00/set.cpp b/wled00/set.cpp index 85ed58ac..ad189f24 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -681,7 +681,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) lastEditTime = millis(); if (subPage != 2 && !doReboot) doSerializeConfig = true; //serializeConfig(); //do not save if factory reset or LED settings (which are saved after LED re-init) + #ifndef WLED_DISABLE_ALEXA if (subPage == 4) alexaInit(); + #endif } diff --git a/wled00/wled.cpp b/wled00/wled.cpp index b78e9f6f..35894055 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -42,7 +42,9 @@ void WLED::loop() #endif handleTime(); + #ifndef WLED_DISABLE_INFRARED handleIR(); // 2nd call to function needed for ESP32 to return valid results -- should be good for ESP8266, too + #endif handleConnection(); handleSerial(); handleNotifications(); @@ -64,7 +66,9 @@ void WLED::loop() yield(); handleIO(); + #ifndef WLED_DISABLE_INFRARED handleIR(); + #endif #ifndef WLED_DISABLE_ALEXA handleAlexa(); #endif @@ -135,7 +139,9 @@ void WLED::loop() } if (millis() - lastMqttReconnectAttempt > 30000 || lastMqttReconnectAttempt == 0) { // lastMqttReconnectAttempt==0 forces immediate broadcast lastMqttReconnectAttempt = millis(); + #ifndef WLED_DISABLE_MQTT initMqtt(); + #endif yield(); // refresh WLED nodes list refreshNodeList(); @@ -414,8 +420,10 @@ void WLED::setup() // fill in unique mdns default if (strcmp(cmDNS, "x") == 0) sprintf_P(cmDNS, PSTR("wled-%*s"), 6, escapedMac.c_str() + 6); +#ifndef WLED_DISABLE_MQTT if (mqttDeviceTopic[0] == 0) sprintf_P(mqttDeviceTopic, PSTR("wled/%*s"), 6, escapedMac.c_str() + 6); if (mqttClientID[0] == 0) sprintf_P(mqttClientID, PSTR("WLED-%*s"), 6, escapedMac.c_str() + 6); +#endif #ifdef WLED_ENABLE_ADALIGHT if (Serial.available() > 0 && Serial.peek() == 'I') handleImprovPacket(); @@ -674,9 +682,11 @@ void WLED::initInterfaces() } #endif +#ifndef WLED_DISABLE_ALEXA // init Alexa hue emulation if (alexaEnabled) alexaInit(); +#endif #ifndef WLED_DISABLE_OTA if (aOtaEnabled) @@ -715,7 +725,9 @@ void WLED::initInterfaces() e131.begin(e131Multicast, e131Port, e131Universe, E131_MAX_UNIVERSE_COUNT); ddp.begin(false, DDP_DEFAULT_PORT); reconnectHue(); +#ifndef WLED_DISABLE_MQTT initMqtt(); +#endif interfacesInited = true; wasConnected = true; } diff --git a/wled00/wled.h b/wled00/wled.h index 66c7cac2..43643bb0 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -121,6 +121,7 @@ #define ESPALEXA_MAXDEVICES 10 // #define ESPALEXA_DEBUG #include "src/dependencies/espalexa/Espalexa.h" + #include "src/dependencies/espalexa/EspalexaDevice.h" #endif #ifndef WLED_DISABLE_BLYNK #include "src/dependencies/blynk/BlynkSimpleEsp.h" @@ -135,7 +136,9 @@ #endif #include "src/dependencies/e131/ESPAsyncE131.h" +#ifdef WLED_ENABLE_MQTT #include "src/dependencies/async-mqtt-client/AsyncMqttClient.h" +#endif #define ARDUINOJSON_DECODE_UNICODE 0 #include "src/dependencies/json/AsyncJson-v6.h" @@ -407,7 +410,12 @@ WLED_GLOBAL bool e131Multicast _INIT(false); // multicast o WLED_GLOBAL bool e131SkipOutOfSequence _INIT(false); // freeze instead of flickering WLED_GLOBAL uint16_t pollReplyCount _INIT(0); // count number of replies for ArtPoll node report +// mqtt +WLED_GLOBAL unsigned long lastMqttReconnectAttempt _INIT(0); // used for other periodic tasks too +#ifndef WLED_DISABLE_MQTT +WLED_GLOBAL AsyncMqttClient *mqtt _INIT(NULL); WLED_GLOBAL bool mqttEnabled _INIT(false); +WLED_GLOBAL char mqttStatusTopic[40] _INIT(""); // this must be global because of async handlers WLED_GLOBAL char mqttDeviceTopic[33] _INIT(""); // main MQTT topic (individual per device, default is wled/mac) WLED_GLOBAL char mqttGroupTopic[33] _INIT("wled/all"); // second MQTT topic (for example to group devices) WLED_GLOBAL char mqttServer[33] _INIT(""); // both domains and IPs should work (no SSL) @@ -415,6 +423,10 @@ WLED_GLOBAL char mqttUser[41] _INIT(""); // optional: username WLED_GLOBAL char mqttPass[65] _INIT(""); // optional: password for MQTT auth WLED_GLOBAL char mqttClientID[41] _INIT(""); // override the client ID WLED_GLOBAL uint16_t mqttPort _INIT(1883); +#define WLED_MQTT_CONNECTED (mqtt != nullptr && mqtt->connected()) +#else +#define WLED_MQTT_CONNECTED false +#endif #ifndef WLED_DISABLE_HUESYNC WLED_GLOBAL bool huePollingEnabled _INIT(false); // poll hue bridge for light state @@ -590,11 +602,8 @@ WLED_GLOBAL uint8_t tpmPacketCount _INIT(0); WLED_GLOBAL uint16_t tpmPayloadFrameSize _INIT(0); WLED_GLOBAL bool useMainSegmentOnly _INIT(false); -// mqtt -WLED_GLOBAL unsigned long lastMqttReconnectAttempt _INIT(0); WLED_GLOBAL unsigned long lastInterfaceUpdate _INIT(0); WLED_GLOBAL byte interfaceUpdateCallMode _INIT(CALL_MODE_INIT); -WLED_GLOBAL char mqttStatusTopic[40] _INIT(""); // this must be global because of async handlers // alexa udp WLED_GLOBAL String escapedMac; @@ -655,8 +664,7 @@ WLED_GLOBAL AsyncWebServer server _INIT_N(((80))); #ifdef WLED_ENABLE_WEBSOCKETS WLED_GLOBAL AsyncWebSocket ws _INIT_N((("/ws"))); #endif -WLED_GLOBAL AsyncClient* hueClient _INIT(NULL); -WLED_GLOBAL AsyncMqttClient* mqtt _INIT(NULL); +WLED_GLOBAL AsyncClient *hueClient _INIT(NULL); WLED_GLOBAL AsyncWebHandler *editHandler _INIT(nullptr); // udp interface objects @@ -766,7 +774,6 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); #define WLED_CONNECTED (WiFi.status() == WL_CONNECTED) #endif #define WLED_WIFI_CONFIGURED (strlen(clientSSID) >= 1 && strcmp(clientSSID, DEFAULT_CLIENT_SSID) != 0) -#define WLED_MQTT_CONNECTED (mqtt != nullptr && mqtt->connected()) #ifndef WLED_AP_SSID_UNIQUE #define WLED_SET_AP_SSID() do { \