Change mqtt client name

This commit is contained in:
Dirk Jahnke 2021-02-02 15:49:15 +01:00
parent 83fc1e357f
commit d6b84bae70
1 changed files with 4 additions and 3 deletions

View File

@ -37,6 +37,7 @@
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xEA };
IPAddress ip(192, 168, 89, 205);
IPAddress mqttServerIP(192, 168, 89, 95);
const char *mqttUser = "default";
const char *mqttPassword = "12345678";
@ -204,19 +205,19 @@ void reconnect() {
while (!mqttClient.connected()) {
Serial.print(F("Attempting MQTT connection..."));
// Attempt to connect
if (mqttClient.connect("doorBellGateway", mqttUser, mqttPassword, lwtTopic, lwtQos, lwtRetain, lwtMessage)) {
if (mqttClient.connect("doorBellGW", mqttUser, mqttPassword, lwtTopic, lwtQos, lwtRetain, lwtMessage)) {
Serial.println(F("connected"));
// Once connected, publish an announcement...
mqttClient.publish_P(lwtTopic, onlineMessage, lwtRetain);
// mqttClient.publish("hello","hello world");
// ... and resubscribe
Serial.println(F("MQTT subscribe doorbell"));
if (!mqttClient.subscribe("doorbell")) {
if (!mqttClient.subscribe("doorBellGW", 1)) {
Serial.println(F("ERROR: Failed to subscribe"));
}
for (unsigned int i=0; i<NUM_OUTPUTS; ++i) {
Serial.print(F("MQTT subscribe ")); Serial.println(myOutputs[i].listenTopic);
if (!mqttClient.subscribe(myOutputs[i].listenTopic)) {
if (!mqttClient.subscribe(myOutputs[i].listenTopic, 1)) {
Serial.println(F("ERROR: Failed to subscribe"));
}
}