Skip to content

Commit

Permalink
In docs use events() instead of event_receiver().
Browse files Browse the repository at this point in the history
  • Loading branch information
ratmice authored and qwandor committed Dec 23, 2021
1 parent 9500008 commit f454cc9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
12 changes: 3 additions & 9 deletions examples/event_driven_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
// connect to the adapter
let central = get_central(&manager).await;

// Each adapter can only have one event receiver. We fetch it via
// event_receiver(), which will return an option. The first time the getter
// is called, it will return Some(Receiver<CentralEvent>). After that, it
// will only return None.
//
// While this API is awkward, is is done as not to disrupt the adapter
// retrieval system in btleplug v0.x while still allowing us to use event
// streams/channels instead of callbacks. In btleplug v1.x, we'll retrieve
// channels as part of adapter construction.
// Each adapter has an event stream, we fetch via events(),
// simplifying the type, this will return what is essentially a
// Future<Result<Stream<Item=CentralEvent>>>.
let mut events = central.events().await?;

// start scanning for devices
Expand Down
4 changes: 2 additions & 2 deletions examples/lights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ async fn main() -> Result<(), Box<dyn Error>> {

// start scanning for devices
central.start_scan(ScanFilter::default()).await?;
// instead of waiting, you can use central.event_receiver() to get a channel
// to listen for notifications on.
// instead of waiting, you can use central.events() to get a stream which will
// notify you of new devices, for an example of that see examples/event_driven_discovery.rs
time::sleep(Duration::from_secs(2)).await;

// find the device we're interested in
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
//!
//! // start scanning for devices
//! central.start_scan(ScanFilter::default()).await?;
//! // instead of waiting, you can use central.event_receiver() to fetch a channel and
//! // be notified of new devices
//! // instead of waiting, you can use central.events() to get a stream which will
//! // notify you of new devices, for an example of that see examples/event_driven_discovery.rs
//! time::sleep(Duration::from_secs(2)).await;
//!
//! // find the device we're interested in
Expand Down

0 comments on commit f454cc9

Please sign in to comment.