Change mqtt client name
This commit is contained in:
parent
83fc1e357f
commit
d6b84bae70
|
@ -37,6 +37,7 @@
|
||||||
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xEA };
|
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xEA };
|
||||||
IPAddress ip(192, 168, 89, 205);
|
IPAddress ip(192, 168, 89, 205);
|
||||||
IPAddress mqttServerIP(192, 168, 89, 95);
|
IPAddress mqttServerIP(192, 168, 89, 95);
|
||||||
|
|
||||||
const char *mqttUser = "default";
|
const char *mqttUser = "default";
|
||||||
const char *mqttPassword = "12345678";
|
const char *mqttPassword = "12345678";
|
||||||
|
|
||||||
|
@ -204,19 +205,19 @@ void reconnect() {
|
||||||
while (!mqttClient.connected()) {
|
while (!mqttClient.connected()) {
|
||||||
Serial.print(F("Attempting MQTT connection..."));
|
Serial.print(F("Attempting MQTT connection..."));
|
||||||
// Attempt to connect
|
// 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"));
|
Serial.println(F("connected"));
|
||||||
// Once connected, publish an announcement...
|
// Once connected, publish an announcement...
|
||||||
mqttClient.publish_P(lwtTopic, onlineMessage, lwtRetain);
|
mqttClient.publish_P(lwtTopic, onlineMessage, lwtRetain);
|
||||||
// mqttClient.publish("hello","hello world");
|
// mqttClient.publish("hello","hello world");
|
||||||
// ... and resubscribe
|
// ... and resubscribe
|
||||||
Serial.println(F("MQTT subscribe doorbell"));
|
Serial.println(F("MQTT subscribe doorbell"));
|
||||||
if (!mqttClient.subscribe("doorbell")) {
|
if (!mqttClient.subscribe("doorBellGW", 1)) {
|
||||||
Serial.println(F("ERROR: Failed to subscribe"));
|
Serial.println(F("ERROR: Failed to subscribe"));
|
||||||
}
|
}
|
||||||
for (unsigned int i=0; i<NUM_OUTPUTS; ++i) {
|
for (unsigned int i=0; i<NUM_OUTPUTS; ++i) {
|
||||||
Serial.print(F("MQTT subscribe ")); Serial.println(myOutputs[i].listenTopic);
|
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"));
|
Serial.println(F("ERROR: Failed to subscribe"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue