set subscribed flag

This commit is contained in:
2018-11-16 01:16:50 +01:00
parent 0a5bfc8cf9
commit cbba58095c

View File

@@ -35,18 +35,19 @@ void MqttPlugin::connect()
if (client->connect(mqttConfig.clientName))
{
// bind handlers to all local subscriptions
if (!locallySubscribed)
{
for (auto const &localSub : mediator->subscriptions)
{
// bind all local topics to the MQTT upstream once
if (!locallySubscribed)
{
subscribe(localSub.first.c_str(), bind(&MqttPlugin::upstreamHandler, this, localSub.first.c_str(), _1));
}
// subscribe topic on remote queue to dispatch messages to local subscriptions
client->subscribe(
(String(mqttConfig.inTopicRoot) + String(localSub.first.c_str()))
.c_str());
}
locallySubscribed = true;
}
PRINT_MSG(Serial, "MQTT", "connected");
}
}