Rework after review

Signed-off-by: Martin Lukas <martin.lukas@chargebyte.com>
This commit is contained in:
Martin Lukas 2024-10-28 09:22:06 +01:00
parent f90561fb26
commit b88935bd2f
2 changed files with 26 additions and 26 deletions

View File

@ -768,23 +768,23 @@ void IntegrationPluginShelly::joinMulticastGroup()
{ {
if (m_coap->joinMulticastGroup()) { if (m_coap->joinMulticastGroup()) {
qCInfo(dcShelly()) << "Joined CoIoT multicast group"; qCInfo(dcShelly()) << "Joined CoIoT multicast group";
m_multicastRetryCnt = 0; m_multicastWarningPrintCount = 0;
} else { } else {
uint retryTime = 0; uint mod = m_multicastWarningPrintCount % 120;
// FIXME: It would probably be better to monitor the network interfaces and re-join if necessary // FIXME: It would probably be better to monitor the network interfaces and re-join if necessary
if (m_multicastRetryCnt < 12) { if (m_multicastWarningPrintCount < 12) {
qCWarning(dcShelly()) << "Failed to join CoIoT multicast group. Retrying in 5 seconds..."; 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](){ if (m_multicastWarningPrintCount >= 12 && mod == 0) {
qCWarning(dcShelly()) << "Failed to join CoIoT multicast group. Retrying in 10 minutes...";
}
QTimer::singleShot(5000, m_coap, [this](){
joinMulticastGroup(); joinMulticastGroup();
}); });
m_multicastRetryCnt++; m_multicastWarningPrintCount++;
} }
} }

View File

@ -94,7 +94,7 @@ private:
PluginTimer *m_reconfigureTimer = nullptr; PluginTimer *m_reconfigureTimer = nullptr;
Coap *m_coap = nullptr; Coap *m_coap = nullptr;
uint m_multicastRetryCnt = 0; uint m_multicastWarningPrintCount = 0;
QHash<Thing*, ShellyJsonRpcClient*> m_rpcClients; QHash<Thing*, ShellyJsonRpcClient*> m_rpcClients;
}; };