trouble-host

Crates

git

Versions

default

Flavors

Struct Connection

Source
pub struct Connection<'stack, P: PacketPool> { /* private fields */ }
Expand description

Handle to a BLE connection.

When the last reference to a connection is dropped, the connection is automatically disconnected.

Implementations§

Source§

impl<'stack, P: PacketPool> Connection<'stack, P>

Source

pub async fn next(&self) -> ConnectionEvent

Wait for next connection event.

Source

pub fn is_connected(&self) -> bool

Check if still connected

Source

pub fn handle(&self) -> ConnHandle

Connection handle of this connection.

Source

pub fn att_mtu(&self) -> u16

Expose the att_mtu.

Source

pub fn role(&self) -> LeConnRole

The connection role for this connection.

Source

pub fn peer_address(&self) -> BdAddr

The peer address for this connection.

Source

pub fn peer_identity(&self) -> Identity

The peer identity key for this connection.

Source

pub fn request_security(&self) -> Result<(), Error>

Request a certain security level

For a peripheral this may cause the peripheral to send a security request. For a central this may cause the central to send a pairing request.

If the link is already encrypted then this will always generate an error.

Source

pub fn security_level(&self) -> Result<SecurityLevel, Error>

Get the encrypted state of the connection

Source

pub fn bondable(&self) -> Result<bool, Error>

Get whether the connection is set as bondable or not.

This is only relevant before pairing has started.

Source

pub fn set_bondable(&self, bondable: bool) -> Result<(), Error>

Set whether the connection is bondable or not.

By default a connection is not bondable.

This must be set before pairing is initiated. Once the pairing procedure has started this field is ignored.

If both peripheral and central are bondable then the [ConnectionEvent::PairingComplete] event contains the bond information for the pairing. This bond information should be stored in non-volatile memory and restored on reboot using [Stack::add_bond_information()].

If any party in a pairing is not bondable the [ConnectionEvent::PairingComplete] contains a None entry for the bond member.

Source

pub fn pass_key_confirm(&self) -> Result<(), Error>

Confirm that the displayed pass key matches the one displayed on the other party

Source

pub fn pass_key_cancel(&self) -> Result<(), Error>

The displayed pass key does not match the one displayed on the other party

Source

pub fn pass_key_input(&self, pass_key: u32) -> Result<(), Error>

Input the pairing pass key

Source

pub fn disconnect(&self)

Request connection to be disconnected.

Source

pub async fn rssi<T>( &self, stack: &Stack<'_, T, P>, ) -> Result<i8, BleHostError<T::Error>>

The RSSI value for this connection.

Source

pub async fn set_phy<T>( &self, stack: &Stack<'_, T, P>, phy: PhyKind, ) -> Result<(), BleHostError<T::Error>>

Update phy for this connection.

This updates both TX and RX phy of the connection. For more fine grained control, use the LeSetPhy HCI command directly.

Source

pub async fn read_phy<T>( &self, stack: &Stack<'_, T, P>, ) -> Result<(PhyKind, PhyKind), BleHostError<T::Error>>

Read the current phy used for the connection.

Source

pub async fn update_data_length<T>( &self, stack: &Stack<'_, T, P>, length: u16, time_us: u16, ) -> Result<(), BleHostError<T::Error>>

Update data length for this connection.

Source

pub async fn update_connection_params<T>( &self, stack: &Stack<'_, T, P>, params: &ConnectParams, ) -> Result<(), BleHostError<T::Error>>

Update connection parameters for this connection.

Source

pub async fn accept_connection_params<T>( &self, stack: &Stack<'_, T, P>, params: &ConnectParams, ) -> Result<(), BleHostError<T::Error>>

Respond to updated parameters.

Source

pub fn with_attribute_server<'values, 'server, M: RawMutex, const ATT_MAX: usize, const CCCD_MAX: usize, const CONN_MAX: usize>( self, server: &'server AttributeServer<'values, M, P, ATT_MAX, CCCD_MAX, CONN_MAX>, ) -> Result<GattConnection<'stack, 'server, P>, Error>

Transform BLE connection into a GattConnection

Trait Implementations§

Source§

impl<P: PacketPool> Clone for Connection<'_, P>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: PacketPool> Drop for Connection<'_, P>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'stack, P> Freeze for Connection<'stack, P>

§

impl<'stack, P> !RefUnwindSafe for Connection<'stack, P>

§

impl<'stack, P> !Send for Connection<'stack, P>

§

impl<'stack, P> !Sync for Connection<'stack, P>

§

impl<'stack, P> Unpin for Connection<'stack, P>

§

impl<'stack, P> !UnwindSafe for Connection<'stack, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.