How to use the coap.registerFormat function in coap

To help you get started, we’ve selected a few coap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Alliasd / ELIoT / lib / init.js View on Github external
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
github PeterEB / coap-node / lib / init.js View on Github external
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
github PeterEB / coap-node / lib / init.js View on Github external
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         
github Alliasd / ELIoT / lib / init.js View on Github external
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
github PeterEB / coap-shepherd / lib / init.js View on Github external
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.');
github eclipse / thingweb.node-wot / packages / binding-coap / src / coap-server.ts View on Github external
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
  }
github PeterEB / coap-shepherd / lib / init.js View on Github external
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);
github eclipse / thingweb.node-wot / packages / binding-coap / src / coap-client.ts View on Github external
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
  }
github eclipse / thingweb.node-wot / packages / binding-coap / src / coap-server.ts View on Github external
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
  }
github telefonicaid / lwm2m-node-lib / lib / services / coapRouter.js View on Github external
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);
    }
}