MQTT broker with username and password
cellerich opened this issue · comments
Hi,
First of all, thanks a lot for this project. I was about to put together something similar with the help of some GitHub Repos out there. But this project fulfills all my needs!
However I am using a MQTT broker which needs a username and password to connect to.
It was very easy to implement this, that's why I like to share it here. I'm not so fluent with Git push/pull/change requests and such, therefore I just document the changes I made here:
extend config.h
with two lines:
// MQTT Broker
#define MQTT_HOST "x.x.x.x"
#define MQTT_PORT 1883
#define MQTT_USER "mqtt username"
#define MQTT_PASSWORD "mqtt password"
add the line under mqttClient.setServer...
in mqtt.cpp
- line 415
mqttClient.setClientId(HOSTNAME);
mqttClient.setServer(MQTT_HOST, MQTT_PORT);
mqttClient.setCredentials(MQTT_USER, MQTT_PASSWORD);
Maybe you are able (and willing) to put it into the code base.
Thanks for the suggested. I added this option.