forked from luca/mineqtt
1
0
Fork 0
Go to file
Florian Sorg 8feda55bb8 feat: add SUBSCRIBE 2024-09-09 01:19:47 +02:00
mosquitto chore: add compose file for testing 2024-09-06 00:34:24 +02:00
.editorconfig style: add and apply editorconfig 2024-09-05 14:52:59 +02:00
README.md docs: add installation via OPPM 2024-09-06 00:25:32 +02:00
docker-compose.yml chore: add compose file for testing 2024-09-06 00:34:24 +02:00
mqtt.lua feat: add SUBSCRIBE 2024-09-09 01:19:47 +02:00

README.md

MineQTT

Installation

via OPPM

oppm register lujoga/oppm
oppm install mqtt

via interactive Lua shell

local net = require("internet"); local io = require("io"); local f = io.open("/lib/mqtt.lua", "w"); for line in net.request("https://git.luj0ga.de/luca/mineqtt/raw/branch/main/mqtt.lua") do f:write(line) end; f:flush():close()

Usage

local mqtt = require("mqtt")

local client, err = mqtt.open("mqtt.example.org", 1883)
if err ~= nil then
    error(err)
end

local err = client:connect()
if err ~= nil then
    error(err)
end

local err = client:handle()
if err ~= nil then
    error(err)
end

print(client.is_connected)

local err = client:publish("test", "Test Message Please Ignore")
if err ~= nil then
    error(err)
end

local err = client:disconnect()
if err ~= nil then
    error(err)
end