npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rpi-wifi-connection

v1.0.17

Published

Module to connect a Raspberry Pi to Wi-Fi

Downloads

196

Readme

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 = require('rpi-wifi-connection');
var wifi = new Wifi();

wifi.connect({ssid:'my-network', psk:'raspberry'}).then(() => {
    console.log('Connected to network.');
})
.catch((error) => {
    console.log(error);
});

scan()

Return a promise containing the available networks


var Wifi = require('rpi-wifi-connection');
var wifi = new Wifi();

wifi.scan().then((ssids) => {
    console.log(ssids);
})
.catch((error) => {
    console.log(error);
});

// [ { 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 = require('rpi-wifi-connection');
var wifi = new Wifi();

wifi.getStatus().then((status) => {
    console.log(status);
})
.catch((error) => {
    console.log(error);
});

// { 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 = require('rpi-wifi-connection');
var wifi = new Wifi();

wifi.getState().then((connected) => {
    if (connected)        
        console.log('Connected to network.');
    else
        console.log('Not connected to network.');
})
.catch((error) => {
    console.log(error);
});

getNetworks()

Returns a promise containing a list of Wi-Fi networks.

var Wifi = require('rpi-wifi-connection');
var wifi = new Wifi();

wifi.getNetworks().then((networks) => {
    console.log(networks);
});

//  [ { id: 0, ssid: 'Julia' } ]