Skip to main content
BSWorld

English | 简体中文

CI Release PyPI bscontroller License

BSWorld is a deterministic simulation framework for testing Bluetooth Hosts and Applications on Linux. A pytest scenario defines the device topology and expected behavior; BSWorld runs the participants on a shared BabbleSim radio and simulation clock, then archives logs and protocol traces.

Use BSWorld to:

  • Test open-source Host stacks such as Zephyr, NuttX, BlueZ, NimBLE, Bumble, and TrouBLE without modifying their source code.
  • Run without hardware: Hosts connect over standard H4 HCI to virtual Controllers, or complete firmware joins the PHY with its own Controller and radio.
  • Keep Application logs, HCI BTSnoop captures, PHY logs, and Ellisys traces for debugging failures.
  • Simulate many devices in one scenario. Repeated runs of the same scenario produce consistent logs and timing, regardless of host load or scheduling.
  • Share one discrete simulation clock across all devices. Scenarios are isolated and run in parallel with pytest-xdist, up to 100 times faster than real time.
  • Inject attenuation, interference, WLAN activity, and recorded radio signals.

Quick Start

BSWorld runs on Linux/x86_64. Develop in a local Linux environment, and use the published Docker images to run and verify the tests. Each platform's image holds BSWorld and that platform's compiled executables as CI tested them, without toolchains or firmware sources; the Docker guide lists them.

Docker

Install Docker Engine, then run an image's integration tests, taking the Zephyr image as an example:

sudo docker pull ghcr.io/xiaomi/bsworld-zephyr:latest
mkdir -p .cache/docker-results
# The published images run as UID/GID 1000.
sudo chown 1000:1000 .cache/docker-results
sudo docker run --rm \
  --mount "type=bind,src=$PWD/.cache/docker-results,dst=/output" \
  ghcr.io/xiaomi/bsworld-zephyr:latest

Results are written to .cache/docker-results, including pytest.xml, process logs, HCI captures, and RF traces. See the Docker guide for the NuttX, TrouBLE and Linux images, to run a selected suite, test the current checkout, choose an image version, or build an image.

Local Linux

A local environment builds the firmware and runs the tests with your own tools, so changes rebuild incrementally.

Development and test commands require Python 3.12 or newer. On Ubuntu 24.04, install the required tools:

sudo apt-get update
sudo apt-get install -y \
  bash ca-certificates curl git repo file make binutils build-essential \
  python3.12 python3.12-dev python3.12-venv python3-pip \
  gcc-multilib g++-multilib coreutils findutils grep sed

Clone and install BSWorld:

git clone https://github.com/XiaoMi/bsworld.git
cd bsworld
export BSWORLD_ROOT="$PWD"
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install -e components/bscontroller -e '.[test]'

Run the development checks:

ruff check .
ruff format --check .
pytest tests/unit tests/integration/support -q

Build and Test

Fetch the BabbleSim revisions selected by components/babblesim.xml:

mkdir -p "$BSWORLD_ROOT/.cache/babblesim"
cd "$BSWORLD_ROOT/.cache/babblesim"
repo init --standalone-manifest --depth=1 -u "file://$BSWORLD_ROOT/components/babblesim.xml"
repo sync -c --no-tags

Set the output paths and build every component:

export BSIM_OUT_PATH="$PWD/build"
export BSIM_COMPONENTS_PATH="$PWD/components"
export BSIM_BUILD_FAIL_ASAP=1
make -j"$(nproc)" everything

Export BSWORLD_ROOT, BSIM_OUT_PATH and BSIM_COMPONENTS_PATH again in every new shell that builds or runs tests; without BSIM_OUT_PATH, the integration tests stop with a setup error.

Run the Bumble and BabbleSim scenarios, which need no other binaries:

cd "$BSWORLD_ROOT"
pytest tests/integration/bumble tests/integration/babblesim -n auto

The other suites run a platform's executables. Build them with the guides in Supported Integrations, which name the variable to export for each executable.

Supported Integrations

Environment Validated behavior Guide
Zephyr Bluetooth shell Advertising and scanning, interference and recovery, connections and GATT, LL procedures, pairing and privacy, periodic advertising; complete firmware against Host-only shells on either Controller and against Bumble Zephyr tests
Bumble Python Host Advertising, scanning, connections, periodic advertising and synchronization Bumble tests
Linux and BlueZ under User Mode Linux Controller setup, advertising, scanning, connection and disconnection through the Linux Bluetooth subsystem BlueZ tests
TrouBLE Rust Host Advertising, connection, Battery Service discovery, reads and notifications TrouBLE tests
NuttX BTSak Advertising, scanning, multiple advertisers, interference and recovery BTSak tests
Apache NimBLE Discovery, connection, GATT and subscription on NuttX; discovery and connection under User Mode Linux NuttX tests · UML tests

Technical Architecture

BSWorld keeps each Application and Host stack on its native interface. Every Host connects through standard HCI to an independent Zephyr Controller process or Python BSController worker. Complete Zephyr firmware includes its own Controller and radio and joins the PHY directly; see Complete firmware. All Controllers, complete firmware and interference sources share the BabbleSim PHY and simulation clock. Native Hosts also join the PHY's clock, Bumble runs on the pytest event loop, and a User Mode Linux guest receives its clock from that loop through UML time-travel.

BSWorld participants connected through independent virtual Controllers or as complete firmware to a shared BabbleSim PHY
Figure 1: BSWorld architecture

The virtual Controllers implement HCI commands, events, ACL data, Link Layer procedures, and radio transmission and reception. A topology can mix RTOS, Python, User Mode Linux and complete Zephyr participants with either Controller implementation. See Virtual Controllers to choose and configure them.

HCI traffic is saved as hciN.snoop for Wireshark or another BTSnoop-capable tool. Radio traffic is saved as babblesim/ellisys.bttrp for Ellisys. See Logs, traces, and captures for locations and a recommended investigation order.

Discrete-Time Scheduling

Time base Meaning
Simulation time Defines protocol timers, packet timing, RF events, asyncio waits, and test timeouts. It advances only after all participants synchronize.
Wall-clock time Measures how long the test takes on the host. CPU load and Linux scheduling affect this duration but not protocol timing.

BSWorld registers Applications, Controllers, interference devices, and pytest in the same simulation. A shared synchronization barrier keeps them on one timeline, so a protocol interval such as T_IFS = 150 μs remains 150 μs regardless of host load. After topology startup, standard asyncio waits and timeouts use simulation time; see Async waiting and simulation time.

Repeatability assumes identical binaries and inputs and controlled random sources. External networks, wall-clock-driven services, and other unadapted Host I/O can still introduce nondeterminism.

Documentation

Community

License

BSWorld is licensed under the Apache License 2.0. Third-party components retain their own licenses; see Third-Party Notices.

Metadata

Release files for bsworld 1.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bsworld 1.1.6
File Size Uploaded Provenance Actions
bsworld-1.1.6.tar.gz 2.3 MB With provenance Details for bsworld-1.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bsworld 1.1.6
File Interpreter ABI Platform Actions
bsworld-1.1.6-py3-none-any.whl Python 3 none any Details for bsworld-1.1.6-py3-none-any.whl

Total release size: 2.3 MB

Release files / bsworld-1.1.6.tar.gz

Download URL bsworld-1.1.6.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
4be252b078ad56253a44dbf99586972c6fccd81d3f712e9c6d6106cbfa34fecb
BLAKE2b-256 checksum
How to use checksums
c90df55e87362e5b2f2157fbf472bfad9a580a56d212e5056d62ea0d6b03698c
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 Nov 13, 2026.

Transparency log

Release files / bsworld-1.1.6-py3-none-any.whl

Download URL bsworld-1.1.6-py3-none-any.whl
Size 51.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35d77b166bde4b5b907f138212156ce7af6d6e7506aac6e5621c3cad93faca7b
BLAKE2b-256 checksum
How to use checksums
90b547a629982eb9cd93cbaf1f50dcd70ec293c8e4e424c7f169730d9dfb4a6d
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 Nov 13, 2026.

Transparency log

Security for bsworld 1.1.6

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.

Select from 2 files

Attestation for bsworld-1.1.6.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 Nov 13, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page