diff --git a/src/app.cpp b/src/app.cpp index 5ebae6da..82f5c0b4 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -831,10 +831,10 @@ void app::updateLed(void) { -void app::subscribe(const char *subTopic, uint8_t qos) { - mMqtt.subscribe(subTopic, qos); +void app::subscribeExtern(const char *subTopic, uint8_t qos) { + mMqtt.subscribeExtern(subTopic, qos); } -void app::unsubscribe(const char *subTopic) { - mMqtt.unsubscribe(subTopic); +void app::unsubscribeExtern(const char *subTopic) { + mMqtt.unsubscribeExtern(subTopic); } \ No newline at end of file diff --git a/src/app.h b/src/app.h index 18d656c3..3eb0dd5c 100644 --- a/src/app.h +++ b/src/app.h @@ -360,8 +360,8 @@ class app : public IApp, public ah::Scheduler { } #endif - void subscribe(const char *subTopic, uint8_t qos = QOS_0); - void unsubscribe(const char *subTopic); + void subscribeExtern(const char *subTopic, uint8_t qos = QOS_0); + void unsubscribeExtern(const char *subTopic); private: #define CHECK_AVAIL true diff --git a/src/appInterface.h b/src/appInterface.h index e81580cf..ef728a73 100644 --- a/src/appInterface.h +++ b/src/appInterface.h @@ -74,8 +74,8 @@ class IApp { #endif virtual void* getRadioObj(bool nrf) = 0; - virtual void subscribe(const char *subTopic, uint8_t qos) = 0; - virtual void unsubscribe(const char *subTopic) = 0; + virtual void subscribeExtern(const char *subTopic, uint8_t qos) = 0; + virtual void unsubscribeExtern(const char *subTopic) = 0; }; #endif /*__IAPP_H__*/ diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 0ba32b9a..480834f6 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -251,18 +251,18 @@ class PubMqtt { mClient.subscribe(topic, qos); } - // new - need to unsubscribe the topics. - void unsubscribe(const char *subTopic) - { - mClient.unsubscribe(subTopic); // add as many topics as you like - } - void subscribeExtern(const char *subTopic, uint8_t qos = QOS_0) { char topic[MQTT_TOPIC_LEN + 20]; snprintf(topic, (MQTT_TOPIC_LEN + 20), "%s", subTopic); mClient.subscribe(topic, qos); } + // new - need to unsubscribe the topics. + void unsubscribeExtern(const char *subTopic) + { + mClient.unsubscribe(subTopic); // add as many topics as you like + } + void setConnectionCb(connectionCb cb) { mConnectionCb = cb; } diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 71a8a304..5fabbd4a 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -1207,19 +1207,18 @@ class RestApi { // pm_src const char *neu = jsonIn[F("pm_src")].as(); - if (strncmp(mConfig->plugin.zeroExport.groups[group].pm_src, neu, strlen(neu)) != 0) { + if (strcmp(mConfig->plugin.zeroExport.groups[group].pm_src, neu) != 0) { // unsubscribe if(mConfig->plugin.zeroExport.groups[group].pm_type == zeroExportPowermeterType_t::Mqtt) { - mApp->unsubscribe(mConfig->plugin.zeroExport.groups[group].pm_src); - + mApp->unsubscribeExtern(mConfig->plugin.zeroExport.groups[group].pm_src); } // save snprintf(mConfig->plugin.zeroExport.groups[group].pm_src, ZEROEXPORT_GROUP_MAX_LEN_PM_SRC, "%s", jsonIn[F("pm_src")].as()); // subsrcribe if(mConfig->plugin.zeroExport.groups[group].pm_type == zeroExportPowermeterType_t::Mqtt) { - mApp->subscribe(mConfig->plugin.zeroExport.groups[group].pm_src, QOS_2); + mApp->subscribeExtern(mConfig->plugin.zeroExport.groups[group].pm_src, QOS_2); } } @@ -1252,7 +1251,7 @@ class RestApi { if(mConfig->plugin.zeroExport.groups[group].pm_type == zeroExportBatteryCfg::mqttSoC || mConfig->plugin.zeroExport.groups[group].pm_type == zeroExportBatteryCfg::mqttU ) { - mApp->unsubscribe(mConfig->plugin.zeroExport.groups[group].battTopic); + mApp->unsubscribeExtern(mConfig->plugin.zeroExport.groups[group].battTopic); } // save @@ -1261,7 +1260,7 @@ class RestApi { if(mConfig->plugin.zeroExport.groups[group].pm_type == zeroExportBatteryCfg::mqttSoC || mConfig->plugin.zeroExport.groups[group].pm_type == zeroExportBatteryCfg::mqttU) { - mApp->subscribe(mConfig->plugin.zeroExport.groups[group].battTopic, QOS_2); + mApp->subscribeExtern(mConfig->plugin.zeroExport.groups[group].battTopic, QOS_2); } }