https://github.com/fkleon/pybricks-ble
Communicate with Pybricks devices using BLE data broadcasting
https://github.com/fkleon/pybricks-ble
bluetooth-low-energy lego pybricks
Last synced: 5 months ago
JSON representation
Communicate with Pybricks devices using BLE data broadcasting
- Host: GitHub
- URL: https://github.com/fkleon/pybricks-ble
- Owner: fkleon
- License: mit
- Created: 2023-11-29T09:36:01.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-06-25T09:36:29.000Z (12 months ago)
- Last Synced: 2025-10-13T00:29:33.058Z (8 months ago)
- Topics: bluetooth-low-energy, lego, pybricks
- Language: Python
- Homepage: http://portfolio.leonhardt.co.nz/pybricks-ble/
- Size: 133 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pb_ble
A Python implementation of the [Pybricks connectionless Bluetooth messaging](https://github.com/pybricks/technical-info/blob/master/pybricks-ble-broadcast-observe.md) protocol.
## What is this?
This package was born from the need to develop, test and debug Pybricks programs that make use of connectionless messaging -- but without having a second (or third..) Pybricks Hub readily available.
It includes both command line tools and Python interfaces to send and receive Pybricks broadcast messages on a device running Linux.
To use the Bluetooth Low Energy (BLE) radio features of this library, you need:
- a BLE-capable Bluetooth adapter.
- a device running Linux with BlueZ and D-Bus (e.g. Ubuntu 20.04 or newer).
### How to use this?
- Find out more in the [📝 documentation](https://portfolio.leonhardt.co.nz/pybricks-ble)!
- Check out the [🧑💻 CLI usage examples](https://portfolio.leonhardt.co.nz/pybricks-ble/pb_ble/cli.html) or [🔧 programmatic usage example](./tools/pybricks_virtual_ble.py).
### Alternatives
If you're running a SBC or board that's Micropython-capable, check out [micropython-bleradio](https://github.com/pybricks/micropython-bleradio) from the Pybricks creators.
## Development
A `Makefile` is provided for convenience. Running one of the provided targets will create or refresh a local Python virtual environment:
* `format`: Format the code base.
* `lint`: Lint the code base.
* `typecheck`: Type-check the code base.
Alternatively, use `pip` for an editable installation of this library:
```sh
pip install --group dev -e .
```
### Testing
There are two test modes:
* unit test (default): run the test suite against a BlueZ mock service.
* integration test: run the tests suite against the real BlueZ service on your system.
#### Unit tests
Running the unit tests requires a system with D-Bus.
```sh
make test
```
#### Integration tests
Running the integration tests requires a system with D-Bus, BlueZ and a powered BLE-capable Bluetooth device.
These tests interface with BlueZ directly, so will trigger actual Bluetooth advertisements to be sent for a short time.
```sh
make integration-test
```
### Documentation
A web version of the documentation is generated with [pdoc](https://pdoc.dev/).
To run this locally:
```sh
make -C docs/ dev
```