diff --git a/config-example.h b/config-example.h index d27f89e..759bf22 100644 --- a/config-example.h +++ b/config-example.h @@ -31,9 +31,11 @@ #define MQTT_PORT 1883 // The user to use to connect to the MQTT broker. +// Set this to NULL if no user is required. #define MQTT_USER "" // The password to use to connect to the MQTT broker. +// Set this to NULL if no password is required. #define MQTT_PASSWORD "" // The root topic used for communicating with this controller. diff --git a/mqtt.cpp b/mqtt.cpp index e65db8c..e206801 100644 --- a/mqtt.cpp +++ b/mqtt.cpp @@ -111,7 +111,7 @@ void MQTT::setupMqtt() { Serial.println("[MQTT] Connecting to MQTT broker..."); uint retries = 0; - if (this->client->connect(this->clientId.c_str(), String(this->mqttRootTopic + "/" + this->clientId + "/availability").c_str(), 1, true, "offline")) + if (this->client->connect(this->clientId.c_str(), this->mqttUser, this->mqttPassword, String(this->mqttRootTopic + "/" + this->clientId + "/availability").c_str(), 1, true, "offline")) { Serial.println("[MQTT] connected!"); this->client->publish(String(this->mqttRootTopic + "/" + this->clientId + "/availability").c_str(), "online", true);