onem2m_client

1.0.63 • Public • Published

oneM2M_Client

This is created by Synctechno inc for communication with Mobius on KETI through oneM2M Standard
NPM
npm npm

Installation

$ npm install onem2m_client --save


Usage

Get Resource

var onem2mClient = require('onem2m_client')();

onem2mClient.Http.getResource(ResourceURL, origin)
.then(function(result){
  resource = result[`m2m:{type}`];
  /**
   * if resource is CB then have to be result['m2m:cb']
   * if resource is AE then have to be result['m2m:ae']
   * if resource is CNT then have to be result['m2m:cnt']
   * if resource is CIN then have to be result['m2m:cin']
   * if resource is SUB then have to be result['m2m:sub']
   * etc...
   **/
})

Create Resource

var onem2mClient = require('onem2m_client')();
var obj = {
  'm2m:cin' : {
    con : /* Content */,
    lib : /* any lib */
  }
}
onem2mClient.Http.createResource(ResourceURL, obj, origin)
  .then(function(result){
    console.log(result);
  });

Discover Resource

var onem2mClient = require('onem2m_client')();
onem2mClient.Http.discoverResource(ResourceURL, origin, type, limit, offset)
  .then(function(result){
    /**
     * {
     *  "m2m:urli" : {
     *    "parentNode URL",
     *    "First Child URL",
     *    "Second Child URL",
     *        ...
     *  }
     * }
     **/
  })

Mqtt Notification

var onem2mClient = require('onem2m_client')();
var targetUri = onem2mClient.Model.getAccessPointInfo(TARGET_RESOURCE_URL);
var mqttAddress = `mqtt://${targetUri}`;
var mqttClilent = onem2mClient.MQTT.getClilent(mqttAddress, target);
mqttClient.on('notification', function(mqttServerAddress, topicTo, topicParams, notiEventType, data) {
  var eventResource = data.resouce;
  /*
   ex)
   eventResource : {
     "m2m:cin" : {
       rn : ...,
       ri : ...,
       cr : ...,
       con : "Content"
     }
   }
});

Question

if you have any questions then, send mail to rnd@synctechno.com thank you.

Readme

Keywords

Package Sidebar

Install

npm i onem2m_client

Weekly Downloads

2

Version

1.0.63

License

MIT

Unpacked Size

31.6 kB

Total Files

8

Last publish

Collaborators

  • thyun.kim
  • junghochae