1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

net/coap: Move COAP_RANDOM_FACTOR_1000 to 'CONFIG' namespace

COAP_RANDOM_FACTOR_1000 is moved to the compile time configuration macro
namespace.
This commit is contained in:
Leandro Lanzieri 2020-01-28 20:29:40 +01:00
parent 072a0d8563
commit afe4244ac9
No known key found for this signature in database
GPG Key ID: 39607DE6080007A3
2 changed files with 6 additions and 6 deletions

View File

@ -181,7 +181,7 @@ extern "C" {
* timeout doubles for subsequent retries. To avoid synchronization of resends
* across hosts, the actual timeout is chosen randomly between
* @ref CONFIG_COAP_ACK_TIMEOUT and
* (@ref CONFIG_COAP_ACK_TIMEOUT * @ref COAP_RANDOM_FACTOR_1000 / 1000).
* (@ref CONFIG_COAP_ACK_TIMEOUT * @ref CONFIG_COAP_RANDOM_FACTOR_1000 / 1000).
*/
#ifndef CONFIG_COAP_ACK_TIMEOUT
#define CONFIG_COAP_ACK_TIMEOUT (2U)
@ -196,8 +196,8 @@ extern "C" {
*
* See @ref CONFIG_COAP_ACK_TIMEOUT
*/
#ifndef COAP_RANDOM_FACTOR_1000
#define COAP_RANDOM_FACTOR_1000 (1500)
#ifndef CONFIG_COAP_RANDOM_FACTOR_1000
#define CONFIG_COAP_RANDOM_FACTOR_1000 (1500)
#endif
/** @brief Maximum number of retransmissions for a confirmable request */

View File

@ -42,7 +42,7 @@
#define GCOAP_RESOURCE_NO_PATH -2
/* End of the range to pick a random timeout */
#define TIMEOUT_RANGE_END (CONFIG_COAP_ACK_TIMEOUT * COAP_RANDOM_FACTOR_1000 / 1000)
#define TIMEOUT_RANGE_END (CONFIG_COAP_ACK_TIMEOUT * CONFIG_COAP_RANDOM_FACTOR_1000 / 1000)
/* Internal functions */
static void *_event_loop(void *arg);
@ -250,7 +250,7 @@ static void _on_resp_timeout(void *arg) {
unsigned i = COAP_MAX_RETRANSMIT - memo->send_limit;
#endif
uint32_t timeout = ((uint32_t)CONFIG_COAP_ACK_TIMEOUT << i) * US_PER_SEC;
#if COAP_RANDOM_FACTOR_1000 > 1000
#if CONFIG_COAP_RANDOM_FACTOR_1000 > 1000
uint32_t end = ((uint32_t)TIMEOUT_RANGE_END << i) * US_PER_SEC;
timeout = random_uint32_range(timeout, end);
#endif
@ -774,7 +774,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)CONFIG_COAP_ACK_TIMEOUT * US_PER_SEC;
#if COAP_RANDOM_FACTOR_1000 > 1000
#if CONFIG_COAP_RANDOM_FACTOR_1000 > 1000
timeout = random_uint32_range(timeout, TIMEOUT_RANGE_END * US_PER_SEC);
#endif
}