From e5b48560727eef1b85713fef3eb003b1ae64b9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Tue, 10 Sep 2024 10:47:48 +0200 Subject: [PATCH] INRO: Update reconnection logic if modbus timeouts but TCP is still connected --- inro/integrationplugininro.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/inro/integrationplugininro.cpp b/inro/integrationplugininro.cpp index 8d8ad6f..15f677d 100644 --- a/inro/integrationplugininro.cpp +++ b/inro/integrationplugininro.cpp @@ -274,9 +274,19 @@ void IntegrationPluginInro::setupConnection(ThingSetupInfo *info) connection->modbusTcpMaster()->setHostAddress(deviceInfo.ipAddress); - if (!thing->stateValue("connected").toBool()) { - qCDebug(dcInro()) << "Received discovery paket for" << thing << "Start connecting to the PANTABOX on" << deviceInfo.ipAddress.toString(); - connection->connectDevice(); + if (!connection->reachable()) { + + 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(); + } } });