- Sat May 30, 2015 7:47 pm
#18998
Hi Dnc40085,
no flame, but how often your battery powered device needs to scan wifi?
I flashed new firmware "NodeMCU 0.9.6 build 20150405", format, update my testing file "scan.lua":
Code: Select allssid = 'Home123'
found = nil
wifi.setmode(wifi.STATIONAP)
scan_cfg = {}
scan_cfg.ssid = ssid
wifi.sta.getap(scan_cfg, function(t)
print(t)
found = 'really???'
for k,v in pairs(t) do print(k, v) end
end)
tmr.alarm(0, 500, 1, function()
if (found == nil) then
print('scanning...')
else
tmr.stop(0)
if (found == false) then
print('not found')
else
print('found', ssid, found)
end
end
end)
and I got this output (bssid edited):
Code: Select allŕ˙@ú)Ď(˙ťÍ�ü�óá
NodeMCU 0.9.6 build 20150405 powered by Lua 5.1.4
lua: cannot open init.lua
> dofile('scan.lua')
> scanning...
scanning...
scanning...
scanning...
table: 0x3fff6150
xx:xx:xx:xx:xx:xx Home,-83,1,6
found Home123 really???
dofile('scan.lua')
> scanning...
scanning...
scanning...
scanning...
scanning...
PANIC: unprotected error in call to Lua API (attempt to call a number value)
�{íˇś‹h˙ů4śřá
NodeMCU 0.9.6 build 20150405 powered by Lua 5.1.4
lua: cannot open init.lua
> dofile('scan.lua')
> scanning...
scanning...
scanning...
scanning...
table: 0x3fff6150
xx:xx:xx:xx:xx:xx Home,-83,1,6
found Home123 really???
dofile('scan.lua')
> scanning...
scanning...
scanning...
scanning...
scanning...
PANIC: unprotected error in call to Lua API (attempt to call a number value)
Í‹ű ŤyIlţyR†ü>çř
NodeMCU 0.9.6 build 20150405 powered by Lua 5.1.4
lua: cannot open init.lua
>
Scanning takes the same time as in my previous
code.
Every second "dofile('scan.lua')" fails.
Looking for "Home123" (does not exist) and found "Home" (exists).
Bugs or new features?
M
Edit:
I understand the reason for exchanging SSID and BSSID in the table, but is it really necessary to change the behavior of the function instead of creating new ones?