Skip to content
XiaoMiPublic

About

Hardware-free Bluetooth simulation framework for AI agents and CI. Runs Zephyr, NuttX, NimBLE, BlueZ, Bumble, and Trouble concurrently—with deterministic results and speeds up to hundreds of times faster than real time.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

21 stars

Watchers

1 watching

Forks

BSWorld

English | 简体中文

CI PyPI bscontroller PyPI bsclock PyPI bs2g4phy PyPI bsuml License

BSWorld tests Bluetooth LE Hosts on Linux without radio hardware. A pytest test defines the devices and the radio conditions. Each Host connects over H4 HCI to its own BSController, and all Controllers share one simulated radio and one simulation clock.

  • Test open-source Host stacks without hardware or changes to their source code.
  • Repeat runs exactly. Protocol timers, radio events and test timeouts follow simulation time, not host speed.
  • Set path attenuation, inject interference or WLAN traffic, or replay recorded radio activity.
  • Debug with per-test console logs, HCI captures, radio captures and a shared Ellisys trace.

Install

BSWorld needs Linux on x86_64 and Python 3.12 or newer. Build BabbleSim with every target in the BS2G4PHY build guide, and keep BSIM_OUT_PATH set in the shell.

Install the Python 3.12 development packages.

sudo apt-get install -y python3.12-dev python3.12-venv

Clone BSWorld. The guides use BSWORLD_ROOT for the checkout path.

git clone https://github.com/XiaoMi/bsworld.git
cd bsworld
export BSWORLD_ROOT="$PWD"

Install BSWorld and its components into a virtual environment.

python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements-dev.txt

Check the setup. The suite starts a BabbleSim PHY with BSControllers and checks their captures.

pytest tests/integration/babblesim -q

In a new shell, run source .venv/bin/activate and set BSWORLD_ROOT and BSIM_OUT_PATH again.

Supported Hosts

Each suite runs the Host in a UML Guest against a Bumble peer.

Host Coverage
BlueZ Advertising from two Guests, scanning, connection and disconnection
Zephyr Bluetooth shell Scanning, advertising, GATT, pairing, privacy, link updates, periodic advertising and sync transfer
NuttX BTSak and NimBLE Advertising, scanning, recovery after interference, GATT reads, writes and notifications
Apache NimBLE Linux Advertising and connection
TrouBLE Battery Service discovery, reads and notifications in both roles

How it works

Each Host has its own BSController. Bumble runs in the pytest event loop and connects to the Controller's H4 socket. A UML Guest runs as a separate process. BSWorld bridges its Virtio Bluetooth device to the Controller and advances the Guest's clock through UML time-travel.

The Controllers, the pytest event loop and any interference sources are participants of one BabbleSim PHY, which grants simulation time to one participant at a time. After topo.start(), asyncio.sleep() and timeouts in the test count simulation time.

Bumble runs in the pytest event loop and each BSController in its own worker loop. BS2G4PHY connects the Controllers and the pytest clock to the shared BabbleSim PHY.

BSWorld is built from four components, each published on PyPI:

Component Role
BS2G4PHY Python participants on a BabbleSim 2.4 GHz PHY: process startup, device IDs, frames, attenuation and interference
BSClock An asyncio event loop that runs on simulation time
BSController A software Bluetooth LE Controller with an H4 HCI interface
BSUML User Mode Linux guests on simulation time: the time-travel calendar and a vhost-user backend for Virtio devices

Documentation

License

BSWorld is licensed under the Apache License 2.0. See Third-Party Notices for the software it builds on.

About

Hardware-free Bluetooth simulation framework for AI agents and CI. Runs Zephyr, NuttX, NimBLE, BlueZ, Bumble, and Trouble concurrently—with deterministic results and speeds up to hundreds of times faster than real time.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

21 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages