Skip to content

Commit 71f9ab3

Browse files
hlxidmgjm
authored andcommitted
Remove redundant BLE service UUID check as it is already done using a ScanFilter
1 parent 19db575 commit 71f9ab3

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/ble.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,15 @@ impl Device {
7171
}
7272

7373
async fn from_peripheral(peripheral: Peripheral) -> Option<Self> {
74-
// Check whether the BLE device has the service UUID we're looking for
75-
// and also the correct name.
76-
// The service uuid is also by devices that are not LED badges, so
77-
// the name check is also necessary.
74+
// The existance of the service with the correct UUID
75+
// exists is already checked by the scan filter.
76+
// But we also need to check the device name to make sure
77+
// we're talking to a badge as some devices that are not led badges
78+
// also use the same service UUID.
7879
let props = peripheral.properties().await.ok()??;
79-
8080
let local_name = props.local_name.as_ref()?;
81-
if local_name != BADGE_BLE_DEVICE_NAME {
82-
return None;
83-
}
8481

85-
if props
86-
.services
87-
.iter()
88-
.any(|uuid| *uuid == BADGE_SERVICE_UUID)
89-
{
82+
if local_name == BADGE_BLE_DEVICE_NAME {
9083
Some(Self { peripheral })
9184
} else {
9285
None

0 commit comments

Comments
 (0)