diff --git a/blatted/cli/__init__.py b/blatted/cli/__init__.py index 03ebe04..e7d1665 100644 --- a/blatted/cli/__init__.py +++ b/blatted/cli/__init__.py @@ -2,17 +2,23 @@ import click -from ..tools.ble import scanner +from ..tools.ble import scanner, monitor -@click.command() -def scan(): +@click.command(name="scan") +def scanner_cmd(): scanner.run() +@click.command(name="monitor") +def monitor_cmd(): + monitor.run() + + @click.group() def main(): pass -main.add_command(scan) +main.add_command(scanner_cmd) +main.add_command(monitor_cmd) diff --git a/blatted/tools/ble/monitor.py b/blatted/tools/ble/monitor.py new file mode 100644 index 0000000..c3777ca --- /dev/null +++ b/blatted/tools/ble/monitor.py @@ -0,0 +1,18 @@ +import asyncio + +import bleak.exc +from bleak import BleakClient, BleakGATTCharacteristic +from hexdump import hexdump +from icecream import ic + + +async def monitor_services(filter: list[str] = []): + await asyncio.sleep(.1) + + +def run(uuid_filter: list[str] = []): + print("monitor called") + try: + asyncio.run(monitor_services(uuid_filter)) + except bleak.exc.BleakDBusError as exc: + print(f"ERROR: {exc}")