From 411696217584cccfc948e5d6904c48dcc92b7c9c Mon Sep 17 00:00:00 2001 From: linuswck Date: Thu, 18 Apr 2024 17:32:58 +0800 Subject: [PATCH] firmware: rst active_rpt if eth link is not active --- src/main.rs | 4 +++- src/net/net.rs | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index cb55f01..c6b09ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,7 +72,9 @@ fn main() -> ! { loop { wd.feed(); - net::net::eth_poll_and_update_link_speed(); + if !net::net::eth_poll_link_status_and_update_link_speed() { + active_report = [false; net::net::NUM_OF_SOCKETS]; + } match state { State::LoadFlashSettings => { diff --git a/src/net/net.rs b/src/net/net.rs index 44d28a8..b6995fa 100644 --- a/src/net/net.rs +++ b/src/net/net.rs @@ -352,13 +352,14 @@ impl EthernetPhy { } } -pub fn eth_poll_and_update_link_speed() { +pub fn eth_poll_link_status_and_update_link_speed() -> bool { unsafe { if let Some(ref mut server_handle ) = SERVER_HANDLE { server_handle.update_link_speed(); + return server_handle.link_was_up; } else { - panic!("eth_poll_and_update_link_speed is called before init"); + panic!("eth_poll_link_status_and_update_link_speed is called before init"); } } }