diff --git a/Cargo.lock b/Cargo.lock index 25a4bff..31ffbe8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -529,6 +529,7 @@ version = "0.1.0" dependencies = [ "anyhow", "bluer", + "futures", "tokio", ] diff --git a/Cargo.toml b/Cargo.toml index 53d708b..218d080 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,4 +8,5 @@ edition = "2021" [dependencies] anyhow = "1.0.82" bluer = { version = "0.17.1", features = ["bluetoothd"] } +futures = "0.3.30" tokio = { version = "1.37.0", features = ["rt"] } diff --git a/src/main.rs b/src/main.rs index 433c1d9..4557a6d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,9 @@ use bluer::{self, monitor::Monitor}; use anyhow::Result; +use futures::StreamExt; -#[tokio::main] +#[tokio::main(flavor="current_thread")] async fn main() -> Result<()> { let session = bluer::Session::new().await?; @@ -12,10 +13,10 @@ async fn main() -> Result<()> { adapter.set_powered(true).await?; let mm = adapter.monitor().await?; - let handle = mm.register(Monitor::default()).await?; + let mut handle = mm.register(Monitor::default()).await?; while let Some(evt) = handle.next().await { - eprintln!("{}", evt); + eprintln!("{:?}", evt); } Ok(())