Skip to main content

Host-side CLI for the openbricks MicroPython firmware — flash, list, run, download, and stop code on an openbricks hub over BLE.

Project description

openbricks-dev

Host-side CLI for openbricks hubs — the same UX as pybricks-dev, built on commodity Python tooling (bleak, esptool, mpremote). One tool for flashing, scanning, and (coming) running code over BLE.

Install

Recommended — with pipx so the CLI lands in an isolated venv and avoids the "externally managed environment" error on modern macOS / Linux distros:

pipx install openbricks-dev

Plain pip works too:

pip install openbricks-dev

For development against a repo checkout (editable install):

pipx install --editable tools/openbricks-dev    # or: pip install -e tools/openbricks-dev

Any install path pulls in bleak (cross-platform BLE), esptool, and mpremote.

Commands

flash — program a hub

openbricks-dev flash \
    --name RobotA \
    --port /dev/tty.usbserial-XXXX \
    --firmware native/micropython/ports/esp32/build-openbricks_esp32s3/firmware.bin

Writes the firmware image and bakes the hub's BLE advertising name into NVS. --name is mandatory: two hubs with the same name can't be individually addressed over BLE.

Port syntax: /dev/ttyUSB0 (Linux), /dev/cu.usbserial-* (macOS), COM5 (Windows).

Useful flags: --chip esp32s3, --baud 921600, --skip-erase (faster dev loop, keeps stale NVS).

list — scan for hubs

openbricks-dev list [--timeout 5.0] [--all]

Runs a BLE scan and prints every named device found, sorted by RSSI (strongest first). --all includes unnamed devices too.

run — stage and launch; button stops it; client exits on stop

openbricks-dev run -n RobotA examples/hello.py

Stages the script to /program.py (same target as download) and triggers the hub's launcher to execute it immediately. Output streams back to your terminal in real time.

  • Button stop. Pressing the hub button while the program runs raises KeyboardInterrupt via the same launcher path download+button uses. The client sees the clean "stopped by button press" line and exits.
  • Program completion. When the program finishes (or raises), the client disconnects and exits — same as pybricks-dev run.
  • Script persists. Because run stages to /program.py, the hub can re-run the last program via a button press without another upload. download and run differ only in whether the client auto-launches after upload.

Stderr (e.g. exception tracebacks) arrives after stdout and is surfaced with a blank-line separator. No paste-mode === echo — raw-paste mode is clean.

stop — interrupt the running program

openbricks-dev stop -n RobotA

Sends a single Ctrl-C byte over the NUS REPL bridge, which MicroPython surfaces as KeyboardInterrupt. Useful when openbricks-dev run has already exited but the hub's still chewing on a long-running user program.

download — stage a script; hub button launches it

openbricks-dev download -n RobotA examples/wander.py

Writes the script to /program.py on the hub. The code does not run automatically. Place your robot, press the program button (GPIO 4), and the program starts. Press again to stop it mid-run — same UX as Pybricks Prime-hub pybricksdev download.

This works because the firmware ships a frozen main.py that:

  1. Brings BLE + REPL bridge up immediately (so openbricks-dev run / download / stop are always reachable, even when no program is running).
  2. Instantiates the board's Hub, which wires the BLE-toggle button (short-press on GPIO 5) with LED feedback.
  3. Watches the program button (GPIO 4) via openbricks.launcher.run() — a short-press runs /program.py, a second short-press raises KeyboardInterrupt in the running program.

Two separate pins (4 for program, 5 for BLE toggle), each handled by short-press only — no duration-based dispatch.

Pass --path /alt.py to stage at a different filename (if you've written your own main.py that reads from there).

Tests

cd tools/openbricks-dev
PYTHONPATH=. python -m unittest discover -s tests -t .

No real hardware needed — esptool, mpremote, and bleak are mocked.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openbricks_dev-0.9.2.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openbricks_dev-0.9.2-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file openbricks_dev-0.9.2.tar.gz.

File metadata

  • Download URL: openbricks_dev-0.9.2.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openbricks_dev-0.9.2.tar.gz
Algorithm Hash digest
SHA256 33893f7b0414ebcdc441aa272bd7f93c9f910887468ee98631ae1dc469739521
MD5 0ed37ecf737dd1296f75945167f45660
BLAKE2b-256 2ca09bd93af94c2f4fb9ed7a6f8e9e9c0bd119702d7859291e2f07111d773c42

See more details on using hashes here.

Provenance

The following attestation bundles were made for openbricks_dev-0.9.2.tar.gz:

Publisher: ci.yaml on 1e0ng/openbricks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openbricks_dev-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: openbricks_dev-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openbricks_dev-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 55d23676e1452e8c15ee2c242c9ae0e893f0fe6783d1824868c076a222a87dbf
MD5 ddf5802c37f488f6c409c4196a8e205c
BLAKE2b-256 67a70c9a99d10f1460a96b1d2c36eb302ef795335322a303bccd41d76cc47da5

See more details on using hashes here.

Provenance

The following attestation bundles were made for openbricks_dev-0.9.2-py3-none-any.whl:

Publisher: ci.yaml on 1e0ng/openbricks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page