Actually use username and password when connecting to MQTT broker (see #2)

This commit is contained in:
Erik Borowski
2024-11-30 22:19:25 +01:00
parent 0071af40a6
commit a0b246aae1
2 changed files with 3 additions and 1 deletions

View File

@ -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);