Create an access point with the given ssid, key, channel, and encoding. Encoding can be 0, undefined, "open", "wep", "wpa_psk", "wpa2_psk" or "wpa_wpa2_psk".
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
As requested by @Kolban.
Still not sure on a name, apart from
network
? As a starting point:wifi.setPower(onOrOff, function(err) { ... })
Initialise WiFi, or turn it off. That could be handy?
wifi.connect(ssid, key, [options], function(err) { ... });
Connect to the given access point. options could be an object extra stuff like the security type.
The callback is called with err==null on success. Could maybe also return the IP?
wifi.getAPs(function(err, aps) { ... });
Call the callback with a list of access points, of the form
aps = [ { ssid, enc, signal_strength, mac_address } ]
.The callback is called with err==null on success.
wifi.getConnectedAP(function(err, ap) { ... });
Call the callback with the name of the currently connected access point. The callback is called with
err==null
on success.wifi.createAP(ssid, key, channel, enc, function(err) { ... })
Create an access point with the given ssid, key, channel, and encoding. Encoding can be 0, undefined, "open", "wep", "wpa_psk", "wpa2_psk" or "wpa_wpa2_psk".
Example:
wifi.createAP("ESP123","HelloWorld",5,"wpa2_psk",print)
wifi.getConnectedDevices(function(err, devices) { ... });
If if AP mode (with wifi.createAP), call the callback with the second argument as an array of
{ ip, mac }
objects - one for each connected device.wifi.getIP(function(err, ip) { ... });
Call the callback with the current address details:
{ip:string, mac:string, ...?}
The callback is called with err==null on success.