Skip to main content

MariLib 💫 👀 🐍

MariLib is a Python library to interact with a local Mari network. It connects to a Mari gateway via:

  • UART, using MarilibEdge
  • MQTT, using MarilibCloud

Example with TUI

MariLib provides a stateful class with gateway and node information, network statistics, and a rich real-time TUI:

mari-edge-2.webm

To run with a gateway connected via UART:

# for example, using the Inria Argus MQTT broker
(.venv) $ mari-edge -m mqtts://argus.paris.inria.fr:8883

You can see how it works using mari-edge --help.

Broker credentials come from the environment, never the command line: MARI_MQTT_USER / MARI_MQTT_PASS. MARI_MQTT_INSECURE=1 skips the broker certificate check (the link stays encrypted but the broker is no longer authenticated), for a bench whose broker certificate has expired or is self-signed.

To run with a gateway connected via MQTT:

# for example, using the Inria Argus MQTT broker
(.venv) $ mari-cloud -n 0x0100 -m mqtts://argus.paris.inria.fr:8883

Reading the TUI

Most columns in the per-node table are self-explanatory (TX/RX counts, PDR, RSSI). The two that need a key:

  • Latency | host/dl/app/ul (ms) — total host-measured round-trip latency on the left of the bar, then the four-leg breakdown that sums (≈) to it:

    • host — UART round-trip plus Python parse overhead (typically 10–30 ms at 1 Mbps; sustained higher means host-side congestion).
    • dl — gateway downlink-queue wait plus one radio slot.
    • app — node-side application turnaround (e.g. how long the SwarmIT network-core main loop takes between receiving the probe and enqueueing the response).
    • ul — node uplink-queue wait plus one radio slot. This is the leg that grows when the node is saturating its uplink budget.

    Wire legs come from ASN snapshots the firmware stamps into each probe (gw_tx_enqueued_asn, node_rx_asn, node_tx_enqueued_asn, gw_rx_asn) converted via the slot duration (1.724 ms in the shipped schedules). When the firmware hasn't populated the wire ASNs the row shows total | ? / ? / ? / ?.

  • Q (sf) — estimated TX-queue depth at the node in slotframe units. Each joined node has exactly one uplink slot per slotframe, so ul_ms / sf_duration_ms is the number of packets queued ahead of the probe response when it was enqueued. Coloring: white below 2 (healthy), yellow at 2–4 (contended), red above 4 (saturated). The header panel also shows a ⚠ TX queue saturated line when any node crosses the red threshold.

Setup and dependencies

To setup the environment, do:

$ python -m venv .venv
$ source .venv/bin/activate
(.venv) $ pip install -e .

Minimal example

Here is a minimal example showcasing how to use MariLib:

import time
from marilib.marilib import MarilibEdge
from marilib.serial_uart import get_default_port

def main():
    mari = MarilibEdge(lambda event, data: print(event.name, data), get_default_port())
    while True:
        for node in mari.gateway.nodes:
            mari.send_frame(dst=node.address, payload=b"A" * 3)
        statistics = [(f"{node.address:016X}", node.stats.received_rssi_dbm()) for node in mari.gateway.nodes]
        print(f"Network statistics: {statistics}")
        time.sleep(0.25)

if __name__ == "__main__":
    main()

See it in action in examples/minimal.py.

Metadata

Release files for marilib-pkg 0.11.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 marilib-pkg 0.11.0
File Size Uploaded
marilib_pkg-0.11.0.tar.gz 58.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for marilib-pkg 0.11.0
File Interpreter ABI Platform
marilib_pkg-0.11.0-py3-none-any.whl Python 3 none any Details

Total release size: 131.1 kB

Release files / marilib_pkg-0.11.0.tar.gz

Download URL marilib_pkg-0.11.0.tar.gz
Size 58.0 kB
Tags Source
SHA-256 checksum
How to use checksums
716db126efab38814ea68b12c8918ca91f8620c3572e61df296fdee813c1b0a0
BLAKE2b-256 checksum
How to use checksums
62451ce5cecd831fdf2447ba0d8c694cd53cd165e366b5a11778ceee150b141c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / marilib_pkg-0.11.0-py3-none-any.whl

Download URL marilib_pkg-0.11.0-py3-none-any.whl
Size 73.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92b460540cb502398479c89c9a20241d0c4f6b5b527f2327c7efc7e2a49f6509
BLAKE2b-256 checksum
How to use checksums
b9195a1661140b4a484e681785071829c218a6fb4fe4cc0690d5dd118ffb077a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14
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