From 15947259e80f9440b354c58a4902892999d1ebe4 Mon Sep 17 00:00:00 2001 From: diogo464 Date: Sun, 7 Dec 2025 23:11:31 +0000 Subject: cyw43: update link status on LINK event currently the cyw43 driver only sets the link state in src/control.rs:397 when a join is successful and stays up after that regardless of the actual state of the connection. this commit changes that so that the link state is updated based on LINK events the same way that it is done in https://github.com/georgerobotics/cyw43-driver/blob/dd7568229f3bf7a37737b9e1ef250c26efe75b23/src/cyw43_ctrl.c#L402 --- cyw43/src/control.rs | 1 - cyw43/src/runner.rs | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cyw43/src/control.rs b/cyw43/src/control.rs index 219198d1f..141aeb503 100644 --- a/cyw43/src/control.rs +++ b/cyw43/src/control.rs @@ -394,7 +394,6 @@ impl<'a> Control<'a> { self.events.mask.disable_all(); if status == EStatus::SUCCESS { // successful join - self.state_ch.set_link_state(LinkState::Up); debug!("JOINED"); Ok(()) } else { diff --git a/cyw43/src/runner.rs b/cyw43/src/runner.rs index 7c38be24a..7593aef57 100644 --- a/cyw43/src/runner.rs +++ b/cyw43/src/runner.rs @@ -1,5 +1,6 @@ use embassy_futures::select::{Either4, select4}; use embassy_net_driver_channel as ch; +use embassy_net_driver_channel::driver::LinkState; use embassy_time::{Duration, Timer, block_for}; use embedded_hal_1::digital::OutputPin; @@ -496,6 +497,21 @@ where Bytes(evt_data) ); + // Handle LINK event to update link state + if evt_type == Event::LINK { + if event_packet.msg.status == 0 { + if event_packet.msg.flags & 1 != 0 { + // Bit 0 set = Link is UP + self.ch.set_link_state(LinkState::Up); + debug!("Link state: UP"); + } else { + // Bit 0 clear = Link is DOWN + self.ch.set_link_state(LinkState::Down); + debug!("Link state: DOWN"); + } + } + } + if self.events.mask.is_enabled(evt_type) { let status = event_packet.msg.status; let event_payload = match evt_type { -- cgit