bledev.auto

Optional backend selection. Nothing in bledev imports this module.

import bledev.auto ble = bledev.auto.adapter()

picks, in order: mpble where MicroPython’s bluetooth module exists, cpble where CircuitPython’s _bleio does, webble in a browser (PyScript, Pyodide, the Workbench simulator), and bleak on CPython when bleak is installed (pip install omnipython[ble]). Pass backend="fake" (or set BLEDEV_BACKEND) to force one; extra keyword arguments go to the backend’s constructor.

A host with none raises bledev.UnsupportedError saying what to install.

bledev.auto.BACKENDS = {'bleak': ('bledev.bleak', 'BleakBLE'), 'cpble': ('bledev.cpble', 'CPBLE'), 'fake': ('bledev.fake', 'FakeBLE'), 'mpble': ('bledev.mpble', 'MPBLE'), 'webble': ('bledev.webble', 'WebBLE')}

backend name -> (module, class). Each module stands alone and never imports this one.

bledev.auto.backend_name()[source]

The backend this host would get, or None if it has no BLE.

bledev.auto.adapter(backend=None, **kwargs)[source]

Construct the adapter for this host (or for backend).