From 47bc06f0ce6acfaa0e8ddecba0b226b3bc3f825e Mon Sep 17 00:00:00 2001 From: hsaturn Date: Mon, 22 Mar 2021 02:43:41 +0100 Subject: [PATCH] removed need of Streaming.h if no debug --- examples/tinymqtt-test/tinymqtt-test.ino | 2 +- src/TinyMqtt.cpp | 6 ------ src/TinyMqtt.h | 12 +++++++++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/tinymqtt-test/tinymqtt-test.ino b/examples/tinymqtt-test/tinymqtt-test.ino index 6e6fd10..7e5c060 100644 --- a/examples/tinymqtt-test/tinymqtt-test.ino +++ b/examples/tinymqtt-test/tinymqtt-test.ino @@ -1,3 +1,4 @@ +#define TINY_MQTT_DEBUG #include // https://github.com/hsaturn/TinyMqtt #include // https://github.com/janelia-arduino/Streaming #include @@ -360,7 +361,6 @@ void loop() std::string id=getword(cmd); if (id.length() or clients.find(id)!=clients.end()) { - s=getword(cmd); // broker name if (s=="" or brokers.find(s) != brokers.end()) { diff --git a/src/TinyMqtt.cpp b/src/TinyMqtt.cpp index 99505ae..8e56729 100644 --- a/src/TinyMqtt.cpp +++ b/src/TinyMqtt.cpp @@ -2,12 +2,6 @@ #include #include -#if TINY_MQTT_DEBUG -#define debug(what) { Serial << __LINE__ << ' ' << what << endl; delay(100); } -#else -#define debug(what) {} -#endif - void outstring(const char* prefix, const char*p, uint16_t len) { return; diff --git a/src/TinyMqtt.h b/src/TinyMqtt.h index d70ac8e..190d1d1 100644 --- a/src/TinyMqtt.h +++ b/src/TinyMqtt.h @@ -4,8 +4,11 @@ #include #include "StringIndexer.h" -#ifndef TINY_MQTT_DEBUG -#define TINY_MQTT_DEBUG 0 +#ifdef TINY_MQTT_DEBUG + #include + #define debug(what) { Serial << __LINE__ << ' ' << what << endl; delay(100); } +#else + #define debug(what) {} #endif enum MqttError @@ -145,6 +148,7 @@ class MqttClient // TODO seems to be useless bool isLocal() const { return client == nullptr; } +#ifdef TINY_MQTT_DEBUG void dump() { Serial << "MqttClient (" << clientId.c_str() << ") p=" << (int32_t) parent @@ -158,7 +162,7 @@ class MqttClient } Serial << "]" << endl; } - +#endif private: friend class MqttBroker; @@ -207,6 +211,7 @@ class MqttBroker void connect(std::string host, uint32_t port=1883); bool connected() const { return state == Connected; } +#ifdef TINY_MQTT_DEBUG void dump() { Serial << clients.size() << " client/s" << endl; @@ -216,6 +221,7 @@ class MqttBroker client->dump(); } } +#endif private: friend class MqttClient;