fidl_fuchsia_bluetooth_le

Struct CentralProxy

Source
pub struct CentralProxy { /* private fields */ }

Implementations§

Source§

impl CentralProxy

Source

pub fn new(channel: AsyncChannel) -> Self

Create a new Proxy for fuchsia.bluetooth.le/Central.

Source

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.

Source

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.

Source

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. Each Central protocol is only allowed 1 active scan.
  • error INVALID_ARGS: Some of the scan options are invalid. See the ScanOptions documentation.
  • error INTERNAL: An internal error occurred and a scan could not be started.
Source

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.

Source

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

Source

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.

Source

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.

Source

pub fn stop_scan(&self) -> Result<(), Error>

Terminate a previously started scan session.

Source

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.

Source

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

Source§

type ListenL2capResponseFut = QueryResponseFut<Result<ChannelListenerRegistryListenL2capResponse, i32>>

Source§

type ScanResponseFut = QueryResponseFut<()>

Source§

type GetPeripheralsResponseFut = QueryResponseFut<Vec<RemoteDevice>>

Source§

type GetPeripheralResponseFut = QueryResponseFut<Option<Box<RemoteDevice>>>

Source§

type StartScanResponseFut = QueryResponseFut<Status>

Source§

type ConnectPeripheralResponseFut = QueryResponseFut<Status>

Source§

type DisconnectPeripheralResponseFut = QueryResponseFut<Status>

Source§

fn listen_l2cap( &self, payload: ChannelListenerRegistryListenL2capRequest, ) -> Self::ListenL2capResponseFut

Source§

fn scan( &self, options: &ScanOptions, result_watcher: ServerEnd<ScanResultWatcherMarker>, ) -> Self::ScanResponseFut

Source§

fn connect( &self, id: &PeerId, options: &ConnectionOptions, handle: ServerEnd<ConnectionMarker>, ) -> Result<(), Error>

Source§

fn get_peripherals( &self, service_uuids: Option<&[String]>, ) -> Self::GetPeripheralsResponseFut

Source§

fn get_peripheral(&self, identifier: &str) -> Self::GetPeripheralResponseFut

Source§

fn start_scan(&self, filter: Option<&ScanFilter>) -> Self::StartScanResponseFut

Source§

fn stop_scan(&self) -> Result<(), Error>

Source§

fn connect_peripheral( &self, identifier: &str, options: &ConnectionOptions, gatt_client: ServerEnd<ClientMarker>, ) -> Self::ConnectPeripheralResponseFut

Source§

fn disconnect_peripheral( &self, identifier: &str, ) -> Self::DisconnectPeripheralResponseFut

Source§

impl Clone for CentralProxy

Source§

fn clone(&self) -> CentralProxy

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CentralProxy

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Proxy for CentralProxy

Source§

type Protocol = CentralMarker

The protocol which this Proxy controls.
Source§

fn from_channel(inner: AsyncChannel) -> Self

Create a proxy over the given channel.
Source§

fn into_channel(self) -> Result<AsyncChannel, Self>

Attempt to convert the proxy back into a channel. Read more
Source§

fn as_channel(&self) -> &AsyncChannel

Get a reference to the proxy’s underlying channel. Read more
§

fn into_client_end(self) -> Result<ClientEnd<Self::Protocol>, Self>

Attempt to convert the proxy back into a client end. Read more
§

fn is_closed(&self) -> bool

Returns true if the proxy has received the PEER_CLOSED signal.
§

fn on_closed(&self) -> OnSignals<'_, Unowned<'_, Handle>>

Returns a future that completes when the proxy receives the PEER_CLOSED signal.

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, dst: *mut T)

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

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> ProxyHasClient for T
where T: Proxy,

§

fn client(&self) -> Result<ZirconClient, Infallible>

Get a “client” for this proxy. This is just an object which has methods for a few common handle creation operations.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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