Skip to content

Library and agents to complement a Mari radio gateway

License

Notifications You must be signed in to change notification settings

openswarm-eu/marilib

 
 

Repository files navigation

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:

mira-edge-2.webm

To run with a gateway connected via UART:

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

You can see how it works using examples/mari_edge.py --help.

To run with a gateway connected via MQTT:

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

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.

Acknowledgement

Part of the source code in this repository is developed within the frame and for the purpose of the OpenSwarm project. This project has received funding from the European Unioan's Horizon Europe Framework Programme under Grant Agreement No. 101093046.

OpenSwarm - Funded by the European Union

About

Library and agents to complement a Mari radio gateway

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.6%
  • Shell 0.4%