forked from hbldh/bleak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscover.py
42 lines (28 loc) · 834 Bytes
/
discover.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Scan/Discovery
--------------
Example showing how to scan for BLE devices.
Updated on 2019-03-25 by hbldh <[email protected]>
"""
import argparse
import asyncio
from bleak import BleakScanner
async def main(args: argparse.Namespace):
print("scanning for 5 seconds, please wait...")
devices = await BleakScanner.discover(
return_adv=True, cb=dict(use_bdaddr=args.macos_use_bdaddr)
)
for d, a in devices.values():
print()
print(d)
print("-" * len(str(d)))
print(a)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--macos-use-bdaddr",
action="store_true",
help="when true use Bluetooth address instead of UUID on macOS",
)
args = parser.parse_args()
asyncio.run(main(args))