File: reset.py

package info (click to toggle)
python-usb-devices 0.4.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 292 kB
  • sloc: python: 174; makefile: 15; javascript: 8; sh: 5
file content (25 lines) | stat: -rw-r--r-- 634 bytes parent folder | download
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
import asyncio
import logging

from usb_devices import BluetoothDevice, NotAUSBDeviceError

logging.basicConfig(level=logging.INFO)
logging.getLogger("usb_devices").setLevel(logging.DEBUG)


async def run(device: int) -> None:
    dev = BluetoothDevice(device)
    try:
        reset_ok = await dev.async_reset()
    except NotAUSBDeviceError:
        print(f"hci{device} is not a USB device")
    except FileNotFoundError:
        print(f"hci{device} not found")
    else:
        if reset_ok:
            print(f"Reset of hci{device} succeeded")
        else:
            print(f"Reset of hci{device} failed")


asyncio.run(run(0))