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

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.4.1
File Size Uploaded Provenance Actions
meshbench-0.4.1.tar.gz 71.2 kB With provenance Details for meshbench-0.4.1.tar.gz

Built distribution (wheel)

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

Total release size: 133.1 kB

Release files / meshbench-0.4.1.tar.gz

Download URL meshbench-0.4.1.tar.gz
Size 71.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0f550a67f3679cff5017408f4ecdc125aa945b635306833ab991dbf61b9622e2
BLAKE2b-256 checksum
How to use checksums
7bf2255e902554294bd39b79a4985ef5cf593049e24b0ebc68fb0113dcb22d81
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 Oct 30, 2026.

Transparency log

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

Download URL meshbench-0.4.1-py3-none-any.whl
Size 61.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
859f062237a860cbaed8b3393f7848e01e798ca3cc5a9289b76461c995d45884
BLAKE2b-256 checksum
How to use checksums
42dac2f1e003d7b4a8bdca9e25aa58dfde18dad8d194efe90c3b89bc3e701274
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 Oct 30, 2026.

Transparency log

Security for meshbench 0.4.1

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.4.1.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 Oct 30, 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