Fix build in Esp8266 mode

Modify dump() functions
This commit is contained in:
hsaturn
2021-04-28 18:51:01 +02:00
parent 20292b7b7b
commit e00e31de33
2 changed files with 19 additions and 22 deletions

View File

@@ -7,7 +7,6 @@
#else
#error Unsupported platform
#endif
#include <ESPmDNS.h>
#include <sstream>
#include <map>
@@ -630,14 +629,14 @@ void eval(std::string& cmd)
Serial << "--< " << clients.size() << " client/s. >--" << endl;
for(auto it: clients)
{
Serial << " "; it.second->dump();
it.second->dump(" ");
}
Serial << "--< " << brokers.size() << " brokers/s. >--" << endl;
for(auto it: brokers)
{
Serial << " ==[ Broker: " << it.first.c_str() << " ]== ";
it.second->dump();
Serial << " +-- '" << it.first.c_str() << "' " << it.second->clientsCount() << " client/s."<< endl;
it.second->dump(" ");
}
}
else if (compare(s, "reset"))

View File

@@ -189,23 +189,25 @@ class MqttClient
// TODO seems to be useless
bool isLocal() const { return client == nullptr; }
void dump()
void dump(std::string indent="")
{
uint32_t ms=millis();
Serial << "MqttClient (" << clientId.c_str() << ") " << (connected() ? " ON " : " OFF");
Serial << ", alive=" << alive << '/' << ms << ", ka=" << keep_alive;
Serial << indent << "+-- " << '\'' << clientId.c_str() << "' " << (connected() ? " ON " : " OFF");
Serial << ", alive=" << alive << '/' << ms << ", ka=" << keep_alive << ' ';
Serial << (client && client->connected() ? "" : "dis") << "connected";
message.hexdump("entrant msg");
bool c=false;
if (subscriptions.size())
{
bool c = false;
Serial << " [";
for(auto s: subscriptions)
{
Serial << (c?", ": "")<< s.str().c_str();
if (c) Serial << ", ";
Serial << s.str().c_str();
c=true;
}
Serial << "]" << endl;
Serial << ']';
}
Serial << endl;
}
/** Count the number of messages that have been sent **/
@@ -265,14 +267,10 @@ class MqttBroker
size_t clientsCount() const { return clients.size(); }
void dump()
void dump(std::string indent="")
{
Serial << clients.size() << " client/s" << endl;
for(auto client: clients)
{
Serial << " ";
client->dump();
}
client->dump(indent);
}
private: