Status of mqtt connection

This commit is contained in:
Ollo 2021-03-21 18:00:07 +01:00
parent 3832e89afa
commit c513f7c899
2 changed files with 11 additions and 1 deletions

View File

@ -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...")

View File

@ -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()