mirror of
https://gitlab.com/wirelos/sprocket-plugin-mqtt.git
synced 2025-12-14 21:52:21 +01:00
set subscribed flag
This commit is contained in:
@@ -35,17 +35,18 @@ void MqttPlugin::connect()
|
|||||||
if (client->connect(mqttConfig.clientName))
|
if (client->connect(mqttConfig.clientName))
|
||||||
{
|
{
|
||||||
// bind handlers to all local subscriptions
|
// bind handlers to all local subscriptions
|
||||||
for (auto const &localSub : mediator->subscriptions)
|
if (!locallySubscribed)
|
||||||
{
|
{
|
||||||
// bind all local topics to the MQTT upstream once
|
for (auto const &localSub : mediator->subscriptions)
|
||||||
if (!locallySubscribed)
|
|
||||||
{
|
{
|
||||||
|
// bind all local topics to the MQTT upstream once
|
||||||
subscribe(localSub.first.c_str(), bind(&MqttPlugin::upstreamHandler, this, localSub.first.c_str(), _1));
|
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());
|
||||||
}
|
}
|
||||||
// subscribe topic on remote queue to dispatch messages to local subscriptions
|
locallySubscribed = true;
|
||||||
client->subscribe(
|
|
||||||
(String(mqttConfig.inTopicRoot) + String(localSub.first.c_str()))
|
|
||||||
.c_str());
|
|
||||||
}
|
}
|
||||||
PRINT_MSG(Serial, "MQTT", "connected");
|
PRINT_MSG(Serial, "MQTT", "connected");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user