From 94660f4db7775c83650681068e8b23c75cb9235f Mon Sep 17 00:00:00 2001 From: Ken Bannister Date: Sat, 29 Dec 2018 11:49:53 -0500 Subject: [PATCH] net/coap: allow user to configure message retry macros --- sys/include/net/coap.h | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/sys/include/net/coap.h b/sys/include/net/coap.h index 23a4db50bd..66313cfff4 100644 --- a/sys/include/net/coap.h +++ b/sys/include/net/coap.h @@ -157,20 +157,52 @@ extern "C" { /** @} */ /** - * @name Timing parameters + * @defgroup net_coap_conf CoAP compile configurations + * @ingroup net_coap + * @ingroup config * @{ */ -#define COAP_ACK_TIMEOUT (2U) -#define COAP_RANDOM_FACTOR (1.5) /** - * @brief Maximum variation for confirmable timeout. + * @brief Timeout in seconds for a response to a confirmable request + * + * 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). + */ +#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) +#endif + +/** + * @brief Approximation for maximum variation for confirmable timeout * * Must be an integer, defined as: * * (COAP_ACK_TIMEOUT * COAP_RANDOM_FACTOR) - COAP_ACK_TIMEOUT + * + * Like @ref COAP_ACK_TIMEOUT, this value is valid for the initial confirmable + * message, and doubles for subsequent retries. */ +#ifndef COAP_ACK_VARIANCE #define COAP_ACK_VARIANCE (1U) +#endif + +/** @brief Maximum number of retransmissions for a confirmable request */ +#ifndef COAP_MAX_RETRANSMIT #define COAP_MAX_RETRANSMIT (4) +#endif +/** @} */ + +/** + * @name Timing parameters + * @{ + */ #define COAP_NSTART (1) #define COAP_DEFAULT_LEISURE (5) /** @} */