net/gnrc/rpl: add hooks for nimble_rpble

This commit is contained in:
Hauke Petersen 2021-04-20 14:46:15 +02:00
parent 42f033afb9
commit f5f28347c2
3 changed files with 59 additions and 0 deletions

View File

@ -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 <hauke.petersen@fu-berlin.de>
*/
#ifndef NET_GNRC_RPL_RPBLE_H
#define NET_GNRC_RPL_RPBLE_H
#include <string.h>
#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 */
/** @} */

View File

@ -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;
}

View File

@ -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) {