Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
init.setupNode = function (cn, devResrcs) {
var maxLatency = (cn._config.reqTimeout - 47)/ 2,
so = cn.getSmartObject();
coap.updateTiming({
maxLatency: maxLatency
});
coap.registerFormat('application/json', 11543); // Leshan JSON Numeric Content-Formats
coap.registerFormat('application/tlv', 11542); // Leshan TLV Content-Format
so.init('lwm2mServer', 0, { // oid = 1
shortServerId: 'unknown', // rid = 0
lifetime: cn.lifetime, // rid = 1
defaultMinPeriod: cn._config.defaultMinPeriod, // rid = 2
defaultMaxPeriod: cn._config.defaultMaxPeriod // rid = 3
});
so.init('device', 0, { // oid = 3
manuf: devResrcs.manuf || 'sivann', // rid = 0
model: devResrcs.model || 'cnode-01', // rid = 1
serial: devResrcs.serial || 'c-0000', // rid = 2
firmware: devResrcs.firmware || 'v1.0', // rid = 3
devType: devResrcs.devType || 'generic', // rid = 17
hwVer: devResrcs.hwVer || 'v1.0', // rid = 18
init.setupNode = function (cn, devResrcs) {
var propWritable = { writable: true, enumerable: false, configurable: false },
maxLatency = (cn._config.reqTimeout - 47)/ 2,
so = cn.getSmartObject();
coap.updateTiming({
maxLatency: maxLatency
});
coap.registerFormat('application/tlv', 11542); // Leshan TLV binary Content-Formats
coap.registerFormat('application/json', 11543); // Leshan JSON Numeric Content-Formats
so.init('device', 0, { // oid = 3
manuf: devResrcs.manuf || 'sivann', // rid = 0
model: devResrcs.model || 'cnode-01', // rid = 1
serial: devResrcs.serial || 'c-0000', // rid = 2
firmware: devResrcs.firmware || '1.0', // rid = 3
devType: devResrcs.devType || 'generic', // rid = 17
hwVer: devResrcs.hwVer || '1.0', // rid = 18
swVer: devResrcs.swVer || '1.0', // rid = 19
availPwrSrc: devResrcs.availPwrSrc || 0,
pwrSrcVoltage: devResrcs.pwrSrcVoltage || 100
});
so.init('connMonitor', 0, { // oid = 4
ip: cn.ip, // rid = 4
init.setupNode = function (cn, devResrcs) {
var propWritable = { writable: true, enumerable: false, configurable: false },
maxLatency = (cn._config.reqTimeout - 47)/ 2,
so = cn.getSmartObject();
coap.updateTiming({
maxLatency: maxLatency
});
coap.registerFormat('application/tlv', 11542); // Leshan TLV binary Content-Formats
coap.registerFormat('application/json', 11543); // Leshan JSON Numeric Content-Formats
so.init('device', 0, { // oid = 3
manuf: devResrcs.manuf || 'sivann', // rid = 0
model: devResrcs.model || 'cnode-01', // rid = 1
serial: devResrcs.serial || 'c-0000', // rid = 2
firmware: devResrcs.firmware || '1.0', // rid = 3
devType: devResrcs.devType || 'generic', // rid = 17
hwVer: devResrcs.hwVer || '1.0', // rid = 18
swVer: devResrcs.swVer || '1.0', // rid = 19
availPwrSrc: devResrcs.availPwrSrc || 0,
pwrSrcVoltage: devResrcs.pwrSrcVoltage || 100
});
so.init('connMonitor', 0, { // oid = 4
ip: cn.ip, // rid = 4
routeIp: 'unknown' // rid = 5
init.setupNode = function (cn, devResrcs) {
var maxLatency = (cn._config.reqTimeout - 47)/ 2,
so = cn.getSmartObject();
coap.updateTiming({
maxLatency: maxLatency
});
coap.registerFormat('application/json', 11543); // Leshan JSON Numeric Content-Formats
coap.registerFormat('application/tlv', 11542); // Leshan TLV Content-Format
so.init('lwm2mServer', 0, { // oid = 1
shortServerId: 'unknown', // rid = 0
lifetime: cn.lifetime, // rid = 1
defaultMinPeriod: cn._config.defaultMinPeriod, // rid = 2
defaultMaxPeriod: cn._config.defaultMaxPeriod // rid = 3
});
so.init('device', 0, { // oid = 3
manuf: devResrcs.manuf || 'sivann', // rid = 0
model: devResrcs.model || 'cnode-01', // rid = 1
serial: devResrcs.serial || 'c-0000', // rid = 2
firmware: devResrcs.firmware || 'v1.0', // rid = 3
devType: devResrcs.devType || 'generic', // rid = 17
hwVer: devResrcs.hwVer || 'v1.0', // rid = 18
swVer: devResrcs.swVer || 'v1.0', // rid = 19
init.setupShepherd = function (shepherd, callback) {
var deferred = Q.defer(),
self = this;
debug('coap-shepherd booting...');
coap.registerFormat('application/tlv', 11542); // Leshan TLV binary Content-Formats
coap.registerFormat('application/json', 11543); // Leshan JSON Numeric Content-Formats
coap.updateTiming({
ackTimeout:0.25,
ackRandomFactor: 1.0,
maxRetransmit: 3,
maxLatency: 2,
});
this._coapServerStart(shepherd).then(function (server) {
debug('Create a coap server for shepherd.');
shepherd._enabled = true;
shepherd._server = server;
return self._testRequestServer(shepherd);
}).then(function () {
debug('Coap server testing done.');
constructor(port?: number, address?: string) {
if (port !== undefined) {
this.port = port;
}
if (address !== undefined) {
this.address = address;
}
// WoT-specific content formats
coap.registerFormat('application/ld+json', 2100);
// TODO also register content fromat with IANA
// from experimental range for now
coap.registerFormat('application/td+json', 65100);
// TODO need hook from ContentSerdes for runtime data formats
}
init.setupShepherd = function (shepherd, callback) {
var deferred = Q.defer(),
self = this;
debug('coap-shepherd booting...');
coap.registerFormat('application/tlv', 11542); // Leshan TLV binary Content-Formats
coap.registerFormat('application/json', 11543); // Leshan JSON Numeric Content-Formats
coap.updateTiming({
ackTimeout:0.25,
ackRandomFactor: 1.0,
maxRetransmit: 3,
maxLatency: 2,
});
this._coapServerStart(shepherd).then(function (server) {
debug('Create a coap server for shepherd.');
shepherd._enabled = true;
shepherd._server = server;
return self._testRequestServer(shepherd);
}).then(function () {
debug('Coap server testing done.');
return self._loadNodesFromDb(shepherd);
constructor(server?: CoapServer) {
// if server is passed, feed its socket into the CoAP agent for socket re-use
this.agent = new coap.Agent(server ? { socket: server.getSocket() } : undefined);
// WoT-specific content formats
coap.registerFormat(ContentSerdes.JSON_LD, 2100);
// TODO also register content fromat with IANA
// from experimental range for now
coap.registerFormat(ContentSerdes.TD, 65100);
// TODO need hook from ContentSerdes for runtime data formats
}
constructor(port?: number, address?: string) {
if (port !== undefined) {
this.port = port;
}
if (address !== undefined) {
this.address = address;
}
// WoT-specific content formats
coap.registerFormat('application/ld+json', 2100);
// TODO also register content fromat with IANA
// from experimental range for now
coap.registerFormat('application/td+json', 65100);
// TODO need hook from ContentSerdes for runtime data formats
}
if (config.formats) {
formats = config.formats;
} else if (defaultFormats && defaultFormats.formats) {
formats = defaultFormats.formats;
config.formats = formats;
} else {
throw new errors.ContentFormatNotFound();
}
if (!config.writeFormat && defaultFormats && defaultFormats.writeFormat) {
config.writeFormat = defaultFormats.writeFormat;
}
for (var i = 0; i < formats.length; i++) {
libcoap.registerFormat(formats[i].name, formats[i].value);
}
}