1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-27 01:56:14 +01:00
This commit is contained in:
Gregor Baues 2021-05-03 09:18:53 +02:00
parent 851228fba6
commit 866833a19e

View File

@ -89,32 +89,30 @@ void DccMQTT::connect()
int reconnectCount = 0; int reconnectCount = 0;
// if(broker->prefix != nullptr) { if(broker->prefix != nullptr) {
// char tmp[20]; char tmp[20];
// strcpy_P(tmp, (const char *)broker->prefix); strcpy_P(tmp, (const char *)broker->prefix);
// Serial.println(tmp); connectID[0] = '\0';
// Serial.println(broker->prefix); strcat(connectID, tmp);
// connectID[0] = '\0'; }
// strcat(connectID, tmp);
// }
strcat(connectID, clientID); strcat(connectID, clientID);
DIAG(F("MQTT %s (re)connecting ..."), connectID); DIAG(F("MQTT %s (re)connecting ..."), connectID);
// Build the connect ID : Prefix + clientID // Build the connect ID : Prefix + clientID
while (!mqttClient.connected() && reconnectCount < MAXRECONNECT) while (!mqttClient.connected() && reconnectCount < MAXRECONNECT)
{ {
DIAG(F("Attempting MQTT Broker connection[%d]..."), broker->cType); DIAG(F("Attempting MQTT Broker connection[%d]..."), broker->cType);
switch (broker->cType) switch (broker->cType)
{ {
// no uid no pwd
case 6: case 6:
case 1: case 1:
{ // port(p), ip(i), domain(d), { // port(p), ip(i), domain(d),
if (mqttClient.connect(connectID)) if (mqttClient.connect(connectID))
{ {
DIAG(F("MQTT broker connected ...")); DIAG(F("MQTT Broker connected ..."));
} }
else else
{ {
@ -123,30 +121,23 @@ void DccMQTT::connect()
} }
break; break;
} }
// with uid passwd
case 5:
case 2: case 2:
{ // port(p), ip(i), domain(d), user(uid), pwd(pass), { // port(p), ip(i), domain(d), user(uid), pwd(pass),
break; break;
} }
// with uid, passwd & prefix
case 4:
case 3: case 3:
{ // port(p), ip(i), domain(d), user(uid), pwd(pass), prefix(pfix) { // port(p), ip(i), domain(d), user(uid), pwd(pass), prefix(pfix)
// port(p), domain(d), user(uid), pwd(pass), prefix(pfix)
// mqttClient.connect(connectID, MQTT_BROKER_USER, MQTT_BROKER_PASSWD, "$connected", 0, true, "0", 0)) // mqttClient.connect(connectID, MQTT_BROKER_USER, MQTT_BROKER_PASSWD, "$connected", 0, true, "0", 0))
break; break;
} }
case 4:
{ // port(p), domain(d), user(uid), pwd(pass), prefix(pfix)
break;
} }
case 5: if (reconnectCount == MAXRECONNECT)
{ // port(p), domain(d), user(uid), pwd(pass) {
break;
}
// case 6:
// { // port(p), domain(d)
// mqttClient.connect()
// break;
// }
}
if (reconnectCount == MAXRECONNECT) {
DIAG(F("MQTT Connection aborted after %d tries"), MAXRECONNECT); DIAG(F("MQTT Connection aborted after %d tries"), MAXRECONNECT);
} }
} }