diff --git a/main.lua b/main.lua index 4028a29..eb73ea3 100644 --- a/main.lua +++ b/main.lua @@ -135,6 +135,12 @@ function normalOperation() alive = alive + 1 end 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) else -- set FG to fix value: RED @@ -153,7 +159,7 @@ function normalOperation() local connect_counter=0 -- Wait to be connect to the WiFi access point. 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 if wifi.sta.status() ~= 5 then print(connect_counter .. "/60 Connecting to AP...") diff --git a/mqtt.lua b/mqtt.lua index 987cdff..5305493 100644 --- a/mqtt.lua +++ b/mqtt.lua @@ -145,6 +145,10 @@ function registerMqtt() end) end +function connectedMqtt() + return mqttConnected +end + function startMqttClient() if (mqttServer ~= nil and mqttPrefix ~= nil) then registerMqtt()