From ecf3321c676e7073bcef025d7e7750b43f8010ba Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Sun, 11 Feb 2018 16:06:02 +0000 Subject: [PATCH] net.h: Update and document coap_calc_timeout() function Include session as one of the parameters to coap_calc_timeout() as it is now per session, which is renamed from calc_timeout() as it is now a public function. --- include/coap/net.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/coap/net.h b/include/coap/net.h index 4ee99540..2ba18735 100644 --- a/include/coap/net.h +++ b/include/coap/net.h @@ -561,6 +561,19 @@ coap_pdu_t *coap_wellknown_response(coap_context_t *context, coap_session_t *session, coap_pdu_t *request); -unsigned int calc_timeout(unsigned char r); +/** + * Calculates the initial timeout based on the session CoAP transmission + * parameters 'ack_timeout', 'ack_random_factor', and COAP_TICKS_PER_SECOND. + * The calculation requires 'ack_timeout' and 'ack_random_factor' to be in + * Qx.FRAC_BITS fixed point notation, whereas the passed parameter @p r + * is interpreted as the fractional part of a Q0.MAX_BITS random value. + * + * @param session session timeout is associated with + * @param r random value as fractional part of a Q0.MAX_BITS fixed point + * value + * @return COAP_TICKS_PER_SECOND * 'ack_timeout' * + * (1 + ('ack_random_factor' - 1) * r) + */ +unsigned int coap_calc_timeout(coap_session_t *session, unsigned char r); #endif /* _COAP_NET_H_ */