mirror of
https://gitlab.com/wirelos/sprocket-plugin-mqtt.git
synced 2025-12-15 22:18:20 +01:00
add json config
This commit is contained in:
@@ -2,7 +2,12 @@
|
||||
|
||||
MqttPlugin::MqttPlugin(MqttConfig cfg)
|
||||
{
|
||||
mqttConfig = cfg;
|
||||
mqttConfig.brokerHost = cfg.brokerHost;
|
||||
mqttConfig.brokerPort = cfg.brokerPort;
|
||||
mqttConfig.clientName = cfg.clientName;
|
||||
mqttConfig.inTopicRoot = cfg.inTopicRoot;
|
||||
mqttConfig.outTopicRoot = cfg.outTopicRoot;
|
||||
mqttConfig.fromFile("/mqttConfig.json");
|
||||
}
|
||||
|
||||
void MqttPlugin::activate(Scheduler *scheduler)
|
||||
@@ -35,7 +40,7 @@ void MqttPlugin::connect()
|
||||
if (client->connect(mqttConfig.clientName))
|
||||
{
|
||||
// bind handlers to all local subscriptions
|
||||
if (!locallySubscribed)
|
||||
if (!subscribed)
|
||||
{
|
||||
for (auto const &localSub : mediator->subscriptions)
|
||||
{
|
||||
@@ -46,7 +51,7 @@ void MqttPlugin::connect()
|
||||
(String(mqttConfig.inTopicRoot) + String(localSub.first.c_str()))
|
||||
.c_str());
|
||||
}
|
||||
locallySubscribed = true;
|
||||
subscribed = true;
|
||||
}
|
||||
PRINT_MSG(Serial, "MQTT", "connected");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user