{"id":19343996,"url":"https://github.com/petereb/coap-node","last_synced_at":"2025-04-23T04:36:14.445Z","repository":{"id":57201978,"uuid":"51914962","full_name":"PeterEB/coap-node","owner":"PeterEB","description":"Client node of lightweight M2M (LWM2M).","archived":false,"fork":false,"pushed_at":"2019-04-08T06:31:39.000Z","size":234,"stargazers_count":34,"open_issues_count":2,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T07:41:20.734Z","etag":null,"topics":["coap","lwm2m","nodejs","smartobject"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PeterEB.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":"2016-02-17T10:36:18.000Z","updated_at":"2024-02-29T13:16:33.000Z","dependencies_parsed_at":"2022-09-17T11:21:35.326Z","dependency_job_id":null,"html_url":"https://github.com/PeterEB/coap-node","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterEB%2Fcoap-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterEB%2Fcoap-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterEB%2Fcoap-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterEB%2Fcoap-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PeterEB","download_url":"https://codeload.github.com/PeterEB/coap-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250145139,"owners_count":21382357,"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":["coap","lwm2m","nodejs","smartobject"],"created_at":"2024-11-10T03:42:08.070Z","updated_at":"2025-04-23T04:36:14.196Z","avatar_url":"https://github.com/PeterEB.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# coap-node\nClient node of lightweight M2M (LWM2M).\n\n[![NPM](https://nodei.co/npm/coap-node.png?downloads=true)](https://nodei.co/npm/coap-node/)  \n\n[![Build Status](https://travis-ci.org/PeterEB/coap-node.svg?branch=develop)](https://travis-ci.org/PeterEB/coap-node)\n[![npm](https://img.shields.io/npm/v/coap-node.svg?maxAge=2592000)](https://www.npmjs.com/package/coap-node)\n[![npm](https://img.shields.io/npm/l/coap-node.svg?maxAge=2592000)](https://www.npmjs.com/package/coap-node)\n\n\u003cbr /\u003e\n\n## Documentation  \n\nPlease visit the [Wiki](https://github.com/PeterEB/coap-node/wiki).\n\n\u003cbr /\u003e\n\n## Overview\n\n[**OMA Lightweight M2M**](http://technical.openmobilealliance.org/Technical/technical-information/release-program/current-releases/oma-lightweightm2m-v1-0) (LWM2M) is a resource constrained device management protocol relies on [**CoAP**](https://tools.ietf.org/html/rfc7252). And **CoAP** is an application layer protocol that allows devices to communicate with each other RESTfully over the Internet.  \n\n**coap-shepherd**, **coap-node** and **lwm2m-bs-server** modules aim to provide a simple way to build and manage a **LWM2M** machine network. \n* Server-side library: [**coap-shepherd**](https://github.com/PeterEB/coap-shepherd)\n* Client-side library: **coap-node** (this module)\n* Bootstrap server library: [**lwm2m-bs-server**](https://github.com/PeterEB/lwm2m-bs-server)\n* [**A simple demo webapp**](https://github.com/PeterEB/quick-demo)\n\n![coap-shepherd net](https://raw.githubusercontent.com/PeterEB/documents/master/coap-shepherd/media/lwm2m_net.png)  \n\n### LWM2M Client: coap-node\n\n* It is an implementation of LWM2M Client managed by a **coap-shepherd** Server.\n* It follows most parts of **LWM2M** specification to meet the requirements of a machine network and devices management.\n* It works well with [**Leshan**](https://github.com/eclipse/leshan).\n* Support mulitple servers, factory bootstrap and client initiated bootstrap.\n* It uses [smartobject](https://github.com/PeterEB/smartobject) as its fundamental of resource organizing on devices. **smartobject** can help you create smart objects with IPSO data model, and it also provides a scheme to help you abstract your hardware into smart objects. You may like to use **smartobject** to create many plugins for your own hardware or modules, i.e., temperature sensor, humidity sensor, light control. Here is a [tutorual of how to plan resources](https://github.com/PeterEB/smartobject/blob/master/docs/resource_plan.md) with smartobject.\n\n\u003cbr /\u003e\n\n## Installation\n\n\u003e $ npm install coap-node --save\n\n\u003cbr /\u003e\n\n## Usage\n\nClient-side example (the following example is how you use `coap-node` on a machine node):\n\n* Step 1: Resources initialzation.\n```js\nvar SmartObject = require('smartobject');\n\n// initialize Resources that follow IPSO definition\nvar so = new SmartObject();\n\n// initialize your Resources\n// oid = 'temperature', iid = 0\nso.init('temperature', 0, {\n    sensorValue: 21,\n    units: 'C'\n});\n\n// oid = 'lightCtrl', iid = 0\nso.init('lightCtrl', 0, {\n    onOff: false\n});\n```\n\n* Step 2: Client device initialzation.\n```js\nvar CoapNode = require('coap-node');\n\n// Instantiate a machine node with a client name and your smart object\nvar cnode = new CoapNode('my_first_node', so);\n\ncnode.on('registered', function () {\n    // If the registration procedure completes successfully, 'registered' will be fired\n\n    // after registered, start your application\n});\n\n// register to a Server with its ip and port\ncnode.register('192.168.0.77', 5683, function (err, rsp) {\n    console.log(rsp);      // { status: '2.05' }\n});\n```\n\nServer-side example (please go to [coap-shepherd](https://github.com/PeterEB/coap-shepherd) document for details):\n\n```js\nvar cnode = cserver.find('my_first_node');\n\ncnode.read('/temperature/0/sensorValue', function (err, rsp) {\n    console.log(rsp);      // { status: '2.05', data: 21 }\n});\n\ncnode.write('/lightCtrl/0/onOff', true, function (err, rsp) {\n    console.log(rsp);      // { status: '2.04' }\n});\n```\n\n\u003cbr /\u003e\n\n## License\n\nLicensed under [MIT](https://github.com/PeterEB/coap-node/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetereb%2Fcoap-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetereb%2Fcoap-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetereb%2Fcoap-node/lists"}