diff options
| author | diogo464 <[email protected]> | 2025-12-07 23:11:31 +0000 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-12-07 23:25:09 +0000 |
| commit | 15947259e80f9440b354c58a4902892999d1ebe4 (patch) | |
| tree | 2a5320b44e841e5d4c3dd909ac35956a954aeeec /cyw43/src/runner.rs | |
| parent | b9e467bdfe44e51a8b633040d9fe9cd43c581d36 (diff) | |
cyw43: update link status on LINK eventcyw43-link-status-update
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
Diffstat (limited to 'cyw43/src/runner.rs')
| -rw-r--r-- | cyw43/src/runner.rs | 16 |
1 files changed, 16 insertions, 0 deletions
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 @@ | |||
| 1 | use embassy_futures::select::{Either4, select4}; | 1 | use embassy_futures::select::{Either4, select4}; |
| 2 | use embassy_net_driver_channel as ch; | 2 | use embassy_net_driver_channel as ch; |
| 3 | use embassy_net_driver_channel::driver::LinkState; | ||
| 3 | use embassy_time::{Duration, Timer, block_for}; | 4 | use embassy_time::{Duration, Timer, block_for}; |
| 4 | use embedded_hal_1::digital::OutputPin; | 5 | use embedded_hal_1::digital::OutputPin; |
| 5 | 6 | ||
| @@ -496,6 +497,21 @@ where | |||
| 496 | Bytes(evt_data) | 497 | Bytes(evt_data) |
| 497 | ); | 498 | ); |
| 498 | 499 | ||
| 500 | // Handle LINK event to update link state | ||
| 501 | if evt_type == Event::LINK { | ||
| 502 | if event_packet.msg.status == 0 { | ||
| 503 | if event_packet.msg.flags & 1 != 0 { | ||
| 504 | // Bit 0 set = Link is UP | ||
| 505 | self.ch.set_link_state(LinkState::Up); | ||
| 506 | debug!("Link state: UP"); | ||
| 507 | } else { | ||
| 508 | // Bit 0 clear = Link is DOWN | ||
| 509 | self.ch.set_link_state(LinkState::Down); | ||
| 510 | debug!("Link state: DOWN"); | ||
| 511 | } | ||
| 512 | } | ||
| 513 | } | ||
| 514 | |||
| 499 | if self.events.mask.is_enabled(evt_type) { | 515 | if self.events.mask.is_enabled(evt_type) { |
| 500 | let status = event_packet.msg.status; | 516 | let status = event_packet.msg.status; |
| 501 | let event_payload = match evt_type { | 517 | let event_payload = match evt_type { |
