how to connect?
Posted: Wed Mar 25, 2015 5:52 pm
hello,
I've been googling and sursing here a solution to connect to my Lan.
here is my code:
I tried different combinaisons
wifi.setmode(wifi.STATIONAP);
wifi.setmode(wifi.STATION);
wifi.setmode(wifi.SOFTAP);
wifi.sta.connect();
wifi.sta.autoconnect(1);
or both in comment
but no way
here is always the same result:
but if I do it manually in lualoader:
It works..
Any help appracied
I've been googling and sursing here a solution to connect to my Lan.
here is my code:
Code: Select all
ip = wifi.sta.getip();
if nil == ip then
--wifi.setmode(wifi.STATIONAP);
wifi.setmode(wifi.STATION);
--wifi.setmode(wifi.SOFTAP);
wifi.sta.config("mylan","mypsswd");
wifi.sta.connect();
--wifi.sta.autoconnect(1)
tmr.delay (10000000);
for n = 1, 15 do
ip = wifi.sta.getip();
print(ip);
if nil ~= ip then
break;
end
print ("no IP yet...");
tmr.delay (10000000);
end
end
if nil == ip then
print ("no IP");
else
print ("Node MAC: " .. wifi.sta.getmac());
print ("Node IP: " .. ip);
end
print ("done");
I tried different combinaisons
wifi.setmode(wifi.STATIONAP);
wifi.setmode(wifi.STATION);
wifi.setmode(wifi.SOFTAP);
wifi.sta.connect();
wifi.sta.autoconnect(1);
or both in comment
but no way
here is always the same result:
Code: Select all
NodeMCU 0.9.5 build 20150212 powered by Lua 5.1.4
nil
no IP yet...
nil
no IP yet...
nil
no IP yet...
nil
no IP yet..
but if I do it manually in lualoader:
It works..
Code: Select all
wifi.setmode(wifi.STATION)
> wifi.sta.config("mylan","mypsswd")
> = wifi.sta.getip()
192.168.1.7 255.255.255.0 192.168.1.1
> = wifi.sta.status()
5 GOT IP
>
Any help appracied