As the title says... Chat on...

User avatar
By dnc40085
#17704 A week ago, a pull request of mine was merged into the dev096 branch that added a few features, including the one you are referring to.
if you use http://frightanic.com/nodemcu-custom-build/ to build the dev096 branch the following additions should be available to you:

wifi.sta.config() :
Code: Select all/**
  * wifi.sta.config()
  * Description:
  *    Set current Station configuration.
  *    Note: If there are multiple APs with the same ssid, you can connect to a specific one by entering it's MAC address into the "bssid" field.
  * Syntax:
  *    wifi.sta.getconfig(ssid, password) --Set STATION configuration, Auto-connect by default, Connects to any BSSID
  *    wifi.sta.getconfig(ssid, password, Auto_connect) --Set STATION configuration, Auto-connect(0 or 1), Connects to any BSSID
  *    wifi.sta.getconfig(ssid, password, bssid) --Set STATION configuration, Auto-connect by default, Connects to specific BSSID
  *    wifi.sta.getconfig(ssid, password, Auto_connect, bssid) --Set STATION configuration, Auto-connect(0 or 1), Connects to specific BSSID
  * Parameters:
  *    ssid: string which is less than 32 bytes.
  *    Password: string which is less than 64 bytes.
  *    Auto_connect: 0 (disable Auto-connect) or 1 (to enable Auto-connect).
  *    bssid: MAC address of Access Point you would like to connect to.
  * Returns:
  *    Nothing.
  *
  *   Example:
          --Connect to Access Point automatically when in range
          wifi.sta.getconfig("myssid", "password")

          --Connect to Access Point, User decides when to connect/disconnect to/from AP
          wifi.sta.getconfig("myssid", "mypassword", 0)
          wifi.sta.connect()
          --do some wifi stuff
          wifi.sta.disconnect()

          --Connect to specific Access Point automatically when in range
          wifi.sta.getconfig("myssid", "mypassword", "12:34:56:78:90:12")

          --Connect to specific Access Point, User decides when to connect/disconnect to/from AP
          wifi.sta.getconfig("myssid", "mypassword", 0)
          wifi.sta.connect()
          --do some wifi stuff
          wifi.sta.disconnect()
  *
  */


wifi.sta.getconfig() :
Code: Select all/**
  * wifi.sta.getconfig()
  * Description:
  *    Get current Station configuration.
  *    Note:  if bssid_set==1 STATION is configured to connect to specified BSSID
  *          if bssid_set==0 specified BSSID address is irrelevant.
  * Syntax:
  *    ssid, pwd, bssid_set, bssid=wifi.sta.getconfig()
  * Parameters:
  *    none
  * Returns:
  *    SSID, Password, BSSID_set, BSSID
  */


wifi.sta.getap() :
Code: Select all/**
  * wifi.sta.getap()
  * Description:
  *    scan and get ap list as a lua table into callback function.
  * Syntax:
  *    wifi.sta.getap(function(table))
  *    wifi.sta.getap(cfg, function(table))
  * Parameters:
  *    cfg: table that contains scan configuration
  *    function(table): a callback function to receive ap table when scan is done
         this function receive a table, the key is the ssid,
         value is other info in format: authmode,rssi,bssid,channel
  * Returns:
  *    nil
  *
  * Example:
       --original function left intact to preserve backward compatibility
       wifi.sta.getap(function(T) for k,v in pairs(T) do print(k..":"..v) end end)

       --if no scan configuration is desired cfg can be set to nil or previous example can be used
       wifi.sta.getap(nil, function(T) for k,v in pairs(T) do print(k..":"..v) end end)

       --scan configuration
       scan_cfg={}
     scan_cfg.ssid="myssid"            --if set to nil, ssid is not filtered
     scan_cfg.bssid="AA:AA:AA:AA:AA:AA" --if set to nil, MAC address is not filtered
     scan_cfg.channel=0               --if set to nil, channel will default to 0(scans all channels), if set scan will be faster
     scan_cfg.show_hidden=1          --if set to nil, show_hidden will default to 0
       wifi.sta.getap(scan_cfg, function(T) for k,v in pairs(T) do print(k..":"..v) end end)

  */