Skip to content

Commit

Permalink
Merge pull request #97 from thisiscam/nearby_device_scan_fix
Browse files Browse the repository at this point in the history
add time margin when matching against nearby device
  • Loading branch information
malmeloo authored Jan 23, 2025
2 parents 5cd53fb + 010ff02 commit 58b42ba
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion findmy/scanner/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ def is_from(self, other_device: HasPublicKey | RollingKeyPairSource) -> bool:
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)
Expand Down

0 comments on commit 58b42ba

Please # to comment.