Skip to main content

Bridge to connect IOT-LAB to a MQTT broker

Project description

IoT-lab to MQTT bridge

This module provides an easy way to redirect the input/output of the serial ports of iot-lab nodes to a MQTT broker.

The core of the module is a script intended to be run on an iotlab ssh frontend. Utilities are provided to help you run that script on the server automatically when the experiment start.

Installation

pip3 install iotlab_mqtt_bridge

On your own computer you will not be able to launch the module directly, but you will be able to use the module in scripts (see Examples).

On iotlab ssh frontends, the script may already be installed by your local admin (toulouse.iot-lab.info for example). If not, you can ask them or install it in your home directory.

Options

See iotlab-mqtt-bridge --help for detailed options. Notably, the following parameters of the bridge can be configured :

  • broker (IP, broker port, encryption certificate, authentification)
  • verbosity
  • topic root (topic_root hereafter) is used to construct individual node topics.
  • ID dictionnary (json file) used to convert iotlab IDs to a custom set of ids (each must be unique).

The arguments not described in iotlab-mqtt-bridge --help are passed down the serial_aggregator (on which this project is based).

Node topics

Each individual node topic root is constructed as follow :

  1. The local node name is extracted from its address. Ex: dwm1001-1.toulouse.iot-lab.info becomes dwm1001-1
  2. If an ID dictionnary was provided, this local node name (dwm1001-1 in our example) is used as a key in the dictionnary to determine the new identifier, otherwise the local name is used as identifier.
  3. topic_root is prepended to this identifier to form the node_topic

Node output handling

The serial output of each node is split into substrings at every '\n' character, then each substring is published in a single message (containing also the node id and a timestamp) on a specific topic (<node_topic>/out) for each node.

If this substring can be parsed as a JSON object, it is also published on a second topic (<node_topic>/out_json). The payload of messages on the latter topic are thus guaranteed to be valid json objects.

Node input handling

Each message published on <node_topic>/in gets written directly on the serial port of the associated node.

Examples

On site ssh frontend

Run on iotlab ssh frontend : python3 -m iotlab_mqtt_bridge -b <x.x.x.x> -u <broker_username> -p <broker_password> -t "topic_root/"

If TLS is used on the broker, it may be necessary to use the argument -C <ca_cert>.

If iotlab-mqtt-bridge is already installed, running iotlab-mqtt-bridge without arguments will bridge the serial ports to mqtt4.iot-lab.info (it requires that you run iotlab-auth at least once before).

In python script

See examples/script_launcher.py in module directory.

Known issues

  • The serial port can be opened only once. Consquently :
    • A given node can be bridged by only one iotlab_mqtt_bridge at a time
    • Web serial consoles must be closed before starting the MQTT bridge
    • serial_aggregator can not access a given node at the same time as iotlab\_mqtt\_bridge
  • Serial ports can be disturbed when nodes are flashed, so it may be necessary to restart iotlab\_mqtt\_bridge after re-flashing the nodes.

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

iotlab_mqtt_bridge-0.1.22.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

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

iotlab_mqtt_bridge-0.1.22-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file iotlab_mqtt_bridge-0.1.22.tar.gz.

File metadata

  • Download URL: iotlab_mqtt_bridge-0.1.22.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for iotlab_mqtt_bridge-0.1.22.tar.gz
Algorithm Hash digest
SHA256 fb4ebe4ff812143ba8c17c34bb44d6395aeee40f2b352dbba96f04a27749e891
MD5 1c35a7b31213a3bb9f48184d7e6ac793
BLAKE2b-256 442a1ce91768a8e87e5763b436b9001703d9ebd316621c3bcc0ef9ae5cef0763

See more details on using hashes here.

File details

Details for the file iotlab_mqtt_bridge-0.1.22-py3-none-any.whl.

File metadata

File hashes

Hashes for iotlab_mqtt_bridge-0.1.22-py3-none-any.whl
Algorithm Hash digest
SHA256 f19d867cbaa70da08e01ab2991dc95c519b35a70782ff6ca1850b3955ab09729
MD5 90138095907b05de634ee6f114381438
BLAKE2b-256 bed7ff236942b3b59d9511cbe0c14b8216b300398928a58fd7a36431fe55e50c

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