What is LWMQN
Lightweight MQTT machine 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 mqtt-node library and a server-side mqtt-shepherd library to build your machine network with JavaScript and node.js easily.
- Server-side library: mqtt-shepherd
- Client-side library: mqtt-node (this module)
- A simple demo webapp
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
- MqttNode: Class exposed by
require('mqtt-node')
- SmartObject: Class exposed by
require('smartobject')
- qnode: Instance of MqttNode class
- so: Instance of SmartObject class
Installation
Currently Node.js 8.x LTS or higher is required.
$ npm install mqtt-node$ npm install smartobject
Basic Usage
Here is a quick example, with two humidity sensors and one custom object, which shows how to use mqtt-node and smartobject on your client machine.
var MqttNode = var SmartObject = var so = // Humidity sensor - the first instanceso // Humidity sensor - the second instanceso; // A custom Object with two Resources: myResrc1 and myResrc2so // Create a qnode with a client id and your smart object. And attach your 'ready' and 'registered' event listenersvar qnode = 'my_foo_client_id' so; qnode qnode qnode // Connect and register to a Server, that's it!qnode;
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 the registered device by its client id if qnode qnode qnode;
Documentation
Basic APIs
Networking APIs
Generic MQTT Interfaces
Events
Message Encryption
Identifying Mode
Debug messages
License
Licensed under MIT.