From f90561fb2609916a57c3d17a6418aab26563e1ee Mon Sep 17 00:00:00 2001 From: Martin Lukas Date: Mon, 28 Oct 2024 08:00:33 +0100 Subject: [PATCH] Fix spaming log When shelly integration can't join the multicast group it begins spaming the log each 5s. With this commit it log the joining problem each 5s for the first Minute, after that each 10min. Signed-off-by: Martin Lukas --- shelly/integrationpluginshelly.cpp | 15 +++++++++++++-- shelly/integrationpluginshelly.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/shelly/integrationpluginshelly.cpp b/shelly/integrationpluginshelly.cpp index 92ee1993..4ad9c19a 100644 --- a/shelly/integrationpluginshelly.cpp +++ b/shelly/integrationpluginshelly.cpp @@ -768,12 +768,23 @@ void IntegrationPluginShelly::joinMulticastGroup() { if (m_coap->joinMulticastGroup()) { qCInfo(dcShelly()) << "Joined CoIoT multicast group"; + m_multicastRetryCnt = 0; } else { - qCWarning(dcShelly()) << "Failed to join CoIoT multicast group. Retrying in 5 seconds..."; + uint retryTime = 0; + // FIXME: It would probably be better to monitor the network interfaces and re-join if necessary - QTimer::singleShot(5000, m_coap, [this](){ + if (m_multicastRetryCnt < 12) { + qCWarning(dcShelly()) << "Failed to join CoIoT multicast group. Retrying in 5 seconds..."; + retryTime = 5000; + } else { + qCWarning(dcShelly()) << "Failed to join CoIoT multicast group. Retrying in 10 minutes..."; + retryTime = 600000; + } + + QTimer::singleShot(retryTime, m_coap, [this](){ joinMulticastGroup(); }); + m_multicastRetryCnt++; } } diff --git a/shelly/integrationpluginshelly.h b/shelly/integrationpluginshelly.h index 57bfc49a..217f698b 100644 --- a/shelly/integrationpluginshelly.h +++ b/shelly/integrationpluginshelly.h @@ -94,6 +94,7 @@ private: PluginTimer *m_reconfigureTimer = nullptr; Coap *m_coap = nullptr; + uint m_multicastRetryCnt = 0; QHash m_rpcClients; };