-->
Page 1 of 2

do tmr.delay and wifi.sta.getap interact with each other ?

PostPosted: Thu May 07, 2015 1:55 pm
by Stef
hello

I've trouble combining wifi.sta.getap and net.createServer(net.TCP).
Now I assume it's not possible to use these both at the same time.
To find out if this is true, I created a small program combining wifi.sta.getap and wifi.sta.getip.
Although the might be called alternating, now a problem with the tmr module arises.
In the program below, the program hangs in the second while loop.
If I do the pieces of code by hand (interactively) and without the while loop, everything works as expected.

thanks Stef


_ap_scan = true
TMR_1 = 1
wifi.setmode ( wifi.STATION )

function _copy_ap ( My_APs )
print ( "........ found APs ", type ( My_APs ) )
_ap_scan = false
end


for i = 1, 5 do
while wifi.sta.getip () == nil do
print ( "IP unavailable, Waiting..." )
tmr.delay ( 1000000 )
end
print ( "Config done, IP is " .. wifi.sta.getip())

_ap_scan = true
wifi.sta.getap ( _copy_ap )
print ( 'ssstrated', _ap_scan )
while _ap_scan do
tmr.delay ( 1000000 )
print ( '......................', _ap_scan )
end
end

Re: do tmr.delay and wifi.sta.getap interact with each other

PostPosted: Thu May 07, 2015 5:16 pm
by TerryE
tmr.delay -- don't try it in this usecase. It doesn't work. This is a very common mistake so if you search this forum, you'll find various recent posts where I explain how to achieve what you are trying to achieve :)

Re: do tmr.delay and wifi.sta.getap interact with each other

PostPosted: Fri May 08, 2015 8:43 am
by Stef
thanks Terry,

too bad this information isn't in the manual.

cheers,
Stef

Re: do tmr.delay and wifi.sta.getap interact with each other

PostPosted: Fri May 08, 2015 4:28 pm
by TerryE
Yup, we need to add it :(