mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 22:43:50 +01:00
net/coap: Move COAP_ACK_TIMEOUT to 'CONFIG' namespace
COAP_ACK_TIMEOUT is moved to the compile time configuration macro namespace.
This commit is contained in:
parent
e9d2fdb29b
commit
072a0d8563
@ -180,11 +180,11 @@ extern "C" {
|
||||
* This value is for the response to the *initial* confirmable message. The
|
||||
* timeout doubles for subsequent retries. To avoid synchronization of resends
|
||||
* across hosts, the actual timeout is chosen randomly between
|
||||
* @ref COAP_ACK_TIMEOUT and
|
||||
* (@ref COAP_ACK_TIMEOUT * @ref COAP_RANDOM_FACTOR_1000 / 1000).
|
||||
* @ref CONFIG_COAP_ACK_TIMEOUT and
|
||||
* (@ref CONFIG_COAP_ACK_TIMEOUT * @ref COAP_RANDOM_FACTOR_1000 / 1000).
|
||||
*/
|
||||
#ifndef COAP_ACK_TIMEOUT
|
||||
#define COAP_ACK_TIMEOUT (2U)
|
||||
#ifndef CONFIG_COAP_ACK_TIMEOUT
|
||||
#define CONFIG_COAP_ACK_TIMEOUT (2U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -194,7 +194,7 @@ extern "C" {
|
||||
* ([RFC 7252, section 4.2](https://tools.ietf.org/html/rfc7252#section-4.2))
|
||||
* multiplied by 1000, to avoid floating point arithmetic.
|
||||
*
|
||||
* See @ref COAP_ACK_TIMEOUT
|
||||
* See @ref CONFIG_COAP_ACK_TIMEOUT
|
||||
*/
|
||||
#ifndef COAP_RANDOM_FACTOR_1000
|
||||
#define COAP_RANDOM_FACTOR_1000 (1500)
|
||||
|
||||
@ -517,7 +517,7 @@ extern "C" {
|
||||
* In normal operations the timeout between retransmissions doubles. When
|
||||
* CONFIG_GCOAP_NO_RETRANS_BACKOFF is defined this doubling does not happen.
|
||||
*
|
||||
* @see COAP_ACK_TIMEOUT
|
||||
* @see CONFIG_COAP_ACK_TIMEOUT
|
||||
*/
|
||||
#define CONFIG_GCOAP_NO_RETRANS_BACKOFF
|
||||
#endif
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
#define GCOAP_RESOURCE_NO_PATH -2
|
||||
|
||||
/* End of the range to pick a random timeout */
|
||||
#define TIMEOUT_RANGE_END (COAP_ACK_TIMEOUT * COAP_RANDOM_FACTOR_1000 / 1000)
|
||||
#define TIMEOUT_RANGE_END (CONFIG_COAP_ACK_TIMEOUT * COAP_RANDOM_FACTOR_1000 / 1000)
|
||||
|
||||
/* Internal functions */
|
||||
static void *_event_loop(void *arg);
|
||||
@ -249,7 +249,7 @@ static void _on_resp_timeout(void *arg) {
|
||||
#else
|
||||
unsigned i = COAP_MAX_RETRANSMIT - memo->send_limit;
|
||||
#endif
|
||||
uint32_t timeout = ((uint32_t)COAP_ACK_TIMEOUT << i) * US_PER_SEC;
|
||||
uint32_t timeout = ((uint32_t)CONFIG_COAP_ACK_TIMEOUT << i) * US_PER_SEC;
|
||||
#if COAP_RANDOM_FACTOR_1000 > 1000
|
||||
uint32_t end = ((uint32_t)TIMEOUT_RANGE_END << i) * US_PER_SEC;
|
||||
timeout = random_uint32_range(timeout, end);
|
||||
@ -773,7 +773,7 @@ size_t gcoap_req_send(const uint8_t *buf, size_t len,
|
||||
}
|
||||
if (memo->msg.data.pdu_buf) {
|
||||
memo->send_limit = COAP_MAX_RETRANSMIT;
|
||||
timeout = (uint32_t)COAP_ACK_TIMEOUT * US_PER_SEC;
|
||||
timeout = (uint32_t)CONFIG_COAP_ACK_TIMEOUT * US_PER_SEC;
|
||||
#if COAP_RANDOM_FACTOR_1000 > 1000
|
||||
timeout = random_uint32_range(timeout, TIMEOUT_RANGE_END * US_PER_SEC);
|
||||
#endif
|
||||
|
||||
@ -48,7 +48,7 @@ ssize_t nanocoap_request(coap_pkt_t *pkt, sock_udp_ep_t *local, sock_udp_ep_t *r
|
||||
|
||||
/* TODO: timeout random between between ACK_TIMEOUT and (ACK_TIMEOUT *
|
||||
* ACK_RANDOM_FACTOR) */
|
||||
uint32_t timeout = COAP_ACK_TIMEOUT * US_PER_SEC;
|
||||
uint32_t timeout = CONFIG_COAP_ACK_TIMEOUT * US_PER_SEC;
|
||||
unsigned tries_left = COAP_MAX_RETRANSMIT + 1; /* add 1 for initial transmit */
|
||||
while (tries_left) {
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ static ssize_t _nanocoap_request(sock_udp_t *sock, coap_pkt_t *pkt, size_t len)
|
||||
|
||||
/* TODO: timeout random between between ACK_TIMEOUT and (ACK_TIMEOUT *
|
||||
* ACK_RANDOM_FACTOR) */
|
||||
uint32_t timeout = COAP_ACK_TIMEOUT * US_PER_SEC;
|
||||
uint32_t timeout = CONFIG_COAP_ACK_TIMEOUT * US_PER_SEC;
|
||||
uint32_t deadline = deadline_from_interval(timeout);
|
||||
|
||||
/* add 1 for initial transmit */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user