Actually use username and password when connecting to MQTT broker (see #2)
This commit is contained in:
@ -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 "<Your User>"
|
||||
|
||||
// The password to use to connect to the MQTT broker.
|
||||
// Set this to NULL if no password is required.
|
||||
#define MQTT_PASSWORD "<Your Password>"
|
||||
|
||||
// The root topic used for communicating with this controller.
|
||||
|
2
mqtt.cpp
2
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);
|
||||
|
Reference in New Issue
Block a user