diff --git a/src/modules/exec/BrokerMQTT/BrokerMQTT.cpp b/src/modules/exec/BrokerMQTT/BrokerMQTT.cpp index 1523d0c0..6176b3ee 100644 --- a/src/modules/exec/BrokerMQTT/BrokerMQTT.cpp +++ b/src/modules/exec/BrokerMQTT/BrokerMQTT.cpp @@ -7,12 +7,13 @@ namespace _Broker { #define DEF_PORT 1883 +bool _global_debug = false; // MqttBroker broker(1883); class myPicoMQTT : public PicoMQTT::Server { private: - bool _debug; + //bool _debug; String _user; String _pass; @@ -27,15 +28,15 @@ namespace _Broker _pass = pass; } - void setDebug(bool debug) +/* void setDebug(bool debug) { _debug = debug; } - + */ protected: void on_connected(const char *client_id) { - if (_debug) + if (_Broker::_global_debug) { Serial.print("[BrokerMQTT], Client connected: "); Serial.println(client_id); @@ -43,7 +44,7 @@ namespace _Broker } void on_disconnected(const char *client_id) { - if (_debug) + if (_Broker::_global_debug) { // SerialPrint("i", "BrokerMQTT", "Client disconnected: " + client_id); @@ -53,7 +54,7 @@ namespace _Broker } void on_subscribe(const char *client_id, const char *topic) { - if (_debug) + if (_Broker::_global_debug) { // SerialPrint("i", "BrokerMQTT", "Client " + client_id + ", subscribe: " + topic); @@ -65,7 +66,7 @@ namespace _Broker } void on_unsubscribe(const char *client_id, const char *topic) { - if (_debug) + if (_Broker::_global_debug) { // SerialPrint("i", "BrokerMQTT", "Client " + client_id + ", unsubscribe: " + topic); @@ -163,7 +164,8 @@ namespace _Broker _port = DEF_PORT; picoMqtt = new myPicoMQTT(_port); picoMqtt->begin(); - picoMqtt->setDebug(_debug); + //picoMqtt->setDebug(_debug); + _global_debug = _debug; picoMqtt->setAuth(_user, _pass); if (_brige) { @@ -182,12 +184,12 @@ namespace _Broker { picoMqtt->subscribe("#", [](const char *topic, const char *message) { clientMqtt->publish(topic, message); - if (_debug) + if (_Broker::_global_debug) SerialPrint("i", F("BrigeMQTT"), "Client publish, topic: " + String(topic) + " msg: " + String(message) ); }); clientMqtt->subscribe("#", [](const char *topic, const char *message) { picoMqtt->publish(topic, message); - if (_debug) + if (_Broker::_global_debug) SerialPrint("i", F("BrigeMQTT"), "Server publish, topic: " + String(topic) + " msg: " + String(message) ); }); } // picoMqtt.begin();