Supports multiple subscriptions

This commit is contained in:
hsaturn
2021-03-23 23:51:33 +01:00
parent efe6a05bbd
commit 7b20e7deb5
6 changed files with 73 additions and 29 deletions

View File

@@ -225,6 +225,8 @@ void loop()
last_cmd=cmd;
while(cmd.length())
{
MqttError retval = MqttOk;
std::string s;
MqttBroker* broker = nullptr;
MqttClient* client = nullptr;
@@ -314,11 +316,7 @@ void loop()
}
else if (compare(s,"publish"))
{
auto ok=client->publish(getword(cmd, topic.c_str()));
if (ok != MqttOk)
{
Serial << "## ERROR " << ok << endl;
}
retval = client->publish(getword(cmd, topic.c_str()));
}
else if (compare(s,"subscribe"))
{
@@ -431,6 +429,11 @@ void loop()
if (s.length())
Serial << "Unknown command (" << s.c_str() << ")" << endl;
}
if (retval != MqttOk)
{
Serial << "## ERROR " << retval << endl;
}
}
}
else