mirror of
https://codeberg.org/icewind/mitemp-rs.git
synced 2026-06-04 01:34:09 +02:00
bumb dependencies
This commit is contained in:
parent
15e70d0212
commit
a161742989
2 changed files with 12 additions and 6 deletions
11
Cargo.toml
11
Cargo.toml
|
|
@ -7,12 +7,13 @@ description = "Read Xiaomi MI Temperature and Humidity Sensor over BLE"
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
btleplug = "0.9"
|
btleplug = "0.9.2"
|
||||||
num_enum = "0.5"
|
num_enum = "0.5.7"
|
||||||
tokio-stream = "0.1"
|
tokio-stream = "0.1.8"
|
||||||
uuid = "0.8"
|
uuid = "0.8.2"
|
||||||
|
log = "0.4.16"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
main_error = "0.1"
|
main_error = "0.1"
|
||||||
env_logger = "0.9"
|
env_logger = "0.9"
|
||||||
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] }
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
pub use btleplug::api::BDAddr;
|
pub use btleplug::api::BDAddr;
|
||||||
use btleplug::api::{Central, CentralEvent, ScanFilter};
|
use btleplug::api::{Central, CentralEvent, ScanFilter};
|
||||||
|
use log::debug;
|
||||||
use num_enum::TryFromPrimitive;
|
use num_enum::TryFromPrimitive;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
@ -53,7 +54,10 @@ pub async fn listen<A: Central>(
|
||||||
|
|
||||||
Ok(event_receiver
|
Ok(event_receiver
|
||||||
.filter_map(|event| match event {
|
.filter_map(|event| match event {
|
||||||
CentralEvent::ServiceDataAdvertisement { service_data, .. } => Some(service_data),
|
CentralEvent::ServiceDataAdvertisement { service_data, id } => {
|
||||||
|
debug!("Got service data for {:?}", id);
|
||||||
|
Some(service_data)
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.filter_map(|mut service_data| service_data.remove(&UUID))
|
.filter_map(|mut service_data| service_data.remove(&UUID))
|
||||||
|
|
@ -114,6 +118,7 @@ struct InvalidServiceData;
|
||||||
fn parse_advertising_data(
|
fn parse_advertising_data(
|
||||||
service_data: &[u8],
|
service_data: &[u8],
|
||||||
) -> Result<(BDAddr, SensorUpdate), InvalidServiceData> {
|
) -> Result<(BDAddr, SensorUpdate), InvalidServiceData> {
|
||||||
|
debug!("Parsing sensor data {:?}", service_data);
|
||||||
let sensor_type = &service_data[1..4];
|
let sensor_type = &service_data[1..4];
|
||||||
if sensor_type != [0x20, 0xaa, 0x01] {
|
if sensor_type != [0x20, 0xaa, 0x01] {
|
||||||
return Err(InvalidServiceData);
|
return Err(InvalidServiceData);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue