pub struct Stack<'stack, C, P: PacketPool> { /* private fields */ }Expand description
Contains the host stack
Implementations§
Source§impl<'stack, C: Controller, P: PacketPool> Stack<'stack, C, P>
impl<'stack, C: Controller, P: PacketPool> Stack<'stack, C, P>
Sourcepub fn runner(&self) -> Runner<'_, C, P>
pub fn runner(&self) -> Runner<'_, C, P>
Obtain a Runner to drive the BLE host.
The runner must be polled (e.g. via Runner::run()) to drive the BLE host.
Sourcepub fn central(&self) -> Central<'_, C, P>
pub fn central(&self) -> Central<'_, C, P>
Obtain a Central handle for the central BLE role.
This is a lightweight handle that can be created multiple times. Concurrent connect operations are serialized internally.
Sourcepub fn peripheral(&self) -> Peripheral<'_, C, P>
pub fn peripheral(&self) -> Peripheral<'_, C, P>
Obtain a Peripheral handle for the peripheral BLE role.
This is a lightweight handle that can be created multiple times. Concurrent advertise operations are serialized internally.
Sourcepub fn set_io_capabilities(&self, io_capabilities: IoCapabilities)
pub fn set_io_capabilities(&self, io_capabilities: IoCapabilities)
Set the IO capabilities used by the security manager.
Only relevant if the feature security is enabled.
Sourcepub async fn set_rpa_timeout(
&self,
timeout: Duration,
) -> Result<(), BleHostError<C::Error>>
pub async fn set_rpa_timeout( &self, timeout: Duration, ) -> Result<(), BleHostError<C::Error>>
Set the RPA (Resolvable Private Address) rotation timeout.
Updates the stored timeout. If the host is already initialized, also sends
the LeSetResolvablePrivateAddrTimeout HCI command to the controller.
If called before initialization (e.g. during pre-server setup), the value
will be used when the controller is initialized.
Valid range is 1s to 3600s.
Sourcepub async fn command<T>(
&self,
cmd: T,
) -> Result<T::Return, BleHostError<C::Error>>where
T: SyncCmd,
C: ControllerCmdSync<T>,
pub async fn command<T>(
&self,
cmd: T,
) -> Result<T::Return, BleHostError<C::Error>>where
T: SyncCmd,
C: ControllerCmdSync<T>,
Run a HCI command and return the response.
Sourcepub async fn async_command<T>(
&self,
cmd: T,
) -> Result<(), BleHostError<C::Error>>where
T: AsyncCmd,
C: ControllerCmdAsync<T>,
pub async fn async_command<T>(
&self,
cmd: T,
) -> Result<(), BleHostError<C::Error>>where
T: AsyncCmd,
C: ControllerCmdAsync<T>,
Run an async HCI command where the response will generate an event later.
Sourcepub async fn read_minimum_supported_connection_interval(
&self,
) -> Result<<LeReadMinimumSupportedConnectionInterval as SyncCmd>::Return, BleHostError<C::Error>>
pub async fn read_minimum_supported_connection_interval( &self, ) -> Result<<LeReadMinimumSupportedConnectionInterval as SyncCmd>::Return, BleHostError<C::Error>>
Read the minimum supported connection interval from the controller.
Sourcepub fn metrics<F: FnOnce(&HostMetrics) -> R, R>(&self, f: F) -> R
pub fn metrics<F: FnOnce(&HostMetrics) -> R, R>(&self, f: F) -> R
Read current host metrics
Sourcepub fn log_status(&self, verbose: bool)
pub fn log_status(&self, verbose: bool)
Log status information of the host
Sourcepub fn get_local_oob_data(&self) -> OobData
pub fn get_local_oob_data(&self) -> OobData
Generate local OOB data for LESC pairing.
The returned data should be transferred to the peer device via an out-of-band channel (NFC, QR code, etc.) before pairing begins.
Sourcepub fn get_local_address(&self) -> Option<Address>
pub fn get_local_address(&self) -> Option<Address>
Get the local address configured on the security manager.
Sourcepub fn is_privacy_enabled(&self) -> bool
pub fn is_privacy_enabled(&self) -> bool
Check whether BLE address privacy is enabled.
Sourcepub fn add_bond_information(
&self,
bond_information: BondInformation,
) -> Result<(), Error>
pub fn add_bond_information( &self, bond_information: BondInformation, ) -> Result<(), Error>
Add bond information for a peer device.
After bonds are added or removed (either directly or via pairing), the controller’s resolving list is updated automatically the next time advertising, scanning, and connecting are all idle. Applications should ensure periodic idle windows to allow resolving list updates to take effect.
Sourcepub fn remove_bond_information(&self, identity: Identity) -> Result<(), Error>
pub fn remove_bond_information(&self, identity: Identity) -> Result<(), Error>
Remove a bonded device.
After bonds are added or removed (either directly or via pairing), the controller’s resolving list is updated automatically the next time advertising, scanning, and connecting are all idle. Applications should ensure periodic idle windows to allow resolving list updates to take effect.
Sourcepub fn with_bond_information<R>(
&self,
f: impl FnOnce(&[BondInformation]) -> R,
) -> R
pub fn with_bond_information<R>( &self, f: impl FnOnce(&[BondInformation]) -> R, ) -> R
Access bonded devices
Sourcepub fn get_connection_by_peer_address(
&self,
peer_address: Address,
) -> Option<Connection<'_, P>>
pub fn get_connection_by_peer_address( &self, peer_address: Address, ) -> Option<Connection<'_, P>>
Get a connection by its peer address
Sourcepub fn get_connected_handle(
&self,
handle: ConnHandle,
) -> Option<Connection<'_, P>>
pub fn get_connected_handle( &self, handle: ConnHandle, ) -> Option<Connection<'_, P>>
Get a connection by its handle
Sourcepub fn connections(&self) -> ConnectedIter<'_, P>
pub fn connections(&self) -> ConnectedIter<'_, P>
Iterate over all currently connected connections.