Giter VIP home page Giter VIP logo

coap-node's Introduction

coap-node

Client node of lightweight M2M (LWM2M).

NPM

Build Status npm npm


Documentation

Please visit the Wiki.


Overview

OMA Lightweight M2M (LWM2M) is a resource constrained device management protocol relies on CoAP. And CoAP is an application layer protocol that allows devices to communicate with each other RESTfully over the Internet.

coap-shepherd, coap-node and lwm2m-bs-server modules aim to provide a simple way to build and manage a LWM2M machine network.

coap-shepherd net

LWM2M Client: coap-node

  • It is an implementation of LWM2M Client managed by a coap-shepherd Server.
  • It follows most parts of LWM2M specification to meet the requirements of a machine network and devices management.
  • It works well with Leshan.
  • Support mulitple servers, factory bootstrap and client initiated bootstrap.
  • It uses 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 with smartobject.

Installation

$ npm install coap-node --save


Usage

Client-side example (the following example is how you use coap-node on a machine node):

  • Step 1: Resources initialzation.
var SmartObject = require('smartobject');

// initialize Resources that follow IPSO definition
var so = new SmartObject();

// initialize your Resources
// oid = 'temperature', iid = 0
so.init('temperature', 0, {
    sensorValue: 21,
    units: 'C'
});

// oid = 'lightCtrl', iid = 0
so.init('lightCtrl', 0, {
    onOff: false
});
  • Step 2: Client device initialzation.
var CoapNode = require('coap-node');

// Instantiate a machine node with a client name and your smart object
var cnode = new CoapNode('my_first_node', so);

cnode.on('registered', function () {
    // If the registration procedure completes successfully, 'registered' will be fired

    // after registered, start your application
});

// register to a Server with its ip and port
cnode.register('192.168.0.77', 5683, function (err, rsp) {
    console.log(rsp);      // { status: '2.05' }
});

Server-side example (please go to coap-shepherd document for details):

var cnode = cserver.find('my_first_node');

cnode.read('/temperature/0/sensorValue', function (err, rsp) {
    console.log(rsp);      // { status: '2.05', data: 21 }
});

cnode.write('/lightCtrl/0/onOff', true, function (err, rsp) {
    console.log(rsp);      // { status: '2.04' }
});

License

Licensed under MIT.

coap-node's People

Contributors

akashgoswami avatar petereb avatar simenkid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

coap-node's Issues

No observe event

Hello,

I am using coap-node to emulate a lwm2m client.
I noticed that when observe events are received by the COAP stack, they are not forwarded to my application (see extract below)
Anything wrong with what I am doing ?
Thanks for helping

coapnode.register(Lwm2m_Host,Lwm2m_Port,function(err,rsp) {
         if (rsp.status == '2.01')  {
            nb_registered++;
            Devices[d_index].registered=1;
            coapNode[d_index]=coapnode;
            d_index++;
            if (d_index <= last_index) {
               setTimeout(next_reg,Reg_Timer_ms,d_index);
            }
         }
      });
      coapnode.on('registered',function() {
         if (verbose==1)
            console.log("Registration of "+Devices[d_index].Name+" done");
      });
      coapnode.on('observe',((mydev_index) => {return(req) => {
         console.log("Observe for "+Devices[mydev_index].Name+" received: ",req);
         Devices[mydev_index].observed=1;
         nb_observed++;
      };})(d_index));

Any lwm2m Bootstrap support yet?

Hi Peter,

I've just started to play with your coap-node against leshan server.
It worked well. Thanks. Appreciated.

One thing,
It seems that this coap-node lwm2m client doesn't support Bootstrap(?)
I'm considering some mass registration measurement(scalability), which requires BSS too,
at least for our experiment.

Do you have any plan to support BootStrap in your coap-node(lwm2m client)?
If not, how much effort do you expect to implement Bootstrap only in lwm2m client,
assuming that, leshan(+bootstrap) server is used in this case.

Any info would be really appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.