Skip to main content

Connection

Struct Connection 

Source
pub struct Connection { /* private fields */ }
Expand description

An open LE connection. Cloning it is cheap.

Implementations§

Source§

impl Connection

Source

pub fn handle(&self) -> u16

The HCI connection handle.

Source

pub fn role(&self) -> Role

Our role.

Source

pub fn peer(&self) -> Address

The peer’s address as it connected (possibly a private address).

Source

pub fn identity(&self) -> Address

The peer’s identity: its identity address once resolved (from a bond’s IRK, or from pairing), otherwise the address it connected with.

Source

pub fn params(&self) -> ConnParams

Current connection parameters.

Source

pub fn phy(&self) -> (Phy, Phy)

Current PHYs (tx, rx).

Source

pub fn data_length(&self) -> DataLength

Current data length.

Source

pub fn security(&self) -> Security

Current security.

Source

pub fn att_mtu(&self) -> u16

The ATT MTU in use.

Source

pub fn events(&self) -> Receiver<ConnEvent>

Events on this connection, from now on.

Source

pub fn is_connected(&self) -> bool

Whether it is still open.

Source

pub async fn disconnected(&self) -> u8

Waits until the connection closes; returns the HCI reason.

Source

pub async fn disconnect(&self) -> Result<()>

Closes the connection (reason: Remote User Terminated Connection).

Source

pub async fn update_params(&self, p: ParamsRequest) -> Result<ConnParams>

Asks for new connection parameters. As central the controller negotiates them; as peripheral we ask the central over L2CAP.

Source

pub async fn set_phy( &self, tx: &[Phy], rx: &[Phy], coded_s8: bool, ) -> Result<(Phy, Phy)>

Asks for PHYs. Each set lists the PHYs we accept in that direction; coded_s8 prefers the S=8 coding on the coded PHY (longer range).

Source

pub async fn read_phy(&self) -> Result<(Phy, Phy)>

Reads the PHYs in use from the controller.

Source

pub async fn set_data_length(&self, tx_octets: u16, tx_time: u16) -> Result<()>

Asks for a data length (octets 27 to 251, time 328 to 17040 µs).

Source

pub async fn read_rssi(&self) -> Result<i8>

The signal strength of the link, dBm.

Source

pub async fn remote_features(&self) -> Result<u64>

The peer’s LE features (read once, then remembered).

Source

pub fn gatt(&self) -> Client

The GATT client for the peer’s server.

Source

pub async fn pair(&self) -> Result<Security>

Pairs (and bonds, per the host’s configuration). As peripheral this sends a Security Request and the central decides.

Source

pub async fn secure(&self) -> Result<Security>

Encrypts the link with a bond’s stored key, pairing if there is none.

Source

pub async fn open_channel(&self, spsm: u16, mtu: u16) -> Result<Channel>

Opens an LE credit-based channel to the peer’s spsm.

Trait Implementations§

Source§

impl Clone for Connection

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Connection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more