{"id":19339363,"url":"https://github.com/lwmqn/qnode","last_synced_at":"2025-06-11T07:10:34.305Z","repository":{"id":57303727,"uuid":"46707278","full_name":"lwmqn/qnode","owner":"lwmqn","description":"Client node of LwM2M-like Lightweight Message Queuing Network (LwMQN).","archived":false,"fork":false,"pushed_at":"2020-06-01T01:12:11.000Z","size":514,"stargazers_count":22,"open_issues_count":9,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T06:35:50.202Z","etag":null,"topics":["lwm2m","lwmqn","mqtt","mqtt-client"],"latest_commit_sha":null,"homepage":"http://lwmqn.github.io/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lwmqn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-23T08:38:17.000Z","updated_at":"2022-04-07T13:35:15.000Z","dependencies_parsed_at":"2022-08-24T17:11:40.671Z","dependency_job_id":null,"html_url":"https://github.com/lwmqn/qnode","commit_stats":null,"previous_names":["lwmqn/mqtt-node"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwmqn%2Fqnode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwmqn%2Fqnode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwmqn%2Fqnode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwmqn%2Fqnode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lwmqn","download_url":"https://codeload.github.com/lwmqn/qnode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250357534,"owners_count":21417297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lwm2m","lwmqn","mqtt","mqtt-client"],"created_at":"2024-11-10T03:21:27.812Z","updated_at":"2025-04-23T02:30:40.622Z","avatar_url":"https://github.com/lwmqn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![LWMQN Network](https://raw.githubusercontent.com/lwmqn/qnode/master/docs/images/lwmqn.png)\n\n\u003cdiv align=\"center\"\u003e\n\n**@lwmqn/qnode** is a client machine node for the lightweight MQTT machine network (LWMQN)\n\n[![NPM version](https://img.shields.io/npm/v/@lwmqn/qnode.svg?style=flat-square)](https://www.npmjs.com/package/@lwmqn/qnode)\n[![NPM downloads](https://img.shields.io/npm/dm/@lwmqn/qnode.svg?style=flat-square)](https://www.npmjs.com/package/@lwmqn/qnode)\n[![Travis branch](https://img.shields.io/travis/lwmqn/qnode/master.svg?maxAge=2592000\u0026style=flat-square)](https://travis-ci.org/lwmqn/qnode)\n[![Gitter](https://img.shields.io/gitter/room/lwmqn/Lobby.svg?style=flat-square)](https://gitter.im/lwmqn/Lobby)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)\n![pr-welcoming-image](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)\n\n\u003c/div\u003e\n\n-------\n\n## What is LWMQN\n\nLightweight Message Queuing Network ([**LwMQN**](http://lwmqn.github.io)) is an open source project that follows part of [**OMA LwM2M v1.0**](http://technical.openmobilealliance.org/Technical/technical-information/release-program/current-releases/oma-lightweightm2m-v1-0) specification to meet the minimum requirements of machine network management.\n\n### Server-side and Client-side Libraries:\n   - LwMQN project provides you with this machine-side **@lwmqn/qnode** library and a server-side [**@lwmqn/shepherd**](https://github.com/lwmqn/shepherd) library to build your machine network with JavaScript and node.js easily.\n\n* Server-side library: [**@lwmqn/shepherd**](https://github.com/lwmqn/shepherd)\n* Client-side library: **@lwmqn/qnode** (this module)\n* [**A simple demo webapp**](https://github.com/lwmqn/demo)\n\n### Features\n\n* Communication based on MQTT protocol and [mqtt.js](https://www.npmjs.com/package/mqtt) client.\n* Hierarchical Smart Object data model ([IPSO](http://www.ipso-alliance.org/)), which leads to a comprehensive and consistent way in describing real-world gadgets.\n* LWM2M-like interfaces for Client/Server interaction.\n* Auto handles many REQ/RSP things for you. All you have to do is to plan your _Resources_ well.\n\n### Understanding Smart Objects and the IPSO Model\n\n![IPSO Model](https://raw.githubusercontent.com/lwmqn/qnode/master/docs/images/ipso_model.png)\n\n### Acronyms and Abbreviations\n\n* **Server**: LWMQN server\n* **Client** or **Client Device**: LWMQN client, which is a machine node in the network\n* **Qnode**: Class exposed by `require('@lwmqn/qnode')`\n* **SmartObject**: Class exposed by `require('@lwmqn/smartobject')`\n* **qnode**: Instance of Qnode class\n* **so**: Instance of SmartObject class\n\n-------\n\n## Installation\n\nCurrently [Node.js 8.x LTS](https://nodejs.org/en/about/releases/) or higher is required.\n\n```bash\n$ npm install @lwmqn/qnode\n$ npm install @lwmqn/smartobject\n```\n\n### Compabitility table\n\n\n| Qnode versions /\u003cbr\u003eNode.js versions | 8.x\u003cbr\u003eLTS | 10.x\u003cbr\u003eLTS | 11.x | 12.x\u003cbr\u003eLTS | 13.x |\n|--------------------------------------|------------|-------------|------|-------------|------|\n| v0.10.0 | ✔ | ✔ | ✔ | ✔ | ✘ |\n\n-------\n\n## Basic Usage\n\n\nHere is a quick example, with two humidity sensors and one custom object, which shows how to use **@lwmqn/qnode** and **@lwmqn/smartobject** on your client machine.\n\n```js\nconst Qnode = require('@lwmqn/qnode')\nconst SmartObject = require('@lwmqn/smartobject')\n\nconst so = new SmartObject()\n\n// Humidity sensor - the first instance\nso.init('humidity', 0, { // oid = 'humidity', iid = 0\n  sensorValue: 20,\n  units: 'percent'\n})\n\n// Humidity sensor - the second instance\nso.init('humidity', 1, { // oid = 'humidity', iid = 1\n  sensorValue: 16,\n  units: 'percent'\n})\n\n// A custom Object with two Resources: myResrc1 and myResrc2\nso.init('myObject', 0, { // oid = 'myObject', iid = 0\n  myResrc1: 20,\n  myResrc2: 'hello world!'\n})\n\n// Create a qnode with a client id and your smart object. And attach your 'ready' and 'registered' event listeners\nconst qnode = new Qnode('my_foo_client_id', so)\n\nqnode.on('ready', function () {\n  // The ready event fires when the device is ready, but not yet remotely register to a Server.\n  // You can start to run your local app, such as showing the sensed value on an OLED monitor.\n  // To interact with your Resources, simply use the handy APIs provided by SmartObject class.\n})\n\nqnode.on('registered', function () {\n  // The event fires when registration procedure completes successfully, which means your device\n  // has joined the network and managed by the Server. After a success of registration, you can\n  // take the LWMQN Server as a simple MQTT broker. Your device can subscribe to any topic or\n  // publish any topic to the network (if authorized).\n})\n\nqnode.on('login', function () {\n  // Your qnode is now ready to accept remote requests from the Server. Don't worry about the\n  // REQ/RSP things, qnode itself will handle them for you.\n})\n\n// Connect and register to a Server, that's it!\nqnode.connect('mqtt://192.168.0.2')\n```\n\nThe following example shows how to operate upon this qnode **at server-side** (please go to [mqtt-shepherd](https://github.com/lwmqn/shepherd/wiki#Major) document for details):\n\n```js\nconst qnode = qserver.find('my_foo_client_id') // find the registered device by its client id\n\nif (qnode) {\n  qnode.readReq('humidity/0/sensorValue', function (err, rsp) {\n    if (!err) console.log(rsp) // { status: 205, data: 20 }\n  })\n\n  qnode.readReq('myObject/0/myResrc2', function (err, rsp) {\n    if (!err) console.log(rsp) // { status: 205, data: 'hello world!' }\n  })\n}\n```\n\n-------\n\n## Documentation\n* \u003ca href=\"https://github.com/lwmqn/qnode/blob/master/docs/Basic-APIs.md\"\u003e\u003ccode\u003e\u003cb\u003eBasic APIs\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n* \u003ca href=\"https://github.com/lwmqn/qnode/blob/master/docs/Networking-APIs.md\"\u003e\u003ccode\u003e\u003cb\u003eNetworking APIs\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n* \u003ca href=\"https://github.com/lwmqn/qnode/blob/master/docs/Generic-MQTT-Interfaces.md\"\u003e\u003ccode\u003e\u003cb\u003eGeneric MQTT Interfaces\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n* \u003ca href=\"https://github.com/lwmqn/qnode/blob/master/docs/Events.md\"\u003e\u003ccode\u003e\u003cb\u003eEvents\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n* \u003ca href=\"https://github.com/lwmqn/qnode/blob/master/docs/Message-Encryption.md\"\u003e\u003ccode\u003e\u003cb\u003eMessage Encryption\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n* \u003ca href=\"https://github.com/lwmqn/qnode/blob/master/docs/Identifying-Mode.md\"\u003e\u003ccode\u003e\u003cb\u003eIdentifying Mode\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n* \u003ca href=\"https://github.com/lwmqn/qnode/blob/master/docs/Debug-Messages.md\"\u003e\u003ccode\u003e\u003cb\u003eDebug messages\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n\n-------\n\n## License\n\nLicensed under [MIT](https://github.com/lwmqn/qnode/blob/master/LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwmqn%2Fqnode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flwmqn%2Fqnode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwmqn%2Fqnode/lists"}