rpi-wifi-connection
Module to connect a Raspberry Pi to Wi-Fi
Installation
$ npm install rpi-wifi-connection --save
Usage
var Wifi = require('rpi-wifi-connection');
var wifi = new Wifi();
Methods
constructor(iface)
Constructs a new wifi connection object.
- iface - Specifies the name of the interface (default is wlan0)
connect(options)
Connects to the specified network.
- options.ssid - Specifies the network name.
- options.psk - Specifies the password.
- options.timeout - Specifies the number of milliseconds to wait for connection. Default is 60 seconds (60000).
var Wifi = ;var wifi = ; wifi;
scan()
Return a promise containing the available networks
var Wifi = ;var wifi = ; wifi; // [ { bssid: 'f4:ca:e5:e7:de:58', signalLevel: -72, frequency: 2467, ssid: 'homo' }, bssid: 'f4:ca:e5:e7:de:5a' signalLevel: -72 frequency: 2467 ssid: 'deus'
getStatus()
Returns a promise containing the network status.
var Wifi = ;var wifi = ; wifi; // { ssid: 'Julia', ip_address: '10.0.1.189' }
getState()
Returns a promise containing the connection state. Please note that this only returns the connection state of your Raspberry Pi for any network. To see if you are connected to a specific network, use getStatus().
var Wifi = ;var wifi = ; wifi;
getNetworks()
Returns a promise containing a list of Wi-Fi networks.
var Wifi = ;var wifi = ; wifi; // [ { id: 0, ssid: 'Julia' } ]