Comparing version 0.14.0 to 0.15.0
@@ -51,1 +51,3 @@ /* | ||
module.exports.parameters = parameters | ||
module.exports.updateTiming = parameters.refreshTiming | ||
module.exports.defaultTiming = parameters.defaultTiming |
/* | ||
* Copyright (c) 2013-2015 node-coap contributors. | ||
* | ||
* node-coap is licensed under an MIT +no-false-attribs license. | ||
* All rights not explicitly granted in the MIT license are reserved. | ||
* See the included LICENSE file for more details. | ||
*/ | ||
* Copyright (c) 2013-2015 node-coap contributors. | ||
* | ||
* node-coap is licensed under an MIT +no-false-attribs license. | ||
* All rights not explicitly granted in the MIT license are reserved. | ||
* See the included LICENSE file for more details. | ||
*/ | ||
// CoAP parameters | ||
var p = { | ||
ackTimeout: 2 // seconds | ||
ackTimeout: 2 // seconds | ||
, ackRandomFactor: 1.5 | ||
, maxRetransmit: 4 | ||
, nstart: 1 | ||
, defaultLeisure: 5 | ||
, probingRate: 1 // byte/seconds | ||
@@ -22,35 +19,46 @@ // MAX_LATENCY is the maximum time a datagram is expected to take | ||
, maxLatency: 100 // seconds | ||
, piggybackReplyMs: 50 | ||
// default coap port | ||
, coapPort: 5683 | ||
// default max packet size | ||
, maxPacketSize: 1280 | ||
} | ||
var defaultTiming = JSON.parse(JSON.stringify(p)) | ||
// MAX_TRANSMIT_SPAN is the maximum time from the first transmission | ||
// of a Confirmable message to its last retransmission. | ||
p.maxTransmitSpan = p.ackTimeout * ((Math.pow(2, p.maxRetransmit)) - 1) * p.ackRandomFactor | ||
p.refreshTiming = function(values) { | ||
for (var key in values){ | ||
if (p[key]) { | ||
p[key] = values[key] | ||
} | ||
} | ||
// MAX_TRANSMIT_WAIT is the maximum time from the first transmission | ||
// of a Confirmable message to the time when the sender gives up on | ||
// receiving an acknowledgement or reset. | ||
p.maxTransmitWait = p.ackTimeout * (Math.pow(2, p.maxRetransmit + 1) - 1) * p.ackRandomFactor | ||
// MAX_TRANSMIT_SPAN is the maximum time from the first transmission | ||
// of a Confirmable message to its last retransmission. | ||
p.maxTransmitSpan = p.ackTimeout * ((Math.pow(2, p.maxRetransmit)) - 1) * p.ackRandomFactor | ||
// MAX_TRANSMIT_WAIT is the maximum time from the first transmission | ||
// of a Confirmable message to the time when the sender gives up on | ||
// receiving an acknowledgement or reset. | ||
p.maxTransmitWait = p.ackTimeout * (Math.pow(2, p.maxRetransmit + 1) - 1) * p.ackRandomFactor | ||
// PROCESSING_DELAY is the time a node takes to turn around a | ||
// Confirmable message into an acknowledgement. | ||
p.processingDelay = p.ackTimeout | ||
// PROCESSING_DELAY is the time a node takes to turn around a | ||
// Confirmable message into an acknowledgement. | ||
p.processingDelay = p.ackTimeout | ||
// MAX_RTT is the maximum round-trip time | ||
p.maxRTT = 2 * p.maxLatency + p.processingDelay | ||
// MAX_RTT is the maximum round-trip time | ||
p.maxRTT = 2 * p.maxLatency + p.processingDelay | ||
// EXCHANGE_LIFETIME is the time from starting to send a Confirmable | ||
// message to the time when an acknowledgement is no longer expected, | ||
// i.e. message layer information about the message exchange can be | ||
// purged | ||
p.exchangeLifetime = p.maxTransmitSpan + p.maxRTT | ||
// EXCHANGE_LIFETIME is the time from starting to send a Confirmable | ||
// message to the time when an acknowledgement is no longer expected, | ||
// i.e. message layer information about the message exchange can be | ||
// purged | ||
p.exchangeLifetime = p.maxTransmitSpan + p.maxRTT | ||
} | ||
p.refreshTiming() | ||
// default port for CoAP | ||
p.coapPort = 5683 | ||
// default max packet size | ||
p.maxPacketSize = 1280 | ||
p.defaultTiming = function() { | ||
p.refreshTiming(defaultTiming) | ||
} | ||
module.exports = p |
{ | ||
"name": "coap", | ||
"version": "0.14.0", | ||
"version": "0.15.0", | ||
"description": "A CoAP library for node modelled after 'http'", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -138,2 +138,4 @@ node-coap | ||
* <a href="#globalAgentIPv6"><code>coap.<b>globalAgentIPv6</b></code></a> | ||
* <a href="#updateTiming"><code>coap.<b>updateTiming</b></code></a> | ||
* <a href="#defaultTiming"><code>coap.<b>defaultTiming</b></code></a> | ||
@@ -221,3 +223,3 @@ ------------------------------------------------------- | ||
* `multicastAddress`: Optional. Use this in order to force server to listen on multicast address | ||
* `multicastInterface`: Optional. Use this in order to force server to listen on multicast interface. This is only applicable | ||
* `multicastInterface`: Optional. Use this in order to force server to listen on multicast interface. This is only applicable | ||
if `multicastAddress` is set. If absent, server will try to listen `multicastAddress` on all available interfaces | ||
@@ -231,3 +233,3 @@ * `piggybackReplyMs`: set the number of milliseconds to wait for a | ||
Emitted each time there is a request. | ||
Emitted each time there is a request. | ||
`request` is an instance of <a | ||
@@ -424,3 +426,3 @@ href='#incoming'><code>IncomingMessage</code></a> and `response` is | ||
An `ObserveWriteStream` object is | ||
An `ObserveWriteStream` object is | ||
emitted by the `coap.createServer` `'response'` event as a response | ||
@@ -510,2 +512,25 @@ object. | ||
------------------------------------------------------- | ||
<a name="updateTiming"></a> | ||
### coap.updateTiming | ||
You can update the CoAP timing settings, take a look at the examples: | ||
```js | ||
var coapTiming = { | ||
ackTimeout:0.25, | ||
ackRandomFactor: 1.0, | ||
maxRetransmit: 3, | ||
maxLatency: 2, | ||
piggybackReplyMs: 10 | ||
}; | ||
coap.updateTiming(coapTiming); | ||
``` | ||
------------------------------------------------------- | ||
<a name="defaultTiming"></a> | ||
### coap.defaultTiming | ||
Reset the CoAP timings to the default values | ||
<a name="contributing"></a> | ||
@@ -512,0 +537,0 @@ ## Contributing |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
165486
40
4614
561