file.remove("luac.out.stage") -- remove stage file from last attempt
-- Do we have a new LFS blob? If so, install it.
if file.exists("luac.out") then
- print("Updating LFS image. Will reboot if things go well.")
+ print("INIT2","Updating LFS image. Will reboot if things go well.")
file.rename("luac.out", "luac.out.stage")
node.flashreload("luac.out.stage")
- error("Failed to update LFS!")
+ error("INIT2", "Failed to update LFS!")
end
-- It's early in boot, so we have plenty of RAM. Compile
local conf = sjson.decode(file.read() or "")
if type(conf) == "table"
then ctfwshw = conf
- else print("ctfws-misc.conf malformed")
+ else print("INIT2", "ctfws-misc.conf malformed")
end
end
-- Hardware initialization
-print("init2 hw")
+print("INIT2", "hw")
wifi.sta.sleeptype(wifi.NONE_SLEEP) -- don't power down radio
gpio.mode(5,gpio.OUTPUT) -- beeper on GPIO14
i2c.setup(0,2,1,i2c.SLOW) -- init i2c on GPIO4 and GPIO5
lcd = OVL.lcd1602()(ctfwshw.lcd or 0x27)
-- give the LCD time to initialize properly
-tmr.create():alarm(125, tmr.ALARM_SINGLE, function() print("init2 go3") OVL.init3() end)
+tmr.create():alarm(125, tmr.ALARM_SINGLE, function() print("INIT2", "go3") OVL.init3() end)
-- MQTT plumbing
mqc, mqttUser = OVL.nwfmqtt().mkclient("nwfmqtt.conf")
if mqc == nil then
- print("You forgot your MQTT configuration file")
+ print("CTFWS", "You forgot your MQTT configuration file")
end
local mqttBootTopic = string.format("ctfws/dev/%s/beat",mqttUser)
mqc:lwt(mqttBootTopic,"dead",1,1)
local mqtt_reconn_cronentry
local function mqtt_reconn()
- dprint("Trying reconn...")
+ dprint("CTFWS", "Trying reconn...")
mqtt_reconn_cronentry = cron.schedule("* * * * *", function(e)
mqc:close(); OVL.nwfmqtt().connect(mqc,"nwfmqtt.conf")
end)