Skip to main content

Host

Struct Host 

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

A running Bluetooth host on one controller. Cloning it is cheap; every clone drives the same controller.

Implementations§

Source§

impl Host

Source

pub async fn advertise( &self, params: &AdvertisingParams, data: &[u8], scan_response: &[u8], ) -> Result<u8>

Starts an advertising set; returns its handle. scan_response is sent to active scanners when the set is scannable.

Source

pub async fn set_advertising_data( &self, handle: u8, data: &[u8], scan_response: Option<&[u8]>, ) -> Result<()>

Replaces a running set’s data (and scan response, when given).

Source

pub async fn stop_advertising(&self, handle: u8) -> Result<()>

Stops and removes a set.

Source

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

Stops every set.

Source

pub async fn advertising_sets(&self) -> Vec<(u8, AdvertisingParams)>

Running sets and their parameters.

Source

pub async fn start_periodic( &self, handle: u8, params: &PeriodicParams, data: &[u8], ) -> Result<()>

Adds a periodic advertising train to a set (which must be extended, non-connectable and non-scannable) and starts it.

Source

pub async fn set_periodic_data(&self, handle: u8, data: &[u8]) -> Result<()>

Replaces a periodic train’s data.

Source

pub async fn stop_periodic(&self, handle: u8) -> Result<()>

Stops a set’s periodic train.

Source§

impl Host

Source

pub async fn connect( &self, peer: Address, p: &ConnectParams, ) -> Result<Connection>

Connects to a device as central.

Source

pub async fn accept_list_add(&self, a: Address) -> Result<()>

Adds a device to the controller’s filter accept list.

Source

pub async fn accept_list_remove(&self, a: Address) -> Result<()>

Removes a device from the filter accept list.

Source

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

Empties the filter accept list.

Source

pub fn listen_channel(&self, spsm: u16, mtu: u16) -> Receiver<Channel>

Registers an L2CAP credit-based channel server on spsm; incoming channels arrive on the receiver.

Source§

impl Host

Source

pub async fn open(spec: &TransportSpec, config: HostConfig) -> Result<Host>

Opens the controller named by spec, resets it and reads what it can do.

Source

pub async fn start( reader: PacketReader, writer: PacketWriter, config: HostConfig, ) -> Result<Host>

Starts on an already open transport.

Source

pub fn capabilities(&self) -> &Capabilities

What the controller can do.

Source

pub fn address(&self) -> Address

Our identity address (public, or the static random one).

Source

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

Events, from now on. Each call gets its own receiver.

Source

pub async fn stopped(&self) -> String

Resolves when the host stops, with the reason.

Source

pub fn gatt_server(&self) -> Server

The GATT server’s database: add services, set values, notify.

Source

pub fn keys(&self) -> &Keys

Bonds and keys.

Source

pub fn connections(&self) -> Vec<Connection>

Open connections.

Source

pub fn connection(&self, handle: u16) -> Option<Connection>

A connection by handle.

Source§

impl Host

Source

pub async fn start_scan(&self, config: ScanConfig) -> Result<()>

Starts scanning (or changes how). Advertisements arrive as HostEvent::Advertisement.

Source

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

Stops scanning.

Source

pub fn scan_config(&self) -> Option<ScanConfig>

Whether scanning is on, and how.

Source

pub async fn sync_periodic( &self, advertiser: Address, sid: u8, skip: u16, timeout_ms: u32, ) -> Result<u16>

Synchronizes to a periodic advertising train (scanning must be on to find it). Returns the sync handle; reports arrive as HostEvent::PeriodicReport.

Source

pub async fn terminate_sync(&self, sync: u16) -> Result<()>

Stops following a periodic train.

Trait Implementations§

Source§

impl Clone for Host

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Host

§

impl !UnwindSafe for Host

§

impl Freeze for Host

§

impl Send for Host

§

impl Sync for Host

§

impl Unpin for Host

§

impl UnsafeUnpin for Host

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