nymea-plugins-modbus: Fix spaming logs in SMA integration
When SMA integration can't join the multicast group it begins spaming the log each 5s. With this commit it logs the joining problem each 5s for the first minute, after that each 10min. Signed-off-by: Martin Lukas <martin.lukas@chargebyte.com>master
parent
8d85307f46
commit
4fe0e53a1b
|
|
@ -147,10 +147,21 @@ void SpeedwireInterface::reconfigureMulticastGroup()
|
||||||
qCDebug(dcSma()) << "Reconfigure multicast interfaces";
|
qCDebug(dcSma()) << "Reconfigure multicast interfaces";
|
||||||
if (m_multicast->joinMulticastGroup(Speedwire::multicastAddress())) {
|
if (m_multicast->joinMulticastGroup(Speedwire::multicastAddress())) {
|
||||||
qCDebug(dcSma()) << "SpeedwireInterface: Joined successfully multicast group" << Speedwire::multicastAddress().toString();
|
qCDebug(dcSma()) << "SpeedwireInterface: Joined successfully multicast group" << Speedwire::multicastAddress().toString();
|
||||||
|
m_multicastWarningPrintCount = 0;
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcSma()) << "SpeedwireInterface: Failed to join multicast group" << Speedwire::multicastAddress().toString() << m_multicast->errorString() << "Retrying in 5 seconds...";
|
|
||||||
// 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
|
||||||
|
uint mod = m_multicastWarningPrintCount % 120;
|
||||||
|
|
||||||
|
if (m_multicastWarningPrintCount < 12) {
|
||||||
|
qCWarning(dcSma()) << "SpeedwireInterface: Failed to join multicast group" << Speedwire::multicastAddress().toString() << m_multicast->errorString() << "Retrying in 5 seconds...";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_multicastWarningPrintCount >= 12 && mod == 0) {
|
||||||
|
qCWarning(dcSma()) << "SpeedwireInterface: Failed to join multicast group" << Speedwire::multicastAddress().toString() << m_multicast->errorString() << "Retrying in 10 minutes...";
|
||||||
|
}
|
||||||
|
|
||||||
QTimer::singleShot(5000, this, &SpeedwireInterface::reconfigureMulticastGroup);
|
QTimer::singleShot(5000, this, &SpeedwireInterface::reconfigureMulticastGroup);
|
||||||
|
m_multicastWarningPrintCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// foreach (const QNetworkInterface &interface, QNetworkInterface::allInterfaces()) {
|
// foreach (const QNetworkInterface &interface, QNetworkInterface::allInterfaces()) {
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ private:
|
||||||
quint32 m_sourceSerialNumber = 0;
|
quint32 m_sourceSerialNumber = 0;
|
||||||
bool m_available = false;
|
bool m_available = false;
|
||||||
QTimer m_multicastReconfigureationTimer;
|
QTimer m_multicastReconfigureationTimer;
|
||||||
|
uint m_multicastWarningPrintCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue