MQTT Client Library

Description

Luanti MQTT Library 🔗

A MQTT client library for Luanti.

This is an alpha version, except bugs!

Installation 🔗

Install LuaRocks:

# On Debian:
apt install luarocks

Install luasocket & luamqtt

luarocks install luasocket
luarocks install luamqtt

You have to add the mod to the trusted mods in minetest.conf:

secure.trusted_mods = mqtt

API docs 🔗

mqtt.connect 🔗

Function to create and connect an MQTT client

  • Parameters:
    • uri: The URI of the MQTT broker to connect to
    • client_id: A unique identifier for the MQTT client
    • username: The username for authentication (optional)
    • password: The password for authentication (optional)
  • Returns:
    • client: The connected MQTT client instance. If the connection fails, it may return nil or an error message (depending on the implementation of mqtt.client)
local client = mqtt.connect(uri, clientId, username, password)

For example:

local client = mqtt.connect(
    "mqtt.example.com",
    "lunanti",
    "user1",
    "password",
)

mqtt.publish 🔗

Function to publish a message to an MQTT broker

  • Parameters:
    • client: The MQTT client instance
    • topic: The topic to publish the message to
    • payload: The message payload to be published
    • options: A table containing optional parameters
      • qos: The QoS level for message publication (default is 1)
      • retain: A boolean flag indicating whether to retain the message (default is false)
      • dup: A boolean flag indicating whether the message is a duplicate (default is false)
      • properties: A table for additional properties for publishing the message (optional)
      • user_properties: A table for user-defined properties for publishing the message (optional)
      • callback: A function to call when the published message is acknowledged (optional)
  • Returns:
    • success: true or packet id on success, or false and error message on failure
mqtt.publish(client, topic, payload, options)

Example:

mqtt.publish(client, "test/topic", "hello world!")

Reviews

Review

Do you recommend this mod?

  • No reviews, yet.

Releases

2024-12-07 07:55 UTC

0.1.2 🔗

Added german translation

All releases

Threads

New thread

Thread Last Reply

No threads found

Information

Provides

mqtt

Dependencies

Required
No required dependencies

Information

Type
Mod
Technical Name
mqtt
Languages
English, Deutsch
License
GPL-3.0-or-later for code,
CC-BY-SA-4.0 for media.
Maintenance State
Work in Progress
Added
2024-12-01 10:32 UTC
Maintainers
Tuxilio