bundle.ble ========== .. py:module:: bundle.ble .. autoapi-nested-parse:: Bundle BLE module public interface definitions. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/bundle/ble/cli/index /autoapi/bundle/ble/device/index /autoapi/bundle/ble/framing/index /autoapi/bundle/ble/link/index /autoapi/bundle/ble/manager/index /autoapi/bundle/ble/scanner/index /autoapi/bundle/ble/vendors/index Attributes ---------- .. autoapisummary:: bundle.ble.DEFAULT_SCAN_TIMEOUT Classes ------- .. autoapisummary:: bundle.ble.Advertisement bundle.ble.Device bundle.ble.FrameCodec bundle.ble.NordicLink bundle.ble.Manager bundle.ble.Scanner bundle.ble.ScanResult Package Contents ---------------- .. py:class:: Advertisement(/, **data: Any) Bases: :py:obj:`bundle.core.data.Data` Bleak advertisement adapter with convenience helpers. .. py:attribute:: raw :type: bleak.backends.scanner.AdvertisementData | None :value: None .. py:property:: local_name :type: str | None .. py:property:: rssi :type: int | None .. py:property:: tx_power :type: int | None .. py:property:: manufacturer_data :type: dict[int, bytes] .. py:property:: manufacturer_id :type: int | None .. py:property:: manufacturer_label :type: str | None .. py:property:: service_uuids :type: list[str] .. py:property:: service_labels :type: list[str] .. py:method:: info_fragments(*, limit: int = 3) -> list[str] .. py:class:: Device(/, **data: Any) Bases: :py:obj:`bundle.core.Entity` Entity describing a discovered peripheral. .. py:attribute:: name :type: str :value: None .. py:attribute:: alias :type: str | None :value: None .. py:attribute:: address :type: str :value: None .. py:attribute:: signal :type: int | None :value: None .. py:attribute:: type :type: str :value: None .. py:attribute:: manufacturer :type: str | None :value: None .. py:attribute:: services :type: list[str] :value: None .. py:attribute:: tx_power :type: int | None :value: None .. py:attribute:: local_name :type: str | None :value: None .. py:method:: from_backend(device: bleak.backends.device.BLEDevice, advertisement: bleak.backends.scanner.AdvertisementData | None) -> Device :classmethod: .. py:property:: raw_device :type: bleak.backends.device.BLEDevice | None .. py:property:: rssi_display :type: str .. py:property:: info_line :type: str .. py:method:: matches_name(query: str) -> bool .. py:class:: FrameCodec(/, **data: Any) Bases: :py:obj:`bundle.core.data.Data` Decode arbitrary BLE notification splits using a 2-byte BE header. .. py:method:: encode(payload: bytes) -> list[bytes] Wrap *payload* with its length prefix. .. py:method:: feed(chunk: bytes) -> collections.abc.Iterable[bytes] Yield every completed frame extracted from *chunk*. .. py:class:: NordicLink(*args, scanner: bundle.ble.scanner.Scanner | None = None, **kwargs) Bases: :py:obj:`bundle.core.Entity` High-level helper managing a single Nordic UART Service connection. .. py:attribute:: name :type: str :value: None .. py:attribute:: device_address :type: str | None :value: None .. py:attribute:: device_name :type: str | None :value: None .. py:attribute:: timeout :type: float :value: None .. py:method:: on_message(callback: collections.abc.Callable[[bytes], None]) -> None .. py:property:: is_connected :type: bool .. py:method:: connect() -> None :async: .. py:method:: disconnect() -> None :async: .. py:method:: send(payload: bytes) -> None :async: .. py:class:: Manager(*args, **kwargs) Bases: :py:obj:`bundle.core.Entity` Provide a compact API for scanning and opening Nordic UART links. .. py:attribute:: name :type: str :value: None .. py:attribute:: default_timeout :type: float :value: None .. py:method:: scan(*, timeout: float | None = None) -> bundle.ble.scanner.ScanResult :async: .. py:method:: open(*, device_name: str | None = None, device_address: str | None = None, timeout: float | None = None) -> bundle.ble.link.NordicLink :async: .. py:data:: DEFAULT_SCAN_TIMEOUT :value: 5.0 .. py:class:: Scanner(/, **data: Any) Bases: :py:obj:`bundle.core.Entity` Collect advertisement snapshots from nearby peripherals. .. py:attribute:: timeout :type: float :value: None .. py:method:: scan(*, timeout: float | None = None) -> ScanResult :async: .. py:class:: ScanResult(/, **data: Any) Bases: :py:obj:`bundle.core.data.Data` Entity describing a scan run and its collected devices. .. py:attribute:: timeout :type: float :value: None .. py:attribute:: devices :type: list[bundle.ble.device.Device] :value: None .. py:method:: sorted_devices() -> list[bundle.ble.device.Device] .. py:method:: lines() -> list[str]