Skip to main content

meshbench

Drive a MeshBench workbench from Python: real MeshCore firmware over a sample-accurate LoRa channel, scripted.

from datetime import timedelta

from meshbench import Workbench

with Workbench.headless(fixture="fife-strict", seed=9001) as wb:
    wb.sim.run(timedelta(minutes=5))
    print(wb.provenance())
    print(wb.events.total(), "events")

headless needs no display, no GPU and no toolkit. Workbench.attach() connects to a workbench somebody is already looking at and never closes it.

Where more than one is running, meshbench.sessions() says which: the address to connect on, the process, when it started, and what it has open. Pass a row straight to attach(). A session that was killed rather than closed is not listed, because the check is a dial of the address and not a look at a socket file or a pid.

Installing

pip install meshbench

You also need the meshbench binary on PATH — the package drives it, it does not contain it.

What it looks like

wb.project.new(place="Fife")
wb.nodes.place_many(
    [
        {"name": "R1", "kind": Kind.SIMPLE_REPEATER, "lat": 56.20, "lon": -3.20},
        {"name": "C1", "kind": Kind.COMPANION, "lat": 56.19, "lon": -3.17},
    ]
)
wb.sim.start()
wb.firmware.wait_started()  # a sensible default, or pass a timedelta

node = wb.nodes["C1"]
node.firmware = wb.firmware.find("companion-v1.17.0")
print(node.console.ask("get region"))

wb.call(verb, params) is the whole API underneath, and stays public: anything this package has not shaped is one line away rather than a blocker.

Testing firmware with it

The package registers a pytest plugin, so there is no conftest.py to copy:

def test_the_flood_reaches_glenrothes(meshbench):
    meshbench.project.open("fixtures/fixture-fife-strict.json")
    meshbench.sim.run(timedelta(minutes=5))
    assert meshbench.events.total() > 0

One workbench for the whole run — starting firmware on a real mesh is minutes, not milliseconds — with the scenario cleared between tests so reuse does not leak. --meshbench-socket attaches to one you are already running instead.

A failing test prints the provenance, whether or not it asked. Somebody reading a failed assertion about a mesh is deciding whether their firmware change broke something, and they need to know what the run assumed first.

Two things that will bite otherwise

Simulated time is not your time. Every duration here is a datetime.timedelta - Python already has a duration type, so this package does not invent one - but two different clocks are measured in them:

  • the mesh's, for sim.run(...), schedule.add(at=, every=) and sim.wait_until(at=)
  • yours, for every timeout and for sim.run(wait=)

sim.run(timedelta(minutes=5), wait=timedelta(minutes=60)) is five minutes of the mesh's clock, and up to an hour of yours waiting for it. On 155 emulated nodes that gap is the normal case, which is why they are separate arguments. Every wait has a defensible default, so wait_started() on its own is fine.

A node answers on its next loop. Its loop only runs when the engine steps, so reading a console straight after writing to it reads the moment before the command was sent. Use console.ask(), which gives the mesh its own time first.

Honesty

Every result comes out of a simulator that is kinder than the air: no multipath, no body loss, no oscillator error. The measured biases are nearly all in one direction, which is what makes a result usable — treat it as a best case. wb.provenance() says what a given run assumed, and it is meant to be printed above any number you publish.

Licence

GPL-3.0-or-later, with the rest of MeshBench.

Metadata

Release files for meshbench 0.1.0

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

Source distribution (sdist)

Source distribution for meshbench 0.1.0
File Size Uploaded Provenance Actions
meshbench-0.1.0.tar.gz 70.3 kB With provenance Details for meshbench-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 131.4 kB

Release files / meshbench-0.1.0.tar.gz

Download URL meshbench-0.1.0.tar.gz
Size 70.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9b8d3a9642eb7db32071d8a99be507b3c8ca85392749d91dee1945453d81823f
BLAKE2b-256 checksum
How to use checksums
e121e082df84ac23af3304ce413988ee4bad4fcc12c81e9fa93bfeb7774df92f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 9, 2026.

Transparency log

Release files / meshbench-0.1.0-py3-none-any.whl

Download URL meshbench-0.1.0-py3-none-any.whl
Size 61.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a8e18f8d1babbaeff79e128ada21ae686b16f68c19903ab6e0d960be96dcaeb
BLAKE2b-256 checksum
How to use checksums
a6c6a014f47c591d30b013e4e825905a8a4a15e9f8a45b1d75471bc5755dc6f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 9, 2026.

Transparency log

Security for meshbench 0.1.0

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 meshbench-0.1.0.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 Sep 9, 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