onem2m_client
Version:
Synctechno's Library for communicating with Mobius on KETI through oneM2M platform
89 lines (81 loc) • 2.31 kB
Markdown
This is created by Synctechno inc for communication with Mobius on KETI through oneM2M Standard
<br/>
[](https://nodei.co/npm/onem2m_client/)
[](https://www.npmjs.com/package/onem2m_client)
[](https://www.npmjs.com/package/onem2m_client)
<br/>
> $ npm install onem2m_client --save
<br/>
```js
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...
**/
})
```
```js
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);
});
```
```js
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",
* ...
* }
* }
**/
})
```
```js
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.