1
0
Fork 0
mirror of https://codeberg.org/icewind/mitemp-rs.git synced 2026-06-03 09:14:07 +02:00
Read Xiaomi MI Temperature and Humidity Sensor over BLE
  • Rust 92.7%
  • Nix 7.3%
Find a file
2022-06-07 20:10:31 +02:00
examples 0.3.0 2021-10-31 18:29:35 +01:00
src bumb dependencies 2022-06-07 20:10:31 +02:00
.gitignore init repo 2020-01-18 19:37:33 +01:00
Cargo.toml bumb dependencies 2022-06-07 20:10:31 +02:00
LICENSE-APACHE read and license 2020-02-08 01:00:22 +01:00
LICENSE-MIT read and license 2020-02-08 01:00:22 +01:00
README.md 0.3.0 2021-10-31 18:29:35 +01:00

mitemp.rs

Read Xiaomi MI Temperature and Humidity Sensor over BLE

Usage

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(())
}

License

Licensed under either of

Contribution

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.