Trait rumble::api::Central
[−]
[src]
pub trait Central<P: Peripheral>: Send + Sync + Clone { fn on_event(&self, handler: EventHandler); fn start_scan(&self) -> Result<()>; fn stop_scan(&self) -> Result<()>; fn peripherals(&self) -> Vec<P>; fn peripheral(&self, address: BDAddr) -> Option<P>; }
Central is the "client" of BLE. It's able to scan for and establish connections to peripherals.
Required Methods
fn on_event(&self, handler: EventHandler)
Registers a function that will receive notifications when events occur for this Central
module. See Event
for the full set of events. Note that the
handler will be called in a common thread, so it should not block.
fn start_scan(&self) -> Result<()>
Starts a scan for BLE devices. This scan will generally continue until explicitly stopped,
although this may depend on your bluetooth adapter. Discovered devices will be announced
to subscribers of on_event
and will be available via peripherals()
.
fn stop_scan(&self) -> Result<()>
Stops scanning for BLE devices.
fn peripherals(&self) -> Vec<P>
Returns the list of Peripherals
that have been discovered so far.
Note that this list may contain peripherals that are no longer available.
fn peripheral(&self, address: BDAddr) -> Option<P>
Returns a particular Peripheral
by its address if it has been
discovered.