diff options
Diffstat (limited to 'nrf-softdevice/src/softdevice.rs')
-rw-r--r-- | nrf-softdevice/src/softdevice.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/nrf-softdevice/src/softdevice.rs b/nrf-softdevice/src/softdevice.rs index cbcfe8b..af8a0b4 100644 --- a/nrf-softdevice/src/softdevice.rs +++ b/nrf-softdevice/src/softdevice.rs @@ -3,9 +3,9 @@ use core::ptr; use core::sync::atomic::{AtomicBool, Ordering}; use embassy::util::Forever; -use crate::pac; use crate::raw; use crate::RawError; +use crate::{pac, SocEvent}; unsafe extern "C" fn fault_handler(id: u32, pc: u32, info: u32) { match (id, info) { @@ -320,6 +320,14 @@ impl Softdevice { /// It must be called in its own async task after enabling the softdevice /// and before doing any operation. Failure to doing so will cause async operations to never finish. pub async fn run(&self) -> ! { - crate::events::run().await + self.run_with_callback(|_| {}).await + } + + /// Runs the softdevice event handling loop. + /// + /// It must be called in its own async task after enabling the softdevice + /// and before doing any operation. Failure to doing so will cause async operations to never finish. + pub async fn run_with_callback<F: FnMut(SocEvent)>(&self, f: F) -> ! { + crate::events::run(f).await } } |