mirror of
https://gitlab.com/wirelos/sprocket-plugin-mqtt.git
synced 2025-12-15 22:18:20 +01:00
documentation
This commit is contained in:
@@ -22,16 +22,11 @@ void MqttPlugin::enableConnectTask(Scheduler *scheduler)
|
||||
|
||||
void MqttPlugin::enableProcessTask(Scheduler *scheduler)
|
||||
{
|
||||
processTask.set(TASK_MILLISECOND * 5, TASK_FOREVER, bind(&MqttPlugin::process, this));
|
||||
processTask.set(TASK_MILLISECOND * 5, TASK_FOREVER, bind(&PubSubClient::loop, client));
|
||||
scheduler->addTask(processTask);
|
||||
processTask.enable();
|
||||
}
|
||||
|
||||
void MqttPlugin::process()
|
||||
{
|
||||
client->loop();
|
||||
}
|
||||
|
||||
void MqttPlugin::connect()
|
||||
{
|
||||
if (!client->connected())
|
||||
@@ -42,8 +37,11 @@ void MqttPlugin::connect()
|
||||
// bind handlers to all local subscriptions
|
||||
for (auto const &localSub : mediator->subscriptions)
|
||||
{
|
||||
// bind all local topics to the MQTT upstream
|
||||
subscribe(localSub.first.c_str(), bind(&MqttPlugin::upstreamHandler, this, localSub.first.c_str(), _1));
|
||||
// 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()))
|
||||
@@ -54,11 +52,6 @@ void MqttPlugin::connect()
|
||||
}
|
||||
}
|
||||
|
||||
void MqttPlugin::mqttPublish(String msg)
|
||||
{
|
||||
client->publish(mqttConfig.outTopicRoot, msg.c_str());
|
||||
}
|
||||
|
||||
void MqttPlugin::upstreamHandler(String topic, String msg)
|
||||
{
|
||||
// publish message on remote queue
|
||||
|
||||
Reference in New Issue
Block a user