diff --git a/libraries/MySensors/examples/MQTTClientGateway/MQTTClientGateway.ino b/libraries/MySensors/examples/MQTTClientGateway/MQTTClientGateway.ino index a436889..a1c07c9 100644 --- a/libraries/MySensors/examples/MQTTClientGateway/MQTTClientGateway.ino +++ b/libraries/MySensors/examples/MQTTClientGateway/MQTTClientGateway.ino @@ -205,13 +205,19 @@ void loop() { if (!client.connected()) { + boolean ret; #ifdef MQTT_AUTH_REQUIRED strcpy(user, MQTT_USER); strcpy(pwd, MQTT_PWD); - client.connect(connID, user,pwd); + ret = client.connect(connID, user,pwd); #else - client.connect(connID); + ret = client.connect(connID); #endif + if (ret) { + Serial.println("Connected to MQTT broker"); + } else { + Serial.println("Connection to MQTT broker failed"); + } client.subscribe(mqttTopicMask); } client.loop(); diff --git a/libraries/MySensors/examples/MQTTClientGateway/MyMQTTClient.h b/libraries/MySensors/examples/MQTTClientGateway/MyMQTTClient.h index 87610f0..d347825 100644 --- a/libraries/MySensors/examples/MQTTClientGateway/MyMQTTClient.h +++ b/libraries/MySensors/examples/MQTTClientGateway/MyMQTTClient.h @@ -29,8 +29,8 @@ version 2 as published by the Free Software Foundation. #define MQTT_AUTH_REQUIRED // if your broker has anonymous access uncomment -#define MQTT_USER "username" // username on MQTT broker -#define MQTT_PWD "pwd" // password for MQTT username above +#define MQTT_USER "user" // username on MQTT broker +#define MQTT_PWD "pwd" // password for MQTT username above #define MQTT_CONN_ID "MySensors" // passed as id to the MQTT broker