Crates.io | btsensor |
lib.rs | btsensor |
version | 0.1.1 |
source | src |
created_at | 2023-09-02 12:38:22.847336 |
updated_at | 2024-05-17 12:32:29.861895 |
description | A library for decoding sensor readings from BLE advertisements, including the BTHome format. |
homepage | |
repository | https://github.com/alsuren/mijia-homie/ |
max_upload_size | |
id | 961657 |
size | 86,922 |
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.
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.
Licensed under either of
at your option.
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.