SiFi Bridge Python
A Python wrapper over the SiFi Bridge CLI for talking to SiFi Labs devices (BioPoint, SiFiBand, SiFiBand Focus).
Installing
pip install sifi-bridge-py
The sifibridge CLI binary ships bundled per platform via the sifibridge-bin wheel.
Quickstart
from sifi_bridge_py import SifiBridge
with SifiBridge() as sb:
# connect() returns False on no-match, so it is safe to retry in a loop
while not sb.connect():
pass
sb.configure_sensors(emg=True)
sb.configure_emg(fs=1000, mains_notch=60)
sb.start()
for _ in range(50):
packet = sb.get_emg(timeout=2.0)
if not packet:
continue # timed out, no data this tick
print(packet.get("sample_rate"), packet["data"]["emg"][:4])
sb.stop()
sample_rate is measured live and takes two samples to establish, so it is
absent from the first packet of a stream rather than reported as zero. samples_lost is omitted on a healthy packet.
SifiBridge is a context manager, so leaving the with block closes the data socket and shuts down the subprocess. If you can't use with, call sb.close() explicitly when done.
Configuration is incremental
Most methods' parameters default to None. Only specified parameters are actually applied for incremental configuration.
sb.configure_emg(fs=2000, mains_notch=50, bandpass=True, flo=20, fhi=450)
sb.configure_emg(fs=1000) # changes the rate; the filters above are untouched
Targeting several devices
Every device command accepts all=True (apply to every connected device) or devices=[...] (apply to the named handles, either by device ID or name):
sb.configure_emg(fs=1000, all=True)
sb.start(devices=["left_arm", "right_arm"])
When you target more than one device, sifibridge answers with an aggregated response, so these calls return a list of per-device responses instead of the single-device value. start(), stop() and send_event() return True/False for one device and a list for several.
Library overview
Lifecycle
SifiBridge(use_lsl=False)spawns the process. Passuse_lsl=Trueto also stream data to Lab Streaming Layer.sb.close()(orwithblock exit) terminates the subprocess.
Discovery & connection
sb.list_devices(ListSources.BLE | .SERIAL | .DEVICES)returns one dict per device (id,name, …).sb.connect(handle=None)connects to any available device, or to a specific BLE name, MAC address (Linux/Windows) or UUID (macOS). ReturnsTrueon success,Falseif nothing matched in time.sb.disconnect()closes the link and drops the session.sb.select_device(handle)switches which connected device subsequent commands target.sb.rename_device(name)gives the device a custom BLE name (max 14 bytes);sb.rename_device(None)resets it.
Device information
sb.info()returns everything sifibridge knows about the active device. Almost all of it is nested underconfiguration—info()itself carries onlyid,name,deviceandconnected.sb.get_configuration()returns that block;sb.get_active_device(),sb.get_sensors()(the hardware inventory),sb.get_sensor_states()(what is currently enabled),sb.get_device_state()andsb.get_battery()are shortcuts into it.
Sensor configuration
sb.configure_sensors(ecg=…, emg=…, eda=…, imu=…, ppg=…)toggles which sensors stream.sb.configure_ecg(...),configure_emg(...),configure_eda(...),configure_imu(...),configure_ppg(...),configure_temperature(...)set per-sensor sampling rate, filtering and ranges.sb.set_onboard_filtering(enable),sb.set_high_gain(enable),sb.set_low_latency_mode(on),sb.set_night_mode(on),sb.set_ble_power(BleTxPower.LOW|MEDIUM|HIGH).sb.set_memory_mode(MemoryMode.STREAMING | DEVICE | BOTH)controls whether data streams over BLE, lands on onboard flash, or both.
PPG is configured through the two hardware primitives: sps (raw AFE rate) and avg (averaging factor). The effective output rate is sps / avg, and the wrapper caps it at 200 Hz.
You can directly set a target sampling rate with sb.configure_ppg_fs(fs), which solves for a (sps, avg) pair that delivers it, preferring the most averaging (the cleanest signal) unless you pass avg yourself. Reachable rates are 25, 50, 100 and 200 Hz.
sb.configure_ppg_fs(100) # sps=800, avg=8 — most averaging
sb.configure_ppg_fs(100, avg=1) # sps=100, avg=1 — least LED duty
Temperature has no enable of its own and is not part of configure_sensors, but the device only emits it alongside an otherwise active acquisition, so at least one other sensor must be on.
Acquisition & data
sb.start(set_default=False)/sb.stop()toggle streaming.set_default=Truestores the current configuration as the device's power-on default.sb.get_ecg(timeout=…),get_emg,get_eda,get_imu,get_ppg,get_temperature,get_eventpop the next packet of that sensor. Each sensor has its own internal queue, so callingget_ecg()does not drop EMG data that arrived in between. Returns{}on timeout. NOTE: each packet is also routed to a generic queue read byget_data()— don't mix the two APIs on the same instance, or you'll see duplicates.sb.clear_data_buffer()drains all internal queues.DataPacket.from_dict(packet)wraps a packet dict in a typed view when attribute access reads better than key lookups.sb.send_event()emits a software event, which arrives in the stream as aneventpacket timestamped on the device — useful for marking experiment landmarks.sb.set_status_updates(on)toggles the ~1 Hz status packets (battery, memory used, device state).
Buffers & onboard memory
2.0.0 routes all recorded data through a buffering subsystem; exporting to disk is a separate step.
sb.buffer_list(),sb.buffer_info()inspect buffered acquisitions.sb.buffer_pull(sensor, last_seconds=…)pulls samples back into Python.sb.buffer_export(fmt="csv"|"hdf5", output_dir=…)writes them to disk.sb.buffer_clear(all=True)frees them.sb.download_memory_ble(output_dir)/sb.download_memory_serial(port, output_dir)pull the device's onboard flash into the buffers and export it in one call. These block; a full flash over BLE takes hours.sb.erase_onboard_memory(format=False)wipes the recordings;format=Truefully formats the flash.
Device controls
sb.set_led(index, on),sb.set_motor(on),sb.set_motor_intensity(level)(1–10)sb.power_off()sb.dfu(package_path)updates the device firmware over BLE.
Typed packets
The getters return plain dicts. When that gets tedious, wrap one:
from sifi_bridge_py import BioChannel, DataPacket, PacketType
raw = sb.get_imu(timeout=2.0)
if raw:
packet = DataPacket.from_dict(raw)
print(packet.sample_rate, packet.samples_lost, packet.channels)
qw = packet.channel(BioChannel.QW)
imu = packet.as_array() # (n_channels, n_samples) float array
if packet.is_type(PacketType.IMU) and packet.is_ok:
...
sample_rate is None rather than 0.0 until the rate has been measured, and unmodelled fields stay reachable on packet.raw.
Timestamps
Sample timestamps are relative to the start of the acquisition, in seconds. The first sample of a stream is at 0.0. The acquisition's Unix epoch start arrives once, on the start_time packet:
from sifi_bridge_py.utils import get_start_time, absolute_timestamps
start = None
while start is None:
packet = sb.get_data()
if packet.get("packet_type") == "start_time":
start = get_start_time(packet)
emg = sb.get_emg()
t = absolute_timestamps(emg, start) # one Unix epoch timestamp per sample
Don't use a packet's received_at for this: that is when the host received the packet (time of arrival).
Error handling
from sifi_bridge_py import SifiBridgeError, SifiBridgeTimeout
SifiBridgeTimeout(subclass ofSifiBridgeError) — the CLI didn't reply within the timeout. Retry-friendly.connect()already catches this internally and returnsFalse.SifiBridgeError— the CLI returned an explicit{"error": ...}response. Indicates malformed input or an unsupported operation.
Catch SifiBridgeTimeout specifically when you want to distinguish "still trying" from "broken":
try:
sb.configure_emg(fs=1000)
except SifiBridgeTimeout:
# CLI is wedged — back off and retry
...
except SifiBridgeError:
# Bad arguments — surface to the user
raise
Migrating from 1.x
SiFi Bridge 2.0.0 reworked the REPL, so this is a breaking release. The changes you are most likely to hit:
| 1.x | 2.0.0 |
|---|---|
sb.show() |
sb.info() |
new / delete device managers |
gone — connect() creates the session, disconnect() removes it |
configure_channels(...) |
configure_sensors(...) |
configure_* defaults overwrote every setting |
omitted parameters are left untouched |
configure_imu(gyro_range=…) |
removed; the FIFO pins the gyro full scale per IMU part |
configure_imu(accel_range=2|4|8|16) |
8 or 16 only |
configure_ppg(iir=…, ired=…) |
configure_ppg(ir=…, red=…), capped at sps/avg ≤ 200 Hz |
start_status_updates() / stop_status_updates() |
set_status_updates(on) |
start_memory_download() + memory packets |
download_memory_ble() / download_memory_serial() |
| CSV publisher wrote files as data arrived | record into buffers, then buffer_export() |
list_devices() returned names |
returns dicts with id and name |
BioPoint_v1_1 … BioPoint_v1_3 device types |
a single BioPoint; revisions are in info() |
Packet fields moved too: data_lost_count → samples_lost, and the packet's arrival time timestamp → received_at, with a new per-sample timestamps array. The full list is in the SiFi Bridge changelog.
Examples
Examples are available on our documentation website.
Advanced usage
The wrapper exposes the common surface, but the underlying CLI has more. To explore, run sifibridge -p interactively and type help. Anything you find there can also be reached from Python by subclassing SifiBridge and calling self._request("…") directly — _request takes a raw command line, so quote any value carrying a space or ; yourself (shlex.quote, or self._quote(value, "…"), which also rejects the newline the REPL cannot carry). The REPL command reference is documented at docs.sifilabs.com/cli.
Tests
The suite is in three tiers:
uv run python -m unittest tests.test_unit -v # no binary, no hardware
uv run python -m unittest tests.test_integration -v # spawns a real sifibridge
SIFI_HW=BioPoint uv run python -m unittest tests.test_hardware -v # needs a device
Tier 1 and Tier 2 run in CI on every push. Tier 2 also feeds every command line the wrapper can generate to a real sifibridge and asserts it parses. The wrapper builds those lines as strings, so a renamed or removed CLI flag is otherwise invisible until runtime. Tier 3 requires a powered-on device and is requires the SIFI_HW environment variable.
Versioning
The wrapper is updated for every SiFi Bridge release. Major and minor versions are kept in lockstep with the CLI; patch versions vary for project-specific fixes.
Local development
See DEVELOPMENT.md for setup. The short version:
export SIFIBRIDGE_EXE=./sifibridge # point to a local CLI build
uv sync
Deployment
NOTE: If you add new enums or types, re-export them in sifi_bridge_py/__init__.py.
Publishing sifibridge-bin
- Update
versioninsifibridge-bin/pyproject.toml - Build wheels:
cd sifibridge-bin && python scripts/build_wheels.py <release-tag> - Publish:
uv publish dist/*or push abin-<version>tag
Publishing sifi-bridge-py
- Update
versioninpyproject.toml(and thesifibridge-binpin if needed) - Update
SIFIBRIDGE_VERSIONin.github/workflows/tests.ymlif the targeted CLI release changed - Run the tests
- Push a version tag (e.g.
2.0.0) tomain— CI handles the rest
sifibridge-bin must be on PyPI before publishing a sifi-bridge-py version that depends on it.
Metadata
Release files for sifi-bridge-py 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sifi_bridge_py-2.0.2.tar.gz | 103.0 kB | With provenance | Details for sifi_bridge_py-2.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sifi_bridge_py-2.0.2-py3-none-any.whl | Python 3 | none | any | Details for sifi_bridge_py-2.0.2-py3-none-any.whl |
Total release size: 133.1 kB
Release files / sifi_bridge_py-2.0.2.tar.gz
| Download URL | sifi_bridge_py-2.0.2.tar.gz |
|---|---|
| Size | 103.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3f6226591fa6d575aadb842a36ca8dd671017a2796b7642af7b461adfe3cc40
|
|
BLAKE2b-256 checksum How to use checksums |
058ac3e2442f4847e1cd5c402015eddfe3628f4bf844ade59fc59869e2c0687a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logRelease files / sifi_bridge_py-2.0.2-py3-none-any.whl
| Download URL | sifi_bridge_py-2.0.2-py3-none-any.whl |
|---|---|
| Size | 30.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
33c04ccaf664da45aff19fe6fad23962beee84a5407774dd4686ce78b329dcc8
|
|
BLAKE2b-256 checksum How to use checksums |
b95ac9e1d2c89a7d14c4ecd821d937689dc2ee3de375f926b7ca1308f40557dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logSecurity for sifi-bridge-py 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sifi_bridge_py-2.0.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.