[−][src]Trait btleplug::api::Central
Central is the "client" of BLE. It's able to scan for and establish connections to peripherals.
Required methods
fn event_receiver(&self) -> Option<Receiver<CentralEvent>>
Retreive the Event Receiver for the event channel. This channel
receiver will receive notifications when events occur for this Central
module. As this uses an std::channel which cannot be cloned, after the
first call (which will contain Some<ReceiverEvent
for the full set of events returned.
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 active(&self, enabled: bool)
Control whether to use active or passive scan mode to find BLE devices. Active mode scan notifies advertises about the scan, whereas passive scan only receives data from the advertiser. Defaults to use active mode.
fn filter_duplicates(&self, enabled: bool)
Control whether to filter multiple advertisements by the same peer device. Receving can be useful for some applications. E.g. when using scan to collect information from beacons that update data frequently. Defaults to filter duplicate advertisements.
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.