Removed usage of callback parameter

This commit is contained in:
Ollo 2021-04-03 12:42:23 +02:00
parent e497bbe48e
commit 6fbaec749a

View File

@ -121,22 +121,22 @@ function registerMqtt()
mqttConnected = false mqttConnected = false
end end
) )
m:connect(mqttServer, 1883, false, function(client) m:connect(mqttServer, 1883, false, function(c)
print("MQTT is connected") print("MQTT is connected")
mqttConnected = true mqttConnected = true
-- subscribe topic with qos = 0 -- subscribe topic with qos = 0
client:subscribe(mqttPrefix .. "/cmd/#", 0) m:subscribe(mqttPrefix .. "/cmd/#", 0)
local mytimer = tmr.create() local tmr1 = tmr.create()
mytimer:register(1000, tmr.ALARM_SINGLE, function (t) tmr1:register(1000, tmr.ALARM_SINGLE, function (t)
-- publish a message with data = hello, QoS = 0, retain = 0 -- publish a message with data = hello, QoS = 0, retain = 0
client:publish(mqttPrefix .. "/ip", tostring(wifi.sta.getip()), 0, 0) m:publish(mqttPrefix .. "/ip", tostring(wifi.sta.getip()), 0, 0)
local red = string.byte(colorBg,2) local red = string.byte(colorBg,2)
local green = string.byte(colorBg,1) local green = string.byte(colorBg,1)
local blue = string.byte(colorBg,3) local blue = string.byte(colorBg,3)
client:publish(mqttPrefix .. "/background", tostring(red) .. "," .. tostring(green) .. "," .. tostring(blue), 0, 0) m:publish(mqttPrefix .. "/background", tostring(red) .. "," .. tostring(green) .. "," .. tostring(blue), 0, 0)
t:unregister() tmr1:unregister()
end) end)
mytimer:start() tmr1:start()
end, end,
function(client, reason) function(client, reason)
print("failed reason: " .. reason) print("failed reason: " .. reason)