mirror of
https://gitlab.com/wirelos/sprocket-plugin-mqtt.git
synced 2025-12-18 07:16:39 +01:00
Add user and pass
This commit is contained in:
8
src/MqttConfig.h
Normal file → Executable file
8
src/MqttConfig.h
Normal file → Executable file
@@ -7,6 +7,8 @@
|
||||
#define JSON_MQTT_BROKER_HOST "mqttBrokerHost"
|
||||
#define JSON_MQTT_BROKER_PORT "mqttBrokerPort"
|
||||
#define JSON_MQTT_TOPIC_ROOT "mqttRootTopic"
|
||||
#define JSON_MQTT_USER "mqttUser"
|
||||
#define JSON_MQTT_PASS "mqttPass"
|
||||
|
||||
struct MqttConfig
|
||||
{
|
||||
@@ -14,6 +16,8 @@ struct MqttConfig
|
||||
const char *brokerHost;
|
||||
int brokerPort;
|
||||
const char *topicRoot;
|
||||
const char *user;
|
||||
const char *pass;
|
||||
};
|
||||
|
||||
struct MqttConfigJson : public MqttConfig, public JsonStruct
|
||||
@@ -24,6 +28,8 @@ struct MqttConfigJson : public MqttConfig, public JsonStruct
|
||||
root[JSON_MQTT_BROKER_HOST] = brokerHost;
|
||||
root[JSON_MQTT_BROKER_PORT] = brokerPort;
|
||||
root[JSON_MQTT_TOPIC_ROOT] = topicRoot;
|
||||
root[JSON_MQTT_USER] = user;
|
||||
root[JSON_MQTT_PASS] = pass;
|
||||
}
|
||||
void fromJsonObject(JsonObject &json)
|
||||
{
|
||||
@@ -37,6 +43,8 @@ struct MqttConfigJson : public MqttConfig, public JsonStruct
|
||||
brokerHost = getAttr(json, JSON_MQTT_BROKER_HOST);
|
||||
brokerPort = getIntAttrFromJson(json, JSON_MQTT_BROKER_PORT);
|
||||
topicRoot = getAttr(json, JSON_MQTT_TOPIC_ROOT);
|
||||
user = getAttr(json, JSON_MQTT_USER);
|
||||
pass = getAttr(json, JSON_MQTT_PASS);
|
||||
valid = 1;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user