From 8c25d12ae51798abd2f1ca2247c63b7c6b01fb25 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Mon, 27 Jan 2020 17:05:22 +0100 Subject: [PATCH] net/coap: Represent `ACK_RANDOM_FACTOR` multiplied by 1000 --- sys/include/net/coap.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/include/net/coap.h b/sys/include/net/coap.h index 894c019f8b..6d8fe43b6b 100644 --- a/sys/include/net/coap.h +++ b/sys/include/net/coap.h @@ -178,15 +178,24 @@ 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). + * @ref COAP_ACK_TIMEOUT and + * (@ref COAP_ACK_TIMEOUT * @ref COAP_RANDOM_FACTOR_1000 / 1000). */ #ifndef COAP_ACK_TIMEOUT #define COAP_ACK_TIMEOUT (2U) #endif -/** @brief Used to calculate upper bound for timeout; see @ref COAP_ACK_TIMEOUT */ -#ifndef COAP_RANDOM_FACTOR -#define COAP_RANDOM_FACTOR (1.5) +/** + * @brief Used to calculate upper bound for timeout + * + * This represents the `ACK_RANDOM_FACTOR` + * ([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 + */ +#ifndef COAP_RANDOM_FACTOR_1000 +#define COAP_RANDOM_FACTOR_1000 (1500) #endif /**