diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp index 9362e10..b6f2a8f 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp @@ -41,16 +41,21 @@ void ESPMegaIoT::mqttCallback(char *topic, byte *payload, unsigned int length) // Create a null terminated string from the payload memcpy(payload_buffer, payload, length); payload_buffer[length] = '\0'; + // If the topic is not appended with the base topic, call only the absolute callbacks + if (strncmp(topic, this->mqtt_config.base_topic, base_topic_length) != 0) + { + for (const auto &callback : mqtt_callbacks) + { + callback.second(topic, payload_buffer); + } + return; + } // Remove the base topic from the topic char *topic_without_base = topic + strlen(this->mqtt_config.base_topic) + 1; for (const auto &callback : mqtt_relative_callbacks) { callback.second(topic_without_base, payload_buffer); } - for (const auto &callback : mqtt_callbacks) - { - callback.second(topic, payload_buffer); - } // Call the respective card's mqtt callback // Note that after the base topic, there should be the card id // /base_topic/card_id/... diff --git a/ESPMegaPRO-OS-SDK/src/main.cpp b/ESPMegaPRO-OS-SDK/src/main.cpp index 957ec89..c154233 100644 --- a/ESPMegaPRO-OS-SDK/src/main.cpp +++ b/ESPMegaPRO-OS-SDK/src/main.cpp @@ -9,9 +9,9 @@ // #define FRAM_DEBUG // #define MQTT_DEBUG -#define WRITE_DEFAULT_NETCONF -#define CLIMATE_CARD_ENABLE -#define MQTT_CARD_REGISTER +// #define WRITE_DEFAULT_NETCONF +//#define CLIMATE_CARD_ENABLE +//#define MQTT_CARD_REGISTER #define DISPLAY_ENABLE #define WEB_SERVER_ENABLE #define LCD_OTA_ENABLE @@ -199,8 +199,10 @@ void setup() ESP_LOGI("Initializer", "Enabling internal display"); espmega.enableInternalDisplay(&Serial); ESP_LOGI("Initializer", "Binding climate card to internal display"); +#ifdef CLIMATE_CARD_ENABLE espmega.display->bindClimateCard(&climateCard); #endif +#endif #ifdef WEB_SERVER_ENABLE ESP_LOGI("Initializer", "Enabling web server"); espmega.enableWebServer(80); @@ -213,8 +215,8 @@ void setup() #endif #ifdef REMOTE_VARIABLE_ENABLE ESP_LOGI("Initializer", "Initializing testvar"); - testVar.begin(32, "/testvar", espmega.iot, true,"/testvar/request"); - testVar.enableSetValue("/testvar/set"); + testVar.begin(32, "/xm/fan_speed", espmega.iot, true,"/pm/request_fan_speed"); + testVar.enableSetValue("/pm/request_switch_state"); #endif #ifdef CT_ENABLE ESP_LOGI("Initializer", "Initializing analog card");