How to use the coap.updateTiming 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 avency / coap-cli / index.js View on Github external
})
}

var defaultAckTimeout = 30.0
if (program.ackTimeout) {
  defaultAckTimeout = program.ackTimeout
}

var coapTiming = {
  ackTimeout: defaultAckTimeout,
  ackRandomFactor: 1.0,
  maxRetransmit: 5,
  maxLatency: 2,
  piggybackReplyMs: 10
}
coap.updateTiming(coapTiming)

req.on('response', function (res) {
  var endTime = new Date()
  if (program.showTiming) {
    console.log('Request took ' + (endTime.getTime() - startTime.getTime()) + ' ms')
  }

  // print only status code on empty response
  if (!res.payload.length && !program.quiet) {
    process.stderr.write('\x1b[1m(' + res.code + ')\x1b[0m\n')
  }

  res.pipe(through(function addNewLine (chunk, enc, callback) {
    if (!program.quiet) {
      process.stderr.write('\x1b[1m(' + res.code + ')\x1b[0m\t')
    }
github PeterEB / coap-shepherd / lib / coap-shepherd.js View on Github external
port: this._config.port,
        mac: '',
        routerIp: ''
    };

    this._agent = coap.globalAgent;
    this._registry = {};
    this._server = null;

    this._enabled = false;
    this._joinable = false;
    this._hbChecker = null;
    this._permitJoinTime = 0; 
    this._permitJoinTimer = null;

    coap.updateTiming({
        maxLatency: (this._config.reqTimeout - 47) / 2
    });

    this._acceptDevIncoming = function (devInfo, callback) {   // Override at will.
        setImmediate(function () {
            var accepted = true;
            callback(null, accepted);
        });
    };
}