Skip to content

Python API

Autogenerated reference for the Python bindings exposed by bitalino_rs.

Key objects you will see here:

  • Bitalino: connect, start/stop streaming, read frames/batches, query device state.
  • Frame / FrameBatch: data containers with CRC and sequence-gap metadata.
  • DeviceState: on-demand snapshot for BITalino 2.0+ devices.

BITalino driver with Python bindings.

Layout and intent

The Python package is a thin, well-typed façade over the Rust core compiled as _bitalino_core. Everything is grouped by concern:

  • device: High-level driver that wraps Bluetooth/serial I/O and exposes the stateful operations you call from Python.
  • models: Immutable data carriers (frames, batches, device state) and the allowed sampling-rate literals used across the API surface.
  • logging: Opt-in helpers that bridge Rust logs into Python's logging ecosystem so you can watch the driver internals during debugging or capture them alongside your application logs.

What happens under the hood

The Rust layer (pyo3/abi3) owns the heavy lifting:

  • RFCOMM transport: uses a raw RFCOMM socket (device must be pre-paired/trusted and you pass the MAC). No BlueZ/tokio/dbus stack is required at build or runtime.
  • Acquisition runs on the device crystal; the driver reconstructs timing from sequence numbers and host timestamps, surfacing CRC and gap counts via FrameBatch.
  • Battery/state helpers are available only on BITalino 2.0+ and guard against invalid modes.

Typical usage

from bitalino_rs import Bitalino, enable_rust_logs enable_rust_logs("info") # bridge Rust logs into Python's logging dev = Bitalino.connect("12:D3:51:FE:6F:A3") dev.start(rate=1000, channels=[0, 1, 2]) frames = dev.read(100) dev.stop()

enable_rust_logs(level: str | None = None) -> None

Enable Rust-side logging bridged into Python's logging module.

reset_log_cache() -> None

Clear cached Python logger lookups after reconfiguring logging.