Current Lua downloadable firmware will be posted here

User avatar
By zeroday
#2906
scargill wrote:I'm struggling here.

I made sure I understood the startup file - by first simply announcing my name... great - works. And I understand that one needs to delete the file and start again to update it - that's fine.

I also know how to set the thing into WIFI mode... and os I wrote this startup file - sadly it shows 0.0.0.0 BEFORE and 0,0,0,0 AFTER. I can think of no way to use this stand-alone - if you can't set up the wifi on powerup ???

Code: Select allfile.remove("init.lua")
file.open("init.lua","w")
file.writeline([[print("Petes Tester 3")]])
file.writeline([[print(wifi.sta.getip()) ]])
file.writeline([[wifi.setmode(wifi.STATION)]])
file.writeline([[wifi.sta.config("loft-east","xxxxxxxx")]])
file.writeline([[tmr.delay(5000000)]])    -- delay
file.writeline([[print(wifi.sta.getip()) ]])
file.close()
User avatar
By scargill
#2911 I REALLY thought I'd cracked this - but the timer just keeps on ticking.... I can inject tmr.stop() via serial but as shown here as part of the setup... it doesn't stop.... just keeps repeating. Thoughts, anyone.

file.remove("init.lua")
file.open("init.lua","w")
file.writeline([[print("Petes Tester 4")]])
file.writeline([[tmr.alarm(5000, 0, function() dofile("thelot.lua") end )]])
file.close()

file.remove("thelot.lua")
file.open("thelot.lua","w")
file.writeline([[tmr.stop()]])
file.writeline([[connecttoap = function (ssid,pw)]])
file.writeline([[print(wifi.sta.getip())]])
file.writeline([[wifi.setmode(wifi.STATION)]])
file.writeline([[tmr.delay(1000000)]])
file.writeline([[wifi.sta.config(ssid,pw)]])
file.writeline([[tmr.delay(1000000)]])
file.writeline([[print("Connected to ",ssid," as ",wifi.sta.getip())]])
file.writeline([[end]])
file.writeline([[connecttoap("loft-east","xxxxxxxxx")]])
file.close()

Similarly, having stopped the timer, I can run dofile("thelot") manually and that works a treat - as many times as I like. They just don't seem to want to work properly when in the timer function - and you can't use this in the init function directly as the radio does not seem to be turned on until AFTER the init function.
User avatar
By zeroday
#2918
scargill wrote:I REALLY thought I'd cracked this - but the timer just keeps on ticking.... I can inject tmr.stop() via serial but as shown here as part of the setup... it doesn't stop.... just keeps repeating. Thoughts, anyone.

file.remove("init.lua")
file.open("init.lua","w")
file.writeline([[print("Petes Tester 4")]])
file.writeline([[tmr.alarm(5000, 0, function() dofile("thelot.lua") end )]])
file.close()

file.remove("thelot.lua")
file.open("thelot.lua","w")
file.writeline([[tmr.stop()]])
file.writeline([[connecttoap = function (ssid,pw)]])
file.writeline([[print(wifi.sta.getip())]])
file.writeline([[wifi.setmode(wifi.STATION)]])
file.writeline([[tmr.delay(1000000)]])
file.writeline([[wifi.sta.config(ssid,pw)]])
file.writeline([[tmr.delay(1000000)]])
file.writeline([[print("Connected to ",ssid," as ",wifi.sta.getip())]])
file.writeline([[end]])
file.writeline([[connecttoap("loft-east","xxxxxxxxx")]])
file.close()

Similarly, having stopped the timer, I can run dofile("thelot") manually and that works a treat - as many times as I like. They just don't seem to want to work properly when in the timer function - and you can't use this in the init function directly as the radio does not seem to be turned on until AFTER the init function.

It's not because the timer can not be stopped, but this code causes reset repeatedly, I don't know why yet.
inject
Code: Select allfile.remove("init.lua")
as soon as you can when reset, to remove init.lua.
otherwise you have to re-flash firmware.