Struct nrf_softdevice::Softdevice
source · pub struct Softdevice { /* private fields */ }
Expand description
Singleton instance of the enabled softdevice.
The Softdevice
instance can be obtaind by enabling it with Softdevice::enable
. Once
enabled, it can be used to establish Bluetooth connections with [ble::central
] and [ble::peripheral
].
Disabling the softdevice is not supported due to the complexity of a safe implementation. Consider resetting the CPU instead.
Implementations§
source§impl Softdevice
impl Softdevice
sourcepub fn enable(config: &Config) -> &'static mut Softdevice
pub fn enable(config: &Config) -> &'static mut Softdevice
Enable the softdevice.
Panics
- Panics if the requested configuration requires more memory than reserved for the softdevice. In that case, you can give more memory to the softdevice by editing the RAM start address in
memory.x
. The required start address is logged prior to panic. - Panics if the requested configuration has too high memory requirements for the softdevice. The softdevice supports a maximum dynamic memory size of 64kb.
- Panics if called multiple times. Must be called at most once.
sourcepub unsafe fn steal() -> &'static Softdevice
pub unsafe fn steal() -> &'static Softdevice
Return an instance to the softdevice without checking whether
it is enabled or not. This is only safe if the softdevice is enabled
(a call to [enable
] has returned without error) and no &mut
references
to the softdevice are active
sourcepub async fn run(&self) -> !
pub async fn run(&self) -> !
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.
sourcepub async fn run_with_callback<F: FnMut(SocEvent)>(&self, f: F) -> !
pub async fn run_with_callback<F: FnMut(SocEvent)>(&self, f: F) -> !
Runs the softdevice event handling loop with a callback for SocEvent
s.
It must be called under the same conditions as Softdevice::run()
. This
version allows the application to provide a callback to receive SoC events
from the softdevice (other than flash events which are handled by Flash
).