mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
net/gnrc/rpl: use ztimer_msec if available
This commit is contained in:
parent
9954ac8166
commit
7c6b72d3b4
@ -152,7 +152,6 @@
|
||||
#include "net/gnrc/rpl/dodag.h"
|
||||
#include "net/gnrc/rpl/of_manager.h"
|
||||
#include "net/fib.h"
|
||||
#include "xtimer.h"
|
||||
#include "trickle.h"
|
||||
|
||||
#ifdef MODULE_NETSTATS_RPL
|
||||
|
@ -99,7 +99,9 @@ ifneq (,$(filter gnrc_rpl,$(USEMODULE)))
|
||||
USEMODULE += gnrc_icmpv6
|
||||
USEMODULE += gnrc_ipv6_nib
|
||||
USEMODULE += trickle
|
||||
USEMODULE += xtimer
|
||||
ifeq (,$(filter ztimer_msec,$(USEMODULE)))
|
||||
USEMODULE += xtimer
|
||||
endif
|
||||
USEMODULE += evtimer
|
||||
endif
|
||||
|
||||
|
@ -26,6 +26,12 @@
|
||||
#include "mutex.h"
|
||||
#include "evtimer.h"
|
||||
#include "random.h"
|
||||
#if IS_USED(MODULE_ZTIMER_MSEC)
|
||||
#include "ztimer.h"
|
||||
#include "timex.h"
|
||||
#else
|
||||
#include "xtimer.h"
|
||||
#endif
|
||||
#include "gnrc_rpl_internal/globals.h"
|
||||
|
||||
#include "net/gnrc/rpl.h"
|
||||
@ -41,8 +47,13 @@ static char _stack[GNRC_RPL_STACK_SIZE];
|
||||
kernel_pid_t gnrc_rpl_pid = KERNEL_PID_UNDEF;
|
||||
const ipv6_addr_t ipv6_addr_all_rpl_nodes = GNRC_RPL_ALL_NODES_ADDR;
|
||||
#ifdef MODULE_GNRC_RPL_P2P
|
||||
#if IS_USED(MODULE_ZTIMER_MSEC)
|
||||
static uint32_t _lt_time = GNRC_RPL_LIFETIME_UPDATE_STEP * MS_PER_SEC;
|
||||
static ztimer_t _lt_timer;
|
||||
#else
|
||||
static uint32_t _lt_time = GNRC_RPL_LIFETIME_UPDATE_STEP * US_PER_SEC;
|
||||
static xtimer_t _lt_timer;
|
||||
#endif
|
||||
static msg_t _lt_msg = { .type = GNRC_RPL_MSG_TYPE_LIFETIME_UPDATE };
|
||||
#endif
|
||||
static msg_t _msg_q[GNRC_RPL_MSG_QUEUE_SIZE];
|
||||
@ -96,8 +107,13 @@ kernel_pid_t gnrc_rpl_init(kernel_pid_t if_pid)
|
||||
gnrc_rpl_of_manager_init();
|
||||
evtimer_init_msg(&gnrc_rpl_evtimer);
|
||||
#ifdef MODULE_GNRC_RPL_P2P
|
||||
#if IS_USED(MODULE_ZTIMER_MSEC)
|
||||
ztimer_set_msg(ZTIMER_MSEC, &_lt_timer, _lt_time,
|
||||
&_lt_msg, gnrc_rpl_pid);
|
||||
#else
|
||||
xtimer_set_msg(&_lt_timer, _lt_time, &_lt_msg, gnrc_rpl_pid);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_NETSTATS_RPL
|
||||
memset(&gnrc_rpl_netstats, 0, sizeof(gnrc_rpl_netstats));
|
||||
@ -332,7 +348,11 @@ void _update_lifetime(void)
|
||||
{
|
||||
gnrc_rpl_p2p_update();
|
||||
|
||||
#if IS_USED(MODULE_ZTIMER_MSEC)
|
||||
ztimer_set_msg(ZTIMER_MSEC, &_lt_timer, _lt_time, &_lt_msg, gnrc_rpl_pid);
|
||||
#else
|
||||
xtimer_set_msg(&_lt_timer, _lt_time, &_lt_msg, gnrc_rpl_pid);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -19,6 +19,11 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "kernel_defines.h"
|
||||
#if IS_USED(MODULE_ZTIMER_MSEC)
|
||||
#include "ztimer.h"
|
||||
#else
|
||||
#include "xtimer.h"
|
||||
#endif
|
||||
|
||||
#include "net/af.h"
|
||||
#include "net/icmpv6.h"
|
||||
@ -322,7 +327,11 @@ gnrc_pktsnip_t *_dio_prefix_info_build(gnrc_pktsnip_t *pkt, gnrc_rpl_dodag_t *do
|
||||
prefix_info->prefix_len = 64;
|
||||
if (_get_pl_entry(dodag->iface, &dodag->dodag_id, prefix_info->prefix_len,
|
||||
&ple)) {
|
||||
#if IS_USED(MODULE_ZTIMER_MSEC)
|
||||
uint32_t now = (uint32_t)ztimer_now(ZTIMER_MSEC);
|
||||
#else
|
||||
uint32_t now = (xtimer_now_usec64() / US_PER_MS) & UINT32_MAX;
|
||||
#endif
|
||||
uint32_t valid_ltime = (ple.valid_until < UINT32_MAX) ?
|
||||
(ple.valid_until - now) / MS_PER_SEC : UINT32_MAX;
|
||||
uint32_t pref_ltime = (ple.pref_until < UINT32_MAX) ?
|
||||
|
Loading…
Reference in New Issue
Block a user