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

View File

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