removed need of Streaming.h if no debug
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
#define TINY_MQTT_DEBUG
|
||||||
#include <TinyMqtt.h> // https://github.com/hsaturn/TinyMqtt
|
#include <TinyMqtt.h> // https://github.com/hsaturn/TinyMqtt
|
||||||
#include <Streaming.h> // https://github.com/janelia-arduino/Streaming
|
#include <Streaming.h> // https://github.com/janelia-arduino/Streaming
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -360,7 +361,6 @@ void loop()
|
|||||||
std::string id=getword(cmd);
|
std::string id=getword(cmd);
|
||||||
if (id.length() or clients.find(id)!=clients.end())
|
if (id.length() or clients.find(id)!=clients.end())
|
||||||
{
|
{
|
||||||
|
|
||||||
s=getword(cmd); // broker name
|
s=getword(cmd); // broker name
|
||||||
if (s=="" or brokers.find(s) != brokers.end())
|
if (s=="" or brokers.find(s) != brokers.end())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,12 +2,6 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Streaming.h>
|
#include <Streaming.h>
|
||||||
|
|
||||||
#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)
|
void outstring(const char* prefix, const char*p, uint16_t len)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -4,8 +4,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "StringIndexer.h"
|
#include "StringIndexer.h"
|
||||||
|
|
||||||
#ifndef TINY_MQTT_DEBUG
|
#ifdef TINY_MQTT_DEBUG
|
||||||
#define TINY_MQTT_DEBUG 0
|
#include <Streaming.h>
|
||||||
|
#define debug(what) { Serial << __LINE__ << ' ' << what << endl; delay(100); }
|
||||||
|
#else
|
||||||
|
#define debug(what) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum MqttError
|
enum MqttError
|
||||||
@@ -145,6 +148,7 @@ class MqttClient
|
|||||||
// TODO seems to be useless
|
// TODO seems to be useless
|
||||||
bool isLocal() const { return client == nullptr; }
|
bool isLocal() const { return client == nullptr; }
|
||||||
|
|
||||||
|
#ifdef TINY_MQTT_DEBUG
|
||||||
void dump()
|
void dump()
|
||||||
{
|
{
|
||||||
Serial << "MqttClient (" << clientId.c_str() << ") p=" << (int32_t) parent
|
Serial << "MqttClient (" << clientId.c_str() << ") p=" << (int32_t) parent
|
||||||
@@ -158,7 +162,7 @@ class MqttClient
|
|||||||
}
|
}
|
||||||
Serial << "]" << endl;
|
Serial << "]" << endl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class MqttBroker;
|
friend class MqttBroker;
|
||||||
@@ -207,6 +211,7 @@ class MqttBroker
|
|||||||
void connect(std::string host, uint32_t port=1883);
|
void connect(std::string host, uint32_t port=1883);
|
||||||
bool connected() const { return state == Connected; }
|
bool connected() const { return state == Connected; }
|
||||||
|
|
||||||
|
#ifdef TINY_MQTT_DEBUG
|
||||||
void dump()
|
void dump()
|
||||||
{
|
{
|
||||||
Serial << clients.size() << " client/s" << endl;
|
Serial << clients.size() << " client/s" << endl;
|
||||||
@@ -216,6 +221,7 @@ class MqttBroker
|
|||||||
client->dump();
|
client->dump();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class MqttClient;
|
friend class MqttClient;
|
||||||
|
|||||||
Reference in New Issue
Block a user