Skip to content

Commit

Permalink
monitor example: print instead of log
Browse files Browse the repository at this point in the history
  • Loading branch information
surban committed Nov 26, 2023
1 parent 5fd6933 commit f5c0f6e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bluer/examples/le_passive_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ use futures::StreamExt;
#[tokio::main(flavor = "current_thread")]
async fn main() -> bluer::Result<()> {
env_logger::init();

let session = bluer::Session::new().await?;
let adapter = session.default_adapter().await?;
let mm = adapter.monitor().await?;
adapter.set_powered(true).await?;

let mm = adapter.monitor().await?;
let mut monitor_handle = mm
.register(Monitor {
monitor_type: bluer::monitor::Type::OrPatterns,
Expand All @@ -25,12 +27,12 @@ async fn main() -> bluer::Result<()> {

while let Some(mevt) = &monitor_handle.next().await {
if let MonitorEvent::DeviceFound(devid) = mevt {
log::info!("Discovered device {:?}", devid);
println!("Discovered device {:?}", devid);
let dev = adapter.device(devid.device)?;
tokio::spawn(async move {
let mut events = dev.events().await.unwrap();
while let Some(ev) = events.next().await {
log::info!("On device {:?}, received event {:?}", dev, ev);
println!("On device {:?}, received event {:?}", dev, ev);
}
});
}
Expand Down

0 comments on commit f5c0f6e

Please sign in to comment.