onem2m_client
v1.0.63
Published
Synctechno's Library for communicating with Mobius on KETI through oneM2M platform
Downloads
10
Readme
oneM2M_Client
This is created by Synctechno inc for communication with Mobius on KETI through oneM2M Standard
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 [email protected] thank you.