INRO: Update reconnection logic if modbus timeouts but TCP is still connected

master
Simon Stürz 2024-09-10 10:47:48 +02:00
parent c61d0fc6cd
commit e5b4856072
1 changed files with 13 additions and 3 deletions

View File

@ -274,9 +274,19 @@ void IntegrationPluginInro::setupConnection(ThingSetupInfo *info)
connection->modbusTcpMaster()->setHostAddress(deviceInfo.ipAddress); connection->modbusTcpMaster()->setHostAddress(deviceInfo.ipAddress);
if (!thing->stateValue("connected").toBool()) { if (!connection->reachable()) {
qCDebug(dcInro()) << "Received discovery paket for" << thing << "Start connecting to the PANTABOX on" << deviceInfo.ipAddress.toString();
connection->connectDevice(); if (connection->modbusTcpMaster()->connected()) {
qCDebug(dcInro()) << "Received discovery paket for" << thing->name() <<
"which is not reachable but the TCP socket is still connected. Reconnecting the TCP socket on" <<
deviceInfo.ipAddress.toString();
connection->modbusTcpMaster()->reconnectDevice();
} else {
qCDebug(dcInro()) << "Received discovery paket for" << thing->name() <<
"which is not reachable and not connected. Start connecting to the PANTABOX on" <<
deviceInfo.ipAddress.toString();
connection->connectDevice();
}
} }
}); });