Skip to main content

MariLib is a Python library for interacting with the Mari network.

Project description

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.

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.

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

marilib_pkg-0.9.0rc1.tar.gz (39.1 kB view details)

Uploaded Source

Built Distribution

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

marilib_pkg-0.9.0rc1-py3-none-any.whl (51.8 kB view details)

Uploaded Python 3

File details

Details for the file marilib_pkg-0.9.0rc1.tar.gz.

File metadata

  • Download URL: marilib_pkg-0.9.0rc1.tar.gz
  • Upload date:
  • Size: 39.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for marilib_pkg-0.9.0rc1.tar.gz
Algorithm Hash digest
SHA256 29933906322d5cc1326dbeda945010fc9d0ae2e61742b2eff2444065591437e9
MD5 9515003b0c7fb35bfcdd0e55edf3fa13
BLAKE2b-256 7c7f4c1509c0c6135fc7ed725224667979937c23ec041148c0bfb5b9bd8c48a2

See more details on using hashes here.

File details

Details for the file marilib_pkg-0.9.0rc1-py3-none-any.whl.

File metadata

  • Download URL: marilib_pkg-0.9.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 51.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for marilib_pkg-0.9.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 7464edbc403f51d9b41fbd05a7da833d5b7d4b153b088bc8bc20168987467a6b
MD5 0fd72a54b4b8346769e6fe2394380244
BLAKE2b-256 fad674deb7becec999474235057f38739555233cd7f316b775bebe47a062be8a

See more details on using hashes here.

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