Skip to content

rbiggers/wifi

 
 

Repository files navigation

Node WPA Control Interface

Node.js wrapper for the wpa_supplicant control interface for controlling Wi-Fi connections on Linux.

npm npm type definitions npm npm Dependency Status

Installation

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

Example

'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

API documentation may be generated by running grunt typedoc from the package directory (assuming development dependencies have been installed).

Contributing

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

License

Derived from wpa-wifi.
Copyright (c) 2018 Alex Moon.
Licensed under the ISC license.

About

Wifi module in nodejs

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 54.4%
  • TypeScript 45.6%