Status of mqtt connection
This commit is contained in:
parent
3832e89afa
commit
c513f7c899
8
main.lua
8
main.lua
@ -135,6 +135,12 @@ function normalOperation()
|
|||||||
alive = alive + 1
|
alive = alive + 1
|
||||||
end
|
end
|
||||||
if (rgbBuffer ~= nil) then
|
if (rgbBuffer ~= nil) then
|
||||||
|
-- show Mqtt status
|
||||||
|
if (startMqttClient ~= nil) then
|
||||||
|
if (not connectedMqtt()) then
|
||||||
|
rgbBuffer:set(110-4, 128,0,0)
|
||||||
|
end
|
||||||
|
end
|
||||||
ws2812.write(rgbBuffer)
|
ws2812.write(rgbBuffer)
|
||||||
else
|
else
|
||||||
-- set FG to fix value: RED
|
-- set FG to fix value: RED
|
||||||
@ -153,7 +159,7 @@ function normalOperation()
|
|||||||
local connect_counter=0
|
local connect_counter=0
|
||||||
-- Wait to be connect to the WiFi access point.
|
-- Wait to be connect to the WiFi access point.
|
||||||
local wifitimer = tmr.create()
|
local wifitimer = tmr.create()
|
||||||
wifitimer:register(2000, tmr.ALARM_AUTO, function (timer)
|
wifitimer:register(500, tmr.ALARM_AUTO, function (timer)
|
||||||
connect_counter=connect_counter+1
|
connect_counter=connect_counter+1
|
||||||
if wifi.sta.status() ~= 5 then
|
if wifi.sta.status() ~= 5 then
|
||||||
print(connect_counter .. "/60 Connecting to AP...")
|
print(connect_counter .. "/60 Connecting to AP...")
|
||||||
|
4
mqtt.lua
4
mqtt.lua
@ -145,6 +145,10 @@ function registerMqtt()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function connectedMqtt()
|
||||||
|
return mqttConnected
|
||||||
|
end
|
||||||
|
|
||||||
function startMqttClient()
|
function startMqttClient()
|
||||||
if (mqttServer ~= nil and mqttPrefix ~= nil) then
|
if (mqttServer ~= nil and mqttPrefix ~= nil) then
|
||||||
registerMqtt()
|
registerMqtt()
|
||||||
|
Loading…
Reference in New Issue
Block a user