diff --git a/sys/include/net/gnrc/rpl/rpble.h b/sys/include/net/gnrc/rpl/rpble.h new file mode 100644 index 0000000000..2240302408 --- /dev/null +++ b/sys/include/net/gnrc/rpl/rpble.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2021 Freie Universität Berlin + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup net_gnrc_rpl + * @{ + * + * @file + * @brief Glue code linking RPL with the NimBLE rpble connection manager + * + * @author Hauke Petersen + */ + +#ifndef NET_GNRC_RPL_RPBLE_H +#define NET_GNRC_RPL_RPBLE_H + +#include +#if IS_USED(MODULE_NIMBLE_RPBLE) +#include "nimble_rpble.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if IS_USED(MODULE_NIMBLE_RPBLE) +static inline void gnrc_rpl_rpble_update(const gnrc_rpl_dodag_t *dodag) +{ + nimble_rpble_ctx_t ctx; + ctx.inst_id = dodag->instance->id; + memcpy(ctx.dodag_id, &dodag->dodag_id, 16); + ctx.version = dodag->version; + ctx.rank = dodag->my_rank; + ctx.role = dodag->node_status; + nimble_rpble_update(&ctx); +} +#else +static inline void gnrc_rpl_rpble_update(const gnrc_rpl_dodag_t *dodag) +{ + (void)dodag; + /* do nothing here */ +} +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* NET_GNRC_RPL_RPBLE_H */ +/** @} */ diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl.c b/sys/net/gnrc/routing/rpl/gnrc_rpl.c index 1b4c7c80e2..f2b0f3749d 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl.c @@ -35,6 +35,7 @@ #include "gnrc_rpl_internal/globals.h" #include "net/gnrc/rpl.h" +#include "net/gnrc/rpl/rpble.h" #ifdef MODULE_GNRC_RPL_P2P #include "net/gnrc/rpl/p2p.h" #include "net/gnrc/rpl/p2p_dodag.h" @@ -165,6 +166,7 @@ gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, const ipv6_addr_t * trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_MSG, (1 << dodag->dio_min), dodag->dio_interval_doubl, dodag->dio_redun); + gnrc_rpl_rpble_update(dodag); return inst; } diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c index 806c606be7..8a0ead7fcb 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c @@ -29,6 +29,7 @@ #include "utlist.h" #include "net/gnrc/rpl.h" +#include "net/gnrc/rpl/rpble.h" #ifdef MODULE_GNRC_RPL_P2P #include "net/gnrc/rpl/p2p.h" #include "net/gnrc/rpl/p2p_dodag.h" @@ -359,6 +360,7 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda dodag->my_rank = dodag->instance->of->calc_rank(dodag, 0); if (dodag->my_rank != old_rank) { trickle_reset_timer(&dodag->trickle); + gnrc_rpl_rpble_update(dodag); } LL_FOREACH_SAFE(dodag->parents, elt, tmp) {