From 6a5f238255a3a3450db2588cba7383d1be8529a0 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 8 May 2015 10:23:03 +0200 Subject: [PATCH] RPL probing: make delay function user-configurable --- core/net/rpl/rpl-conf.h | 10 ++++++++++ core/net/rpl/rpl-timers.c | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/net/rpl/rpl-conf.h b/core/net/rpl/rpl-conf.h index d3749e033..11d2cdbd0 100644 --- a/core/net/rpl/rpl-conf.h +++ b/core/net/rpl/rpl-conf.h @@ -249,4 +249,14 @@ #define RPL_PROBING_SEND_FUNC(instance, addr) dio_output((instance), (addr)) #endif +/* + * Function used to calculate next RPL probing interval + * */ +#ifdef RPL_CONF_PROBING_DELAY_FUNC +#define RPL_PROBING_DELAY_FUNC RPL_CONF_PROBING_DELAY_FUNC +#else +#define RPL_PROBING_DELAY_FUNC() ((RPL_PROBING_INTERVAL / 2) \ + + random_rand() % (RPL_PROBING_INTERVAL)) +#endif + #endif /* RPL_CONF_H */ diff --git a/core/net/rpl/rpl-timers.c b/core/net/rpl/rpl-timers.c index 7a7a7a2ef..fac19ee4f 100644 --- a/core/net/rpl/rpl-timers.c +++ b/core/net/rpl/rpl-timers.c @@ -414,9 +414,7 @@ handle_probing_timer(void *ptr) void rpl_schedule_probing(rpl_instance_t *instance) { - clock_time_t delay = (RPL_PROBING_INTERVAL / 2) + - random_rand() % (RPL_PROBING_INTERVAL / 2); - ctimer_set(&instance->probing_timer, delay, + ctimer_set(&instance->probing_timer, RPL_PROBING_DELAY_FUNC(), handle_probing_timer, instance); } #endif /* RPL_WITH_PROBING */