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

@lwmqn/qnode

v0.10.0

Published

Client node of LwM2M-like Lightweight Message Queuing Network (LwMQN).

Downloads

1

Readme

LWMQN Network

@lwmqn/qnode is a client machine node for the lightweight MQTT machine network (LWMQN)

NPM version NPM downloads Travis branch Coverage Status Gitter js-standard-style pr-welcoming-image


What is LWMQN

Lightweight Message Queuing Network (LwMQN) is an open source project that follows part of OMA LwM2M v1.0 specification to meet the minimum requirements of machine network management.

Server-side and Client-side Libraries:

  • LwMQN project provides you with this machine-side @lwmqn/qnode library and a server-side @lwmqn/shepherd library to build your machine network with JavaScript and node.js easily.

Features

  • Communication based on MQTT protocol and mqtt.js client.
  • Hierarchical Smart Object data model (IPSO), which leads to a comprehensive and consistent way in describing real-world gadgets.
  • LWM2M-like interfaces for Client/Server interaction.
  • Auto handles many REQ/RSP things for you. All you have to do is to plan your Resources well.

Acronyms and Abbreviations

  • Server: LWMQN server
  • Client or Client Device: LWMQN client, which is a machine node in the network
  • Qnode: Class exposed by require('@lwmqn/qnode')
  • SmartObject: Class exposed by require('@lwmqn/smartobject')
  • qnode: Instance of Qnode class
  • so: Instance of SmartObject class

Installation

Currently Node.js 8.x LTS or higher is required.

$ npm install @lwmqn/qnode
$ npm install @lwmqn/smartobject

Basic Usage

Here is a quick example, with two humidity sensors and one custom object, which shows how to use @lwmqn/qnode and smartobject on your client machine.

var Qnode = require('@lwmqn/qnode')
var SmartObject = require('@lwmqn/smartobject')

var so = new SmartObject()

// Humidity sensor - the first instance
so.init('humidity', 0, {    // oid = 'humidity', iid = 0
  sensorValue: 20,
  units: 'percent'
})

// Humidity sensor - the second instance
so.init('humidity', 1, {    // oid = 'humidity', iid = 1
  sensorValue: 16,
  units: 'percent'
});

// A custom Object with two Resources: myResrc1 and myResrc2
so.init('myObject', 0, {    // oid = 'myObject', iid = 0
  myResrc1: 20,
  myResrc2: 'hello world!'
})

// Create a qnode with a client id and your smart object. And attach your 'ready' and 'registered' event listeners
var qnode = new Qnode('my_foo_client_id', so);

qnode.on('ready', function () {
    // The ready event fires when the device is ready, but not yet remotely register to a Server.
    // You can start to run your local app, such as showing the sensed value on an OLED monitor.
    // To interact with your Resources, simply use the handy APIs provided by SmartObject class.
})

qnode.on('registered', function () {
    // The event fires when registration procedure completes successfully, which means your device
    // has joined the network and managed by the Server. After a success of registration, you can
    // take the LWMQN Server as a simple MQTT broker. Your device can subscribe to any topic or
    // publish any topic to the network (if authorized).
})

qnode.on('login', function () {
    // Your qnode is now ready to accept remote requests from the Server. Don't worry about the
    // REQ/RSP things, qnode itself will handle them for you.
})

// Connect and register to a Server, that's it!
qnode.connect('mqtt://192.168.0.2');

The following example shows how to operate upon this qnode at server-side (please go to mqtt-shepherd document for details):

var qnode = qserver.find('my_foo_client_id');   // find the registered device by its client id

if (qnode) {
  qnode.readReq('humidity/0/sensorValue', function (err, rsp) {
    if (!err) console.log(rsp);   // { status: 205, data: 20 }
  })

  qnode.readReq('myObject/0/myResrc2', function (err, rsp) {
    if (!err) console.log(rsp);   // { status: 205, data: 'hello world!' }
  });
}

Documentation

  • Basic APIs
  • Networking APIs
  • Generic MQTT Interfaces
  • Events
  • Message Encryption
  • Identifying Mode
  • Debug messages

License

Licensed under MIT.