LWM2M
LWM2M simulator is an enterprise only feature currently limited in preview.

Last updated
Was this helpful?
Was this helpful?
{
state.temp = 20;
state.led = false;
state.so = new smartObject();
state.so.init('temperature', 0,
{
_state : state,
sensorValue: {
read: function (cb) {
console.log('Read called for Sensor');
cb(null,state.temp); },
write: function (value, cb){
console.log('Write called for Sensor with value', value)
cb(null,state.temp);
}},
units: 'C'
});
// led
state.so.init('lightCtrl', 0 , {
_state: state,
onOff: {
read: function (cb) {
cb(null, state.led);
},
write: function (val, cb) {
state.led = val;
cb(null, state.led);
}
}
});
//no need for return
}
{
state.temp = 25+index();
/* Update using a trigger method
state.so.write('temperature', 0, 'sensorValue', state.temp , function (err, data) {
if (err) {
console.log(err); // Error: 'Resource is unwritable.'
console.log(data); // _unwritable_
}
});
*/
// Read using trigger method
/*
state.so.dump('temperature', 0, function (err, data) {
console.log(data);
})
*/
var payload = {
pathname: '/.well-known/core',
payload: '</>;hb,</1/0>;obs,</3/0>;obs,</4/0>;obs,</3303/0>;obs',
method: 'GET',
waitResponse: false,
options: {
'Content-Format': 'application/link-format'
},
query: ''
}
return JSON.stringify(payload);
}