Add user and pass

This commit is contained in:
Partick Balsiger
2019-04-07 17:17:44 +02:00
parent 7363e03b74
commit e58e7b3727
25 changed files with 35 additions and 6 deletions

8
src/MqttConfig.h Normal file → Executable file
View 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;
};
};