Left here for archival purposes.

User avatar
By AlexZ
#27574 Code (straight from the api):
Code: Select allwifi.setmode(wifi.STATION)

function listap(t)
    for k,v in pairs(t) do
        print(k.." : "..v)
    end
end

wifi.sta.getap(listap)


When I run this code I get...
Code: Select all> wifi.setmode(wifi.STATION)
>
> function listap(t)
>> for k,v in pairs(t) do
 print(k.." : "..v)
 end
>> end
>
> wifi.sta.getap(listap)
> �!�J� ��1�)M���� ���TC�
NodeMCU custom build by frightanic.com
   branch: master
   commit: f4fc3b95a86ec98c6de0cfb0c1c424e343297420
   SSL: false
   modules: node,file,gpio,wifi,net,tmr
    built on: 2015-09-01 15:48
  powered by Lua 5.1.4
lua: cannot open init.lua


What's happening here? Literally three hours ago everything was working fine. I've reflashed multiple different firmware versions to no avail.

--OF POSSIBLE INTEREST--
Until just a little while ago it seemed as if my ESP-01 module was permanently stuck with wifi.sta.status() == 1 regardless of number of restarts or reflashes. This seems very unusual to me. I got it to leave that status by disabling autoconnect. Now the station is idle like it should be, but my getap problem persists.

--PRINTING WEIRDNESS--
wifi.sta.getap causes the module to crash even when coded like so...
Code: Select allwifi.sta.getap(function(t) print('1') end)

Weirdly enough, if I place this code in init.lua then '1' gets printed between crashes. It seems the body of the function is executing perfectly fine, and the crash is delayed until after the function body has been executed.

A couple of diagnostic print statements:
Input1:
Code: Select allwifi.setmode(wifi.STATION)

function listap(t)
    print('0')
    for k,v in pairs(t) do
        print('1')
        print(k.." : "..v)
    end
    print('2')
end

wifi.sta.getap(listap)

Output1:
Code: Select all> 0
2
�!� �<1�)M�Ό)���TC�
NodeMCU custom build by frightanic.com
   branch: master
   commit: f4fc3b95a86ec98c6de0cfb0c1c424e343297420
   SSL: false
   modules: node,file,gpio,wifi,net,tmr
    built on: 2015-09-01 15:48
  powered by Lua 5.1.4
lua: cannot open init.lua
>


Input2:
Code: Select allwifi.setmode(wifi.STATION)

wifi.sta.getap(print)

Ouput2:
Code: Select all> table: 3fff32b0
�! CB�1�)M�1�)�!���TC�
NodeMCU custom build by frightanic.com
   branch: master
   commit: f4fc3b95a86ec98c6de0cfb0c1c424e343297420
   SSL: false
   modules: node,file,gpio,wifi,net,tmr
    built on: 2015-09-01 15:48
  powered by Lua 5.1.4
lua: cannot open init.lua
>


Does anyone have any clue what's happening?
User avatar
By AlexZ
#27577 So it seems that the table returned is empty. I can add entries to the table and listap will print them as expected. Calling wifi.sta.getap does still crash the module though. Unfortunately, I know for a fact that there are many AP's in my vicinity.