mirror of
https://github.com/fossasia/badgemagic-rs
synced 2025-06-24 07:43:58 +00:00
Remove redundant BLE service UUID check as it is already done using a ScanFilter
This commit is contained in:
parent
19db575be2
commit
71f9ab3f19
1 changed files with 6 additions and 13 deletions
19
src/ble.rs
19
src/ble.rs
|
@ -71,22 +71,15 @@ impl Device {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn from_peripheral(peripheral: Peripheral) -> Option<Self> {
|
async fn from_peripheral(peripheral: Peripheral) -> Option<Self> {
|
||||||
// Check whether the BLE device has the service UUID we're looking for
|
// The existance of the service with the correct UUID
|
||||||
// and also the correct name.
|
// exists is already checked by the scan filter.
|
||||||
// The service uuid is also by devices that are not LED badges, so
|
// But we also need to check the device name to make sure
|
||||||
// the name check is also necessary.
|
// we're talking to a badge as some devices that are not led badges
|
||||||
|
// also use the same service UUID.
|
||||||
let props = peripheral.properties().await.ok()??;
|
let props = peripheral.properties().await.ok()??;
|
||||||
|
|
||||||
let local_name = props.local_name.as_ref()?;
|
let local_name = props.local_name.as_ref()?;
|
||||||
if local_name != BADGE_BLE_DEVICE_NAME {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
if props
|
if local_name == BADGE_BLE_DEVICE_NAME {
|
||||||
.services
|
|
||||||
.iter()
|
|
||||||
.any(|uuid| *uuid == BADGE_SERVICE_UUID)
|
|
||||||
{
|
|
||||||
Some(Self { peripheral })
|
Some(Self { peripheral })
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in a new issue