mirror of
https://github.com/malmeloo/FindMy.py.git
synced 2026-04-18 00:53:56 +02:00
Add BLE device scanning functionality
This commit is contained in:
25
examples/device_scanner.py
Normal file
25
examples/device_scanner.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from findmy.scanner import OfflineFindingScanner
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
async def scan():
|
||||
scanner = await OfflineFindingScanner.create()
|
||||
|
||||
print("Scanning for FindMy-devices...")
|
||||
print()
|
||||
|
||||
async for device in scanner.scan_for(10, extend_timeout=True):
|
||||
print(f"Device - {device.mac_address}")
|
||||
print(f" Public key: {device.adv_key_b64}")
|
||||
print(f" Lookup key: {device.hashed_adv_key_b64}")
|
||||
print(f" Status byte: {device.status:x}")
|
||||
print(f" Hint byte: {device.hint:x}")
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(scan())
|
||||
Reference in New Issue
Block a user