fix(network): harden Ethernet-preferred lifecycle
This commit is contained in:
1 parent
d9db3e8e6a
commit
a0188bd174
26 files changed
+803
-193
No files matched your search
@@ -208,10 +208,14 @@ void AlertReporter::onLoop(unsigned long now_ms) {
|
||||
const uint32_t min_interval_ms =
|
||||
AlertFaultPolicy::minIntervalMs(_obs->alert_min_interval_min);
|
||||
|
||||
// -------- WiFi fault --------
|
||||
// -------- Primary network fault --------
|
||||
if (_obs->alert_wifi_minutes > 0) {
|
||||
if (_bridge != nullptr) {
|
||||
const AlertFaultPolicy::OutageSnapshot snap = _bridge->getWifiOutageSnapshot();
|
||||
const AlertFaultPolicy::OutageSnapshot snap =
|
||||
_bridge->getNetworkOutageSnapshot();
|
||||
const NetworkMedium alert_medium = _bridge->getNetworkAlertMedium();
|
||||
const char* alert_label = alert_medium == NetworkMedium::Ethernet
|
||||
? "Ethernet" : "WiFi";
|
||||
AlertFaultPolicy::TickResult r = AlertFaultPolicy::tick(
|
||||
_wifi, now, snap,
|
||||
AlertFaultPolicy::thresholdMs(_obs->alert_wifi_minutes),
|
||||
@@ -219,20 +223,14 @@ void AlertReporter::onLoop(unsigned long now_ms) {
|
||||
if (r.action == AlertFaultPolicy::Action::FireDown) {
|
||||
char text[80];
|
||||
AlertFaultPolicy::formatNetworkAlert(
|
||||
text, sizeof(text),
|
||||
activeNetworkInterface().medium() == NetworkMedium::Ethernet
|
||||
? "Ethernet" : "WiFi",
|
||||
r, snap);
|
||||
text, sizeof(text), alert_label, r, snap);
|
||||
if (sendChannel(text)) {
|
||||
AlertFaultPolicy::commitDown(_wifi, now, snap.started_ms);
|
||||
}
|
||||
} else if (r.action == AlertFaultPolicy::Action::FireRecovered) {
|
||||
char text[80];
|
||||
AlertFaultPolicy::formatNetworkAlert(
|
||||
text, sizeof(text),
|
||||
activeNetworkInterface().medium() == NetworkMedium::Ethernet
|
||||
? "Ethernet" : "WiFi",
|
||||
r, snap);
|
||||
text, sizeof(text), alert_label, r, snap);
|
||||
sendChannel(text);
|
||||
AlertFaultPolicy::commitRecovered(_wifi);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user