Struct fidl_fuchsia_bluetooth_host::HostProxy
source · pub struct HostProxy { /* private fields */ }
Implementations§
source§impl HostProxy
impl HostProxy
sourcepub fn take_event_stream(&self) -> HostEventStream
pub fn take_event_stream(&self) -> HostEventStream
Get a Stream of events from the remote end of the protocol.
§Panics
Panics if the event stream was already taken.
sourcepub fn request_protocol(&self, payload: ProtocolRequest) -> Result<(), Error>
pub fn request_protocol(&self, payload: ProtocolRequest) -> Result<(), Error>
Fulfills a given protocol request. bt-host will start processing FIDL messages. If the request cannot be fulfilled, the bt-host device will close its end of the given channel.
sourcepub fn shutdown(&self) -> Result<(), Error>
pub fn shutdown(&self) -> Result<(), Error>
Shuts down the host, ending all active Bluetooth procedures:
- All FIDL interface handles associated with this host are closed and all connections initiated via FIDL clients are severed.
- All scan, discovery, and advertising procedures are stopped.
- Bonded devices are cleared and removed from the auto-connect lists.
- Auto-connected peripherals are disconnected.
This effectively resets the host to its initial state and the host remains available for future requests.
The Host will continue to send OnDeviceUpdated events as procedures get terminated.
The Host protocol will close when shutdown is complete.
sourcepub fn watch_state(&self) -> QueryResponseFut<HostInfo>
pub fn watch_state(&self) -> QueryResponseFut<HostInfo>
Returns information about the Bluetooth host subsystem and controller managed by this Host instance. If there has been no change to the state since the last call to this method, the response will be deferred until there is a change.
The returned info
structure will be populated with the current state of the bt-host
device. However the active
parameter will never be populated. This field is managed
by a higher layer.
sourcepub fn set_local_data(&self, payload: &HostData) -> Result<(), Error>
pub fn set_local_data(&self, payload: &HostData) -> Result<(), Error>
Assigns local data to this host.
sourcepub fn watch_peers(&self) -> QueryResponseFut<(Vec<Peer>, Vec<PeerId>)>
pub fn watch_peers(&self) -> QueryResponseFut<(Vec<Peer>, Vec<PeerId>)>
Monitors updates for connectable peers known to the system. Replies only when peers have been added, modified, or removed since the most recent call to WatchPeers().
Peers are added and updated as new information is obtained during discovery, connection establishment, and bonding procedures.
Peers are removed either:
a. explicitly via [fuchsia.bluetooth.host.Host/Forget
], or
b. no transmission has been received from the peer for an internally determined duration
of time and the peer is neither connected nor bonded.
- response
updated
Peers that were added or updated since the last call to WatchPeers(). - response
removed
Ids of peers that were removed since the last call to WatchPeers().
sourcepub fn set_local_name(
&self,
local_name: &str
) -> QueryResponseFut<HostSetLocalNameResult>
pub fn set_local_name( &self, local_name: &str ) -> QueryResponseFut<HostSetLocalNameResult>
Sets the local name for this host device.
sourcepub fn set_device_class(
&self,
device_class: &DeviceClass
) -> QueryResponseFut<HostSetDeviceClassResult>
pub fn set_device_class( &self, device_class: &DeviceClass ) -> QueryResponseFut<HostSetDeviceClassResult>
Sets the device class for this host device.
sourcepub fn start_discovery(&self) -> QueryResponseFut<HostStartDiscoveryResult>
pub fn start_discovery(&self) -> QueryResponseFut<HostStartDiscoveryResult>
Initiates a general discovery procedure for BR/EDR and LE devices. On success, discovered
peers can be monitored using the [fuchsia.bluetooth.host/Host.WatchPeers
] method.
On the LE transport, only general-discoverable and connectable peripherals will be reported.
Discovery will continue until it is terminated via StopDiscovery() or if the Host protocol channel gets closed. If the device does not support BR/EDR, only LE discovery will be performed.
sourcepub fn stop_discovery(&self) -> Result<(), Error>
pub fn stop_discovery(&self) -> Result<(), Error>
Terminates discovery if one was started via StartDiscovery().
NOTE: If another client is performing discovery (e.g. via its own le.Central interface handle), then the system will continue performing device discovery even if this method results in success.
sourcepub fn set_connectable(
&self,
enabled: bool
) -> QueryResponseFut<HostSetConnectableResult>
pub fn set_connectable( &self, enabled: bool ) -> QueryResponseFut<HostSetConnectableResult>
Sets whether this host should be connectable.
sourcepub fn set_discoverable(
&self,
enabled: bool
) -> QueryResponseFut<HostSetDiscoverableResult>
pub fn set_discoverable( &self, enabled: bool ) -> QueryResponseFut<HostSetDiscoverableResult>
Sets whether this host should be discoverable.
sourcepub fn connect(&self, id: &PeerId) -> QueryResponseFut<HostConnectResult>
pub fn connect(&self, id: &PeerId) -> QueryResponseFut<HostConnectResult>
Establish a BR/EDR and/or LE connection to the peer with identifier id
:
-
If the peer is known to support the BR/EDR transport then a logical link over that transport will be established to the device. If the connection attempt is successful, local services registered using “RequestProfile()” will be available to the peer. Traditional services discovered on the peer will be notified to local services asynchronously.
-
If the peer is known to support the LE transport then a logical link over that transport will be established to the device. If the connection attempt is successful, GATT services in the local database (populated via RequestGattServer()) will become available to the peer. Similarly, remote GATT services that are discovered on the peer will become available to holders of a gatt.Client capability and to device drivers that can bind to the bt-gatt-svc class of devices.
The result of the procedure will be communicated via status
. If the remote device
supports both BR/EDR and LE transports and a link cannot be established over both, then an
error Status will be returned and neither transport will be connected.
sourcepub fn disconnect(&self, id: &PeerId) -> QueryResponseFut<HostDisconnectResult>
pub fn disconnect(&self, id: &PeerId) -> QueryResponseFut<HostDisconnectResult>
Terminate all connections (BR/EDR or LE) to the remote peer with identifier id
.
- request
id
The identifier of the peer to disconnect.
- response
status
Contains an error if either LE or BR/EDR transport fails to disconnect. Contains success when both transports are successfully disconnected or if the peer is already disconnected.
sourcepub fn pair(
&self,
id: &PeerId,
options: &PairingOptions
) -> QueryResponseFut<HostPairResult>
pub fn pair( &self, id: &PeerId, options: &PairingOptions ) -> QueryResponseFut<HostPairResult>
Initiates pairing to the peer with the supplied id
and options
. Returns an error if no
connected peer with id
is found or the pairing procedure fails.
If options
specifies a higher security level than the current pairing, this method
attempts to raise the security level. Otherwise this method has no effect and returns
success.
NOTE: This is intended to satisfy test scenarios that require pairing procedures to be initiated without relying on service access. In normal operation, Bluetooth security is enforced during service access.
sourcepub fn forget(&self, id: &PeerId) -> QueryResponseFut<HostForgetResult>
pub fn forget(&self, id: &PeerId) -> QueryResponseFut<HostForgetResult>
Deletes a peer from the Bluetooth host. If the peer is connected, it will be disconnected.
device_id
will no longer refer to any peer, even if a device with the same address is
discovered again.
Returns success after no peer exists that’s identified by device_id
(even if it didn’t
exist before Forget), failure if the peer specified by device_id
could not be
disconnected or deleted and still exists.
sourcepub fn enable_background_scan(&self, enabled: bool) -> Result<(), Error>
pub fn enable_background_scan(&self, enabled: bool) -> Result<(), Error>
Enable or disable a passive LE background scan. When enabled, the bt-host device will continuously perform a passive LE scan in the background when no device discovery sessions are active and accept connection requests from bonded peripherals.
sourcepub fn enable_privacy(&self, enabled: bool) -> Result<(), Error>
pub fn enable_privacy(&self, enabled: bool) -> Result<(), Error>
Enable or disable the LE privacy feature. When enabled, the bt-host device will use a private device address in all LE procedures. When disabled, the public identity address will be used instead (which is the default).
sourcepub fn set_br_edr_security_mode(
&self,
bredr_security_mode: BrEdrSecurityMode
) -> Result<(), Error>
pub fn set_br_edr_security_mode( &self, bredr_security_mode: BrEdrSecurityMode ) -> Result<(), Error>
Set the GAP BR/EDR Security Mode of the host. bt-host only supports encrypted, connection-based security modes, i.e. Mode 4 and Secure Connections Only mode. If the security mode is set to Secure Connections Only, any existing encrypted connections which do not meet the security requirements of Secure Connections Only mode will be disconnected.
sourcepub fn set_le_security_mode(
&self,
le_security_mode: LeSecurityMode
) -> Result<(), Error>
pub fn set_le_security_mode( &self, le_security_mode: LeSecurityMode ) -> Result<(), Error>
Set the GAP LE Security Mode of the host. bt-host only supports encrypted, connection-based security modes, i.e. Mode 1 and Secure Connections Only mode. If the security mode is set to Secure Connections Only, any existing encrypted connections which do not meet the security requirements of Secure Connections Only mode will be disconnected.
sourcepub fn set_pairing_delegate(
&self,
input: InputCapability,
output: OutputCapability,
delegate: ClientEnd<PairingDelegateMarker>
) -> Result<(), Error>
pub fn set_pairing_delegate( &self, input: InputCapability, output: OutputCapability, delegate: ClientEnd<PairingDelegateMarker> ) -> Result<(), Error>
Assigns the pairing delegate that will respond to authentication challenges using the given I/O capabilities. Calling this method cancels any on-going pairing procedure started using a previous delegate. Pairing requests will be rejected if no PairingDelegate has been assigned.
sourcepub fn restore_bonds(
&self,
bonds: &[BondingData]
) -> QueryResponseFut<Vec<BondingData>>
pub fn restore_bonds( &self, bonds: &[BondingData] ) -> QueryResponseFut<Vec<BondingData>>
Restores existing bonded devices to the host. An authenticated session will be established for future connections using the provided bonding data.
If bonding data for the LE transport is available, then the host will automatically establish a connection when the peer is in range and connectable.
If any of the entries in bonds
could not be restored, then they will be returned in
errors
. This can happen for entries that are malformed and for peers that are already
known to the bt-host. An empty errors
list indicates that all bonds were successfully
restored.
Trait Implementations§
source§impl HostProxyInterface for HostProxy
impl HostProxyInterface for HostProxy
fn request_protocol(&self, payload: ProtocolRequest) -> Result<(), Error>
fn shutdown(&self) -> Result<(), Error>
type WatchStateResponseFut = QueryResponseFut<HostInfo>
fn watch_state(&self) -> Self::WatchStateResponseFut
fn set_local_data(&self, payload: &HostData) -> Result<(), Error>
type WatchPeersResponseFut = QueryResponseFut<(Vec<Peer>, Vec<PeerId>)>
fn watch_peers(&self) -> Self::WatchPeersResponseFut
type SetLocalNameResponseFut = QueryResponseFut<Result<(), Error>>
fn set_local_name(&self, local_name: &str) -> Self::SetLocalNameResponseFut
type SetDeviceClassResponseFut = QueryResponseFut<Result<(), Error>>
fn set_device_class( &self, device_class: &DeviceClass ) -> Self::SetDeviceClassResponseFut
type StartDiscoveryResponseFut = QueryResponseFut<Result<(), Error>>
fn start_discovery(&self) -> Self::StartDiscoveryResponseFut
fn stop_discovery(&self) -> Result<(), Error>
type SetConnectableResponseFut = QueryResponseFut<Result<(), Error>>
fn set_connectable(&self, enabled: bool) -> Self::SetConnectableResponseFut
type SetDiscoverableResponseFut = QueryResponseFut<Result<(), Error>>
fn set_discoverable(&self, enabled: bool) -> Self::SetDiscoverableResponseFut
type ConnectResponseFut = QueryResponseFut<Result<(), Error>>
fn connect(&self, id: &PeerId) -> Self::ConnectResponseFut
type DisconnectResponseFut = QueryResponseFut<Result<(), Error>>
fn disconnect(&self, id: &PeerId) -> Self::DisconnectResponseFut
type PairResponseFut = QueryResponseFut<Result<(), Error>>
fn pair(&self, id: &PeerId, options: &PairingOptions) -> Self::PairResponseFut
type ForgetResponseFut = QueryResponseFut<Result<(), Error>>
fn forget(&self, id: &PeerId) -> Self::ForgetResponseFut
fn enable_background_scan(&self, enabled: bool) -> Result<(), Error>
fn enable_privacy(&self, enabled: bool) -> Result<(), Error>
fn set_br_edr_security_mode( &self, bredr_security_mode: BrEdrSecurityMode ) -> Result<(), Error>
fn set_le_security_mode( &self, le_security_mode: LeSecurityMode ) -> Result<(), Error>
fn set_pairing_delegate( &self, input: InputCapability, output: OutputCapability, delegate: ClientEnd<PairingDelegateMarker> ) -> Result<(), Error>
type RestoreBondsResponseFut = QueryResponseFut<Vec<BondingData>>
fn restore_bonds(&self, bonds: &[BondingData]) -> Self::RestoreBondsResponseFut
source§impl Proxy for HostProxy
impl Proxy for HostProxy
§type Protocol = HostMarker
type Protocol = HostMarker
Proxy
controls.