-
Notifications
You must be signed in to change notification settings - Fork 0
Home
peter edited this page Jan 23, 2018
·
2 revisions
oneM2M REST api.
- Eclipse oneM2M
$ npm install om2m-rest --save
var Om2m = require('om2m-rest');
// initialize om2m configuration
var om2m = new Om2m('192.168.1.112', 8282, 'mn-ces', 'my-mn', 'admin', 'admin');
// create your application
om2m.createApp('MY_SENSOR', 'my_sensor', 'Type/sensor', false, function (err, msg) {
console.log(msg);
});
// create your container
om2m.createCont('MY_SENSOR', 'DATA', 10, function (err, msg) {
console.log(msg);
});
// create your content instance
om2m.createApp('MY_SENSOR', 'DATA', temperature, { sensorValue: 25.6 }, function (err, msg) {
console.log(msg);
});Exposed by require('coap-node').
- An instance of this class is denoted as om2m in this document.
Create a new instance of Om2m class.
Arguments:
-
host(String): Target host address. -
port(String): Target port. -
type(String): Type of the target. -
name(String): Name of the target. -
username(String): Usernameof the target. -
password(String | Number): Password of the target.
Returns:
- (Object): om2m.
Examples:
var Om2m = require('om2m-rest');
// initialize om2m configuration
var om2m = new Om2m('192.168.1.112', 8282, 'mn-ces', 'my-mn', 'admin', 'admin');Arguments:
-
callback(Function):function (err, msg) { }, wheremsgis the response to tell whether this request is successful.
Returns:
- (none)
Examples:
om2m.getResc(function (err, msg) {
console.log(msg);
});Arguments:
-
appName(String): . -
api(String): . -
lbl(String): . -
rr(Boolean): . -
poa(String): . -
callback(Function):function (err, msg) { }, wheremsgis the response to tell whether this request is successful.
Returns:
- (none)
Examples:
// `rr` is false
om2m.createApp('MY_SENSOR', 'my_sensor', 'Type/sensor', false, function (err, msg) {
console.log(msg);
});
// `rr` is trun
om2m.createApp('MY_SENSOR', 'my_sensor', 'Type/sensor', trun, 'http://192.168.1.110:1400', function (err, msg) {
console.log(msg);
});Arguments:
-
appName(String): . -
contName(String): . -
mbs(String | Number): . -
callback(Function):function (err, msg) { }, wheremsgis the response to tell whether this request is successful.
Returns:
- (none)
Examples:
om2m.createCont('MY_SENSOR', 'DATA', 10, function (err, msg) {
console.log(msg);
});Arguments:
-
appName(String): . -
contName(String): . -
category(String): . -
value(Object): . -
callback(Function):function (err, msg) { }, wheremsgis the response to tell whether this request is successful.
Returns:
- (none)
Examples:
om2m.createDataInst('MY_SENSOR', 'DATA', temperature, { sensorValue: 25.6 }, function (err, msg) {
console.log(msg);
});Arguments:
-
appName(String): . -
contName(String): . -
category(String): . -
value(Array): . -
callback(Function):function (err, msg) { }, wheremsgis the response to tell whether this request is successful.
Returns:
- (none)
Examples:
om2m.createDescInst('MY_SENSOR', 'DATA', temperature, [ 'getValue' ], function (err, msg) {
console.log(msg);
});