pub struct CentralProxy { /* private fields */ }
Implementations§
Source§impl CentralProxy
impl CentralProxy
Sourcepub fn take_event_stream(&self) -> CentralEventStream
pub fn take_event_stream(&self) -> CentralEventStream
Get a Stream of events from the remote end of the protocol.
§Panics
Panics if the event stream was already taken.
Sourcepub fn listen_l2cap(
&self,
payload: ChannelListenerRegistryListenL2capRequest,
) -> QueryResponseFut<ChannelListenerRegistryListenL2capResult, DefaultFuchsiaResourceDialect>
pub fn listen_l2cap( &self, payload: ChannelListenerRegistryListenL2capRequest, ) -> QueryResponseFut<ChannelListenerRegistryListenL2capResult, DefaultFuchsiaResourceDialect>
Register a listener for incoming channels. The registry will assign a
PSM value that is unique for the local device, as well as open a
[ChannelListener
] for accepting incoming channels. In the unlikely
event that all PSMs have been assigned, this call will fail with
ZX_ERR_NO_RESOURCES
.
Note that the method of service discovery or advertising is defined by the service or protocol, so it is the responsibility of the caller to communicate the assigned PSM to any clients.
Sourcepub fn scan(
&self,
options: &ScanOptions,
result_watcher: ServerEnd<ScanResultWatcherMarker>,
) -> QueryResponseFut<(), DefaultFuchsiaResourceDialect>
pub fn scan( &self, options: &ScanOptions, result_watcher: ServerEnd<ScanResultWatcherMarker>, ) -> QueryResponseFut<(), DefaultFuchsiaResourceDialect>
Scans for nearby LE peripherals and broadcasters. If the scan cannot be
initiated, then result_watcher
will be closed with an epitaph.
A Central client is allowed to have only one active scan at a time. Accordingly, only one Scan request can be outstanding at a time. Additional calls to Scan will fail.
The lifetime of the scan session is tied to the result_watcher
protocol provided. The scan will be stopped if the channel is closed.
Once a scan is started, the [fuchsia.bluetooth.le/ScanResultWatcher
]
can be used to watch for scan results.
- request
options
Options used to configure the scan session. - request
result_watcher
Protocol that remains valid for the duration of this scan session.
- response An empty response will be sent to acknowledge the scan has stopped.
The following epitaphs may be sent by the server on error:
- error
ALREADY_EXISTS
: A scan is already in progress. EachCentral
protocol is only allowed 1 active scan. - error
INVALID_ARGS
: Some of the scanoptions
are invalid. See theScanOptions
documentation. - error
INTERNAL
: An internal error occurred and a scan could not be started.
Sourcepub fn connect(
&self,
id: &PeerId,
options: &ConnectionOptions,
handle: ServerEnd<ConnectionMarker>,
) -> Result<(), Error>
pub fn connect( &self, id: &PeerId, options: &ConnectionOptions, handle: ServerEnd<ConnectionMarker>, ) -> Result<(), Error>
Connect to the peer with the given identifier.
The requested [fuchsia.bluetooth.le/Connection
] represents the
client’s interest on the LE connection to the peer. Closing the channel
removes interest, but may not result in disconnection if another client
holds a valid [fuchsia.bluetooth.le/Connection
] to the same peer.
The [fuchsia.bluetooth.le/Connection
] handle
will be closed by the
system if the connection to the peer is lost or an error occurs.
The following epitaphs may be sent by the server on error:
-
INVALID_ARGS
: Some of the parameters are invalid. -
ALREADY_BOUND
: A Connection to the peer already exists for this Central. The existing Connection should be used. -
NOT_CONNECTED
: A connection could not be established. -
CONNECTION_RESET
: The peer disconnected. -
request
id
Identifier of the peer to initiate a connection to. -
request
options
Options used to configure the connection. -
request
handle
Handle that remains valid for the duration of this connection.
Sourcepub fn get_peripherals(
&self,
service_uuids: Option<&[String]>,
) -> QueryResponseFut<Vec<RemoteDevice>, DefaultFuchsiaResourceDialect>
pub fn get_peripherals( &self, service_uuids: Option<&[String]>, ) -> QueryResponseFut<Vec<RemoteDevice>, DefaultFuchsiaResourceDialect>
Returns the list of peripherals that are known to the system from previous scan, connection, and/or bonding procedures. The results can be filtered based on service UUIDs that are known to be present on the peripheral.
This method only returns peripherals (i.e. connectable devices).
Sourcepub fn get_peripheral(
&self,
identifier: &str,
) -> QueryResponseFut<Option<Box<RemoteDevice>>, DefaultFuchsiaResourceDialect>
pub fn get_peripheral( &self, identifier: &str, ) -> QueryResponseFut<Option<Box<RemoteDevice>>, DefaultFuchsiaResourceDialect>
This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)
Returns information about a single peripheral that is known to the system from previous scan,
connection, and/or bonding procedures based on its unique identifier. Returns null if
identifier
is not recognized.
Sourcepub fn start_scan(
&self,
filter: Option<&ScanFilter>,
) -> QueryResponseFut<Status, DefaultFuchsiaResourceDialect>
pub fn start_scan( &self, filter: Option<&ScanFilter>, ) -> QueryResponseFut<Status, DefaultFuchsiaResourceDialect>
Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
filter
will replace the existing session’s filter.
If filter
is null or empty (i.e. none of its fields has been populated) then the delegate
will be notified for all discoverable devices that are found. This is not recommended; clients
should generally filter results by at least one of filter.service_uuids
,
filter.service_data
, and/or filter.manufacturer_identifier
.
Sourcepub fn connect_peripheral(
&self,
identifier: &str,
options: &ConnectionOptions,
gatt_client: ServerEnd<ClientMarker>,
) -> QueryResponseFut<Status, DefaultFuchsiaResourceDialect>
pub fn connect_peripheral( &self, identifier: &str, options: &ConnectionOptions, gatt_client: ServerEnd<ClientMarker>, ) -> QueryResponseFut<Status, DefaultFuchsiaResourceDialect>
Creates a connection to the peripheral device with the given identifier.
Returns the status of the operation in status
.
On success, gatt_client
will be bound and can be used for GATT client
role procedures. On failure, gatt_client
will be closed and status
will
indicate an error.
Sourcepub fn disconnect_peripheral(
&self,
identifier: &str,
) -> QueryResponseFut<Status, DefaultFuchsiaResourceDialect>
pub fn disconnect_peripheral( &self, identifier: &str, ) -> QueryResponseFut<Status, DefaultFuchsiaResourceDialect>
Disconnects this Central’s connection to the peripheral with the given identifier.
Trait Implementations§
Source§impl CentralProxyInterface for CentralProxy
impl CentralProxyInterface for CentralProxy
type ListenL2capResponseFut = QueryResponseFut<Result<ChannelListenerRegistryListenL2capResponse, i32>>
type ScanResponseFut = QueryResponseFut<()>
type GetPeripheralsResponseFut = QueryResponseFut<Vec<RemoteDevice>>
type GetPeripheralResponseFut = QueryResponseFut<Option<Box<RemoteDevice>>>
type StartScanResponseFut = QueryResponseFut<Status>
type ConnectPeripheralResponseFut = QueryResponseFut<Status>
type DisconnectPeripheralResponseFut = QueryResponseFut<Status>
fn listen_l2cap( &self, payload: ChannelListenerRegistryListenL2capRequest, ) -> Self::ListenL2capResponseFut
fn scan( &self, options: &ScanOptions, result_watcher: ServerEnd<ScanResultWatcherMarker>, ) -> Self::ScanResponseFut
fn connect( &self, id: &PeerId, options: &ConnectionOptions, handle: ServerEnd<ConnectionMarker>, ) -> Result<(), Error>
fn get_peripherals( &self, service_uuids: Option<&[String]>, ) -> Self::GetPeripheralsResponseFut
fn get_peripheral(&self, identifier: &str) -> Self::GetPeripheralResponseFut
fn start_scan(&self, filter: Option<&ScanFilter>) -> Self::StartScanResponseFut
fn stop_scan(&self) -> Result<(), Error>
fn connect_peripheral( &self, identifier: &str, options: &ConnectionOptions, gatt_client: ServerEnd<ClientMarker>, ) -> Self::ConnectPeripheralResponseFut
fn disconnect_peripheral( &self, identifier: &str, ) -> Self::DisconnectPeripheralResponseFut
Source§impl Clone for CentralProxy
impl Clone for CentralProxy
Source§fn clone(&self) -> CentralProxy
fn clone(&self) -> CentralProxy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CentralProxy
impl Debug for CentralProxy
Source§impl Proxy for CentralProxy
impl Proxy for CentralProxy
Source§type Protocol = CentralMarker
type Protocol = CentralMarker
Proxy
controls.Source§fn from_channel(inner: AsyncChannel) -> Self
fn from_channel(inner: AsyncChannel) -> Self
Source§fn into_channel(self) -> Result<AsyncChannel, Self>
fn into_channel(self) -> Result<AsyncChannel, Self>
Source§fn as_channel(&self) -> &AsyncChannel
fn as_channel(&self) -> &AsyncChannel
§fn into_client_end(self) -> Result<ClientEnd<Self::Protocol>, Self>
fn into_client_end(self) -> Result<ClientEnd<Self::Protocol>, Self>
Auto Trait Implementations§
impl Freeze for CentralProxy
impl !RefUnwindSafe for CentralProxy
impl Send for CentralProxy
impl Sync for CentralProxy
impl Unpin for CentralProxy
impl !UnwindSafe for CentralProxy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)