nodemcu-firmware
nodemcu-firmware copied to clipboard
Add support for open networks to enduser_setup
Fixes #3374.
- [x] This PR is for the
dev
branch rather than for therelease
branch. - [x] This PR is compliant with the other contributing guidelines as well (if not, please describe why).
- [x] I have thoroughly tested my contribution.
- [x] The code changes are reflected in the documentation at
docs/*
.
I fixed the bug, making sure an open network (without password) is handled correctly. I tested it and it works perfectly.
I compiled nodemcu for the first time to fix this bug, and it was a great experience. Congratulation for such a nice compiling setup. I've been using nodemcu for years, but this is a first for me. I hope this PR is satisfactory.
Should we add in the docs of enduser_setup a complete example of an adequate boot process (init.lua)? Something like this...
print("Wating 10 seconds. Use t:stop() to cancel the init process...")
t=tmr.create()
t:alarm(10000,tmr.ALARM_SINGLE,function ()
if wifi.sta.getip() then
print("Wifi activated",wifi.sta.getip())
dofile("go.lua")
else
print("No Wifi. Starting portal...")
enduser_setup.start(
"Nodemcu setup",
function()
wifi.sta.autoconnect(1)
print("Wifi activated",wifi.sta.getip())
dofile("go.lua")
end,
function(err, str)
print("enduser_setup: Err #" .. err .. ": " .. str)
-- schedule reboot?
end
)
end
end)
It would be nice to have such an example chunk for init.lua
I compiled nodemcu for the first time to fix this bug, and it was a great experience. Congratulation for such a nice compiling setup.
Wellcome to the club!
Should we add in the docs of enduser_setup a complete example of an adequate boot process (init.lua)? Something like this...
print("Wating 10 seconds. Use t:stop() to cancel the init process...") t=tmr.create() t:alarm(10000,tmr.ALARM_SINGLE,function () if wifi.sta.getip() then print("Wifi activated",wifi.sta.getip()) dofile("go.lua") else print("No Wifi. Starting portal...") enduser_setup.start( "Nodemcu setup", function() wifi.sta.autoconnect(1) print("Wifi activated",wifi.sta.getip()) dofile("go.lua") end, function(err, str) print("enduser_setup: Err #" .. err .. ": " .. str) -- schedule reboot? end ) end end)
It would be nice to have such an example chunk for init.lua
The lua_examples folder would be a nice place for that. Maybe write a comment about what go.lua is (I can guess, but just to be clear) Also set t=nil at the end Maybe have some emphasis on waiting for Wifi too.
I think a different PR would be good for that.
The lua_examples folder would be a nice place for that.... I think a different PR would be good for that.
Yes, and then link to it from the docs.
Oh, it's already here: #3395
@blobule could you please address Gregor's comments?