summaryrefslogtreecommitdiffstats
path: root/src/discover.py
blob: 1632af64c1b7c17919b1113b928cd0ce901910b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import asyncio
from bleak import BleakScanner

async def discover():
    try:
        devices = await BleakScanner.discover()
        return [{"name": device.name, "address": device.address} for device in devices]
    except Exception:
        return []

async def main():
    devices = await discover()
    print(devices)

if __name__ == "__main__":
    asyncio.run(main())
git.ajschof.me — hosted by ajschofield — powered by cgit