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
impl Host
Sourcepub async fn advertise(
&self,
params: &AdvertisingParams,
data: &[u8],
scan_response: &[u8],
) -> Result<u8>
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.
Sourcepub async fn set_advertising_data(
&self,
handle: u8,
data: &[u8],
scan_response: Option<&[u8]>,
) -> Result<()>
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).
Sourcepub async fn stop_advertising(&self, handle: u8) -> Result<()>
pub async fn stop_advertising(&self, handle: u8) -> Result<()>
Stops and removes a set.
Sourcepub async fn stop_all_advertising(&self) -> Result<()>
pub async fn stop_all_advertising(&self) -> Result<()>
Stops every set.
Sourcepub async fn advertising_sets(&self) -> Vec<(u8, AdvertisingParams)>
pub async fn advertising_sets(&self) -> Vec<(u8, AdvertisingParams)>
Running sets and their parameters.
Sourcepub async fn start_periodic(
&self,
handle: u8,
params: &PeriodicParams,
data: &[u8],
) -> Result<()>
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.
Sourcepub async fn set_periodic_data(&self, handle: u8, data: &[u8]) -> Result<()>
pub async fn set_periodic_data(&self, handle: u8, data: &[u8]) -> Result<()>
Replaces a periodic train’s data.
Sourcepub async fn stop_periodic(&self, handle: u8) -> Result<()>
pub async fn stop_periodic(&self, handle: u8) -> Result<()>
Stops a set’s periodic train.
Source§impl Host
impl Host
Sourcepub async fn connect(
&self,
peer: Address,
p: &ConnectParams,
) -> Result<Connection>
pub async fn connect( &self, peer: Address, p: &ConnectParams, ) -> Result<Connection>
Connects to a device as central.
Sourcepub async fn accept_list_add(&self, a: Address) -> Result<()>
pub async fn accept_list_add(&self, a: Address) -> Result<()>
Adds a device to the controller’s filter accept list.
Sourcepub async fn accept_list_remove(&self, a: Address) -> Result<()>
pub async fn accept_list_remove(&self, a: Address) -> Result<()>
Removes a device from the filter accept list.
Sourcepub async fn accept_list_clear(&self) -> Result<()>
pub async fn accept_list_clear(&self) -> Result<()>
Empties the filter accept list.
Source§impl Host
impl Host
Sourcepub async fn open(spec: &TransportSpec, config: HostConfig) -> Result<Host>
pub async fn open(spec: &TransportSpec, config: HostConfig) -> Result<Host>
Opens the controller named by spec, resets it and reads what it can do.
Sourcepub async fn start(
reader: PacketReader,
writer: PacketWriter,
config: HostConfig,
) -> Result<Host>
pub async fn start( reader: PacketReader, writer: PacketWriter, config: HostConfig, ) -> Result<Host>
Starts on an already open transport.
Sourcepub fn capabilities(&self) -> &Capabilities
pub fn capabilities(&self) -> &Capabilities
What the controller can do.
Sourcepub fn events(&self) -> Receiver<HostEvent>
pub fn events(&self) -> Receiver<HostEvent>
Events, from now on. Each call gets its own receiver.
Sourcepub fn gatt_server(&self) -> Server
pub fn gatt_server(&self) -> Server
The GATT server’s database: add services, set values, notify.
Sourcepub fn connections(&self) -> Vec<Connection>
pub fn connections(&self) -> Vec<Connection>
Open connections.
Sourcepub fn connection(&self, handle: u16) -> Option<Connection>
pub fn connection(&self, handle: u16) -> Option<Connection>
A connection by handle.
Source§impl Host
impl Host
Sourcepub async fn start_scan(&self, config: ScanConfig) -> Result<()>
pub async fn start_scan(&self, config: ScanConfig) -> Result<()>
Starts scanning (or changes how). Advertisements arrive as
HostEvent::Advertisement.
Sourcepub fn scan_config(&self) -> Option<ScanConfig>
pub fn scan_config(&self) -> Option<ScanConfig>
Whether scanning is on, and how.
Sourcepub async fn sync_periodic(
&self,
advertiser: Address,
sid: u8,
skip: u16,
timeout_ms: u32,
) -> Result<u16>
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.
Sourcepub async fn terminate_sync(&self, sync: u16) -> Result<()>
pub async fn terminate_sync(&self, sync: u16) -> Result<()>
Stops following a periodic train.