diff --git a/sys/include/net/gcoap.h b/sys/include/net/gcoap.h index 1767e83a7e..09cfb99bfb 100644 --- a/sys/include/net/gcoap.h +++ b/sys/include/net/gcoap.h @@ -352,6 +352,20 @@ extern "C" { #define GCOAP_RECV_TIMEOUT (1 * US_PER_SEC) #endif +#ifdef DOXYGEN +/** + * @ingroup net_gcoap_conf + * @brief Turns off retransmission backoff when defined (undefined per default) + * + * In normal operations the timeout between retransmissions doubles. When + * GCOAP_NO_RETRANS_BACKOFF is defined this doubling does not happen. + * + * @see COAP_ACK_TIMEOUT + * @see COAP_ACK_VARIANCE + */ +#define GCOAP_NO_RETRANS_BACKOFF +#endif + /** * @ingroup net_gcoap_conf * @brief Default time to wait for a non-confirmable response [in usec] diff --git a/sys/net/application_layer/gcoap/gcoap.c b/sys/net/application_layer/gcoap/gcoap.c index 0a0246ff35..04d4bae326 100644 --- a/sys/net/application_layer/gcoap/gcoap.c +++ b/sys/net/application_layer/gcoap/gcoap.c @@ -133,7 +133,11 @@ static void *_event_loop(void *arg) /* reduce retries remaining, double timeout and resend */ else { memo->send_limit--; +#ifdef GCOAP_NO_RETRANS_BACKOFF + unsigned i = 0; +#else unsigned i = COAP_MAX_RETRANSMIT - memo->send_limit; +#endif uint32_t timeout = ((uint32_t)COAP_ACK_TIMEOUT << i) * US_PER_SEC; #if COAP_ACK_VARIANCE > 0 uint32_t variance = ((uint32_t)COAP_ACK_VARIANCE << i) * US_PER_SEC;