mirror of
https://github.com/malmeloo/FindMy.py.git
synced 2026-04-17 21:53:57 +02:00
Merge pull request #97 from thisiscam/nearby_device_scan_fix
add time margin when matching against nearby device
This commit is contained in:
@@ -158,7 +158,12 @@ class NearbyOfflineFindingDevice(OfflineFindingDevice):
|
||||
if isinstance(other_device, HasPublicKey):
|
||||
return other_device.adv_key_bytes.startswith(self._first_adv_key_bytes)
|
||||
if isinstance(other_device, RollingKeyPairSource):
|
||||
return any(self.is_from(key) for key in other_device.keys_at(self.detected_at))
|
||||
# 1 hour margin around the detected time
|
||||
potential_keys = other_device.keys_between(
|
||||
self.detected_at - timedelta(hours=1),
|
||||
self.detected_at + timedelta(hours=1),
|
||||
)
|
||||
return any(self.is_from(key) for key in potential_keys)
|
||||
|
||||
msg = f"Cannot compare against {type(other_device)}"
|
||||
raise ValueError(msg)
|
||||
|
||||
Reference in New Issue
Block a user