From ab706a6f33dab7a17d6b15df5e861b179fe8c548 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Thu, 23 Jun 2016 18:41:40 +0200 Subject: [PATCH] TSCH: map RPL trickle interval to TSCH EB period --- core/net/mac/tsch/tsch-rpl.c | 2 +- core/net/mac/tsch/tsch.c | 2 +- core/net/mac/tsch/tsch.h | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/net/mac/tsch/tsch-rpl.c b/core/net/mac/tsch/tsch-rpl.c index 4558c4366..c6ce0fffd 100644 --- a/core/net/mac/tsch/tsch-rpl.c +++ b/core/net/mac/tsch/tsch-rpl.c @@ -85,7 +85,7 @@ tsch_rpl_callback_new_dio_interval(uint8_t dio_interval) tsch_set_coordinator(1); } /* Set EB period */ - tsch_set_eb_period(TSCH_EB_PERIOD); + tsch_set_eb_period((CLOCK_SECOND * 1UL << dag->instance->dio_intcurrent) / 1000); /* Set join priority based on RPL rank */ tsch_set_join_priority(DAG_RANK(dag->rank, dag->instance) - 1); } else { diff --git a/core/net/mac/tsch/tsch.c b/core/net/mac/tsch/tsch.c index 292744ecc..a214519be 100644 --- a/core/net/mac/tsch/tsch.c +++ b/core/net/mac/tsch/tsch.c @@ -189,7 +189,7 @@ tsch_set_join_priority(uint8_t jp) void tsch_set_eb_period(uint32_t period) { - tsch_current_eb_period = period; + tsch_current_eb_period = MIN(period, TSCH_MAX_EB_PERIOD); } /*---------------------------------------------------------------------------*/ static void diff --git a/core/net/mac/tsch/tsch.h b/core/net/mac/tsch/tsch.h index d548df9d5..03a0068a5 100644 --- a/core/net/mac/tsch/tsch.h +++ b/core/net/mac/tsch/tsch.h @@ -60,7 +60,14 @@ #ifdef TSCH_CONF_EB_PERIOD #define TSCH_EB_PERIOD TSCH_CONF_EB_PERIOD #else -#define TSCH_EB_PERIOD (4 * CLOCK_SECOND) +#define TSCH_EB_PERIOD (16 * CLOCK_SECOND) +#endif + +/* Max Period between two consecutive EBs */ +#ifdef TSCH_CONF_MAX_EB_PERIOD +#define TSCH_MAX_EB_PERIOD TSCH_CONF_MAX_EB_PERIOD +#else +#define TSCH_MAX_EB_PERIOD (50 * CLOCK_SECOND) #endif /* Max acceptable join priority */ @@ -157,7 +164,7 @@ extern const struct mac_driver tschmac_driver; /* The the TSCH join priority */ void tsch_set_join_priority(uint8_t jp); -/* The the period at which EBs are sent */ +/* The period at which EBs are sent */ void tsch_set_eb_period(uint32_t period); /* Set the node as PAN coordinator */ void tsch_set_coordinator(int enable);