btsensor

Crates.iobtsensor
lib.rsbtsensor
version0.1.1
sourcesrc
created_at2023-09-02 12:38:22.847336
updated_at2024-05-17 12:32:29.861895
descriptionA library for decoding sensor readings from BLE advertisements, including the BTHome format.
homepage
repositoryhttps://github.com/alsuren/mijia-homie/
max_upload_size
id961657
size86,922
Andrew Walbran (qwandor)

documentation

README

BLE sensor advertisement library

crates.io page docs.rs page

A library for decoding sensor readings from BLE advertisements.

Currently supports:

The actual BLE scanning is up to you, so this library doesn't depend on any particular Bluetooth library or platform. It just provides types and functions to decode the data you give it.

Usage

use std::collections::HashMap;
use btsensor::{bthome, Reading};

// In a real program, this service data would be obtained from a BLE scan.
let service_data: HashMap<Uuid, Vec<u8>> = [(
    bthome::v1::UNENCRYPTED_UUID,
    vec![0x23, 0x02, 0xC4, 0x09, 0x03, 0x03, 0xBF, 0x13],
)]
.into_iter()
.collect();

let decoded = Reading::decode(&service_data).unwrap();
println!("{}", decoded);

For a more complete example, see the examples directory.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 1669

cargo fmt