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

@nrfcloud/gateway-common

v3.1.0

Published

nRF Cloud Javascript gateway common library

Downloads

11

Readme

@nrfcloud/gateway-common

Common module for JavaScript based gateways.

Introduction

This module contains the gateway logic for communicating with the nRF Cloud platform and Bluetooth devices.

Install

npm i @nrfcloud/gateway-common

Setup

You'll need to provide a class that inherits from bluetoothAdapter. This will have to be specific for your system. See ExampleAdapter for an example.

Create a gateway on your nRF Cloud account (make sure you have an account first!) using the following command:

npx @nrfcloud/gateway-registration

It will ask you for your login credentials. It will output three files in a ./result directory. For MQTTS, you'll need the certificates and gateway ID. For WSS, you'll just need the gateway ID. WSS uses Cognito authentication to provide security.

Use

In your code, create a new Gateway and pass in a configuration object.

It is suggested that you use environment variables and something like dotenv.

(Note that this example is in Typescript, but plain JS works as well.)

import { Gateway, GatewayConfiguration, GatewayEvent } from 'gateway-common';
import { NobleAdapter } from './src/adapters/nobleAdapter';
const configuration: GatewayConfiguration = {
    keyPath: process.env.PRIVATE_KEY_PATH,
    certPath: process.env.CLIENT_CERT_PATH,
    caPath: process.env.CA_CERT_PATH,
    gatewayId: process.env.GATEWAY_ID,
    host: process.env.HOST,
    stage: process.env.ENVIRONMENT_STAGE,
    tenantId: process.env.TENANT_ID,
    bluetoothAdapter: new NobleAdapter(),
};
const gateway = new Gateway(configuration);

Upon instantiation, the gateway will try to connect to nRF Cloud.

Events

The gateway will emit some events as things happen.

  • GATEWAY_DELETED: The gateway has been deleted from nRF Cloud. You'll probably want to delete the certs since they're not useful any more
  • NAME_CHANGED: Gateway name has been changed
  • DEVICE_REMOVED: Device has been removed from the gateway
  • CONNECTIONS_CHANGED: The device connections have changed

Example

To see an implementation of this project, see the Raspbery Pi gateway.