Node.js wrapper for the wpa_supplicant control interface for controlling Wi-Fi connections on Linux.
wpa-ctrl runs on Node.js and is available as an NPM package. You can install wpa-ctrl in your project's directory as usual:
$ npm install wpa-ctrl --save
'use strict';
const WpaCtrl = require('wpa-ctrl');
let wpa = new WpaCtrl('wlan0');
wpa.on('raw_msg', function(msg) {
console.log(msg);
});
(async function connectToWiFi() {
try {
await wpa.connect()
console.log('ready');
let networks = await wpa.listNetworks();
console.log(networks);
let accessPoints = await wpa.scan();
console.log(accessPoints);
let newNetwork = await wpa.addNetwork();
await wpa.setNetworkSSID(newNetwork, 'ssid');
await wpa.setNetworkPreSharedKey(newNetwork, 'password');
await wpa.selectNetwork(newNetwork);
wpa.close();
} catch (err) {
console.log(err);
}
})();
API documentation may be generated by running grunt typedoc
from the package directory (assuming development
dependencies have been installed).
Contributions are welcome and appreciated.
You can find wpa-ctrl on GitHub; feel free to start an issue or create a pull requests:
https://github.com/alexmoon/wifi
Derived from wpa-wifi.
Copyright (c) 2018 Alex Moon.
Licensed under the ISC license.