Crates.io | mitemp |
lib.rs | mitemp |
version | 0.4.0 |
source | src |
created_at | 2021-10-31 17:30:36.875631 |
updated_at | 2024-11-17 16:23:54.732122 |
description | Read Xiaomi MI Temperature and Humidity Sensor over BLE |
homepage | |
repository | https://github.com/icewind1991/mitemp-rs |
max_upload_size | |
id | 474810 |
size | 52,098 |
Read Xiaomi MI Temperature and Humidity Sensor over BLE
use btleplug::api::Manager as _;
use btleplug::platform::Manager;
use mitemp::listen;
use tokio::pin;
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() -> Result<(), btleplug::Error> {
let manager = Manager::new().await?;
let adapter = manager.adapters().await?.pop().unwrap();
let stream = listen(&adapter).await?;
pin!(stream);
while let Some(sensor) = stream.next().await {
println!("{}: {:?}", sensor.mac, sensor.data);
}
Ok(())
}
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.