From a8e1bb27219bb2ebea1126cad07b33937f3ab155 Mon Sep 17 00:00:00 2001 From: Rahix Date: Sat, 25 Apr 2026 15:17:48 +0200 Subject: [PATCH 1/2] fdl: active: Ensure GAP never scans own address Add a debug assertion to ensure the GAP scan never sends a status request to the address of the active station itself. --- src/fdl/active.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fdl/active.rs b/src/fdl/active.rs index 5dcdf7a..674b5bc 100644 --- a/src/fdl/active.rs +++ b/src/fdl/active.rs @@ -1128,6 +1128,8 @@ impl FdlActiveStation { } if let GapState::DoPoll { current_address } = self.gap_state { + debug_assert_ne!(current_address, self.p.address); + let tx_res = phy .transmit_telegram(now, |tx| { Some(tx.send_fdl_status_request(current_address, self.p.address)) From 00608ab106b9c15a8d98051615ba398ec7a0e3e8 Mon Sep 17 00:00:00 2001 From: Rahix Date: Sat, 25 Apr 2026 15:23:32 +0200 Subject: [PATCH 2/2] fdl: tests: Add test for discovering direct neighbor stations The active station implementation already correctly discovers direct neighbors but no test ever verified that this works. To catch any regressions in the future, add a test case for this condition. --- src/fdl/test_active.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/fdl/test_active.rs b/src/fdl/test_active.rs index 3c71db2..2102f11 100644 --- a/src/fdl/test_active.rs +++ b/src/fdl/test_active.rs @@ -565,6 +565,36 @@ fn active_station_discovers_neighbor() { fdl_ut.wait_for_matching(|t| t == fdl::Telegram::Token(fdl::TokenTelegram { da: 4, sa: 7 })); } +/// Test that an active station discovers a direct (active) neighbor station. +#[test] +fn active_station_discovers_direct_neighbor() { + crate::test_utils::prepare_test_logger(); + let mut fdl_ut = FdlActiveUnderTest::new(7); + + fdl_ut.wait_for_matching(|t| { + if let fdl::Telegram::Data(data_telegram) = t { + data_telegram.is_fdl_status_request().is_some() + && data_telegram.h.da == 8 + && data_telegram.h.sa == 7 + } else { + false + } + }); + + fdl_ut.advance_bus_time_min_tsdr(); + fdl_ut.transmit_telegram(|tx| { + Some(tx.send_fdl_status_response( + 7, + 8, + fdl::ResponseState::MasterWithoutToken, + fdl::ResponseStatus::Ok, + )) + }); + fdl_ut.wait_transmission(); + + fdl_ut.wait_for_matching(|t| t == fdl::Telegram::Token(fdl::TokenTelegram { da: 8, sa: 7 })); +} + /// Test that an active station resends the token when not received by next station #[test] fn active_station_resends_token() {