change to get raw data from the get data function
This commit is contained in:
parent
025e39f000
commit
2a6f878371
11
src/lib.rs
11
src/lib.rs
@ -23,17 +23,20 @@ pub async fn find_infinitime(adapter: &Adapter) -> Option<Peripheral> {
|
||||
return None;
|
||||
}
|
||||
|
||||
async fn get_property_value(infinitime: &Peripheral, property: Uuid) -> String {
|
||||
async fn get_property_value(infinitime: &Peripheral, property: Uuid) -> Vec<u8> {
|
||||
let chars = infinitime.characteristics();
|
||||
let cmd_char = chars.iter().find(|c| c.uuid == property).unwrap();
|
||||
let result = infinitime.read(cmd_char).await.unwrap();
|
||||
|
||||
return String::from_utf8(result).expect("Invalid UTF-8");
|
||||
return result;
|
||||
}
|
||||
|
||||
pub async fn get_firmware_version(infinitime: &Peripheral) -> String {
|
||||
return get_property_value(infinitime, FIRMWARE_VERSION_UUID).await;
|
||||
let data = get_property_value(infinitime, FIRMWARE_VERSION_UUID).await;
|
||||
return String::from_utf8(data).expect("Found invalid UTF-8");
|
||||
}
|
||||
pub async fn get_battery_level(infinitime: &Peripheral) -> String {
|
||||
return get_property_value(infinitime, BATTERY_LEVEL_UUID).await;
|
||||
let data = get_property_value(infinitime, BATTERY_LEVEL_UUID).await;
|
||||
let percent = data[0];
|
||||
return percent.to_string();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user