1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

gnrc/gomach : Move GNRC_GOMACH_CP_DURATION_US to 'CONFIG_'

This commit is contained in:
Akshai M 2020-05-19 13:46:24 +05:30
parent 517e7ff5f7
commit ab3e197c3f
2 changed files with 28 additions and 28 deletions

View File

@ -57,14 +57,14 @@ extern "C" {
* @brief The default duration of GoMacH's wake-up period (WP).
*
* GoMacH adopts the duty-cycle scheme that, by default, a node only wakes up
* for a short period of @ref GNRC_GOMACH_CP_DURATION_US in each cycle. In the
* for a short period of @ref CONFIG_GNRC_GOMACH_CP_DURATION_US in each cycle. In the
* rest of the cycle (except vTDMA), the node turns off the radio to conserve
* power. @ref GNRC_GOMACH_CP_DURATION_US should be at least longer than
* power. @ref CONFIG_GNRC_GOMACH_CP_DURATION_US should be at least longer than
* @ref GNRC_GOMACH_MAX_PREAM_INTERVAL_US, thus to guarantee that the receiver
* will not miss the preamble packet.
*/
#ifndef GNRC_GOMACH_CP_DURATION_US
#define GNRC_GOMACH_CP_DURATION_US (10U * US_PER_MS)
#ifndef CONFIG_GNRC_GOMACH_CP_DURATION_US
#define CONFIG_GNRC_GOMACH_CP_DURATION_US (10U * US_PER_MS)
#endif
/**
@ -83,8 +83,9 @@ extern "C" {
* beginning of a cycle.
*
* @note GoMacH's superframe duration @ref GNRC_GOMACH_SUPERFRAME_DURATION_US
* should not be shorter than 10 times of @ref GNRC_GOMACH_CP_DURATION_US and
* not shorter than the RTT tickle interval.
* should not be shorter than 10 times of
* @ref CONFIG_GNRC_GOMACH_CP_DURATION_US and not shorter than the RTT tickle
* interval.
*/
#ifndef GNRC_GOMACH_SUPERFRAME_DURATION_US
#define GNRC_GOMACH_SUPERFRAME_DURATION_US (300LU * US_PER_MS)
@ -94,12 +95,12 @@ extern "C" {
#error "RTT_FREQUENCY undefined."
#else
#if ((GNRC_GOMACH_SUPERFRAME_DURATION_US < ((1000LU *US_PER_MS) / RTT_FREQUENCY)) || \
(GNRC_GOMACH_SUPERFRAME_DURATION_US < (10 *GNRC_GOMACH_CP_DURATION_US)))
(GNRC_GOMACH_SUPERFRAME_DURATION_US < (10 * CONFIG_GNRC_GOMACH_CP_DURATION_US)))
#undef GNRC_GOMACH_SUPERFRAME_DURATION_US
#if (((1000LU *US_PER_MS) / RTT_FREQUENCY) > (10 * GNRC_GOMACH_CP_DURATION_US))
#if (((1000LU *US_PER_MS) / RTT_FREQUENCY) > (10 * CONFIG_GNRC_GOMACH_CP_DURATION_US))
#define GNRC_GOMACH_SUPERFRAME_DURATION_US ((1000LU * US_PER_MS) / RTT_FREQUENCY)
#else
#define GNRC_GOMACH_SUPERFRAME_DURATION_US (10 * GNRC_GOMACH_CP_DURATION_US)
#define GNRC_GOMACH_SUPERFRAME_DURATION_US (10 * CONFIG_GNRC_GOMACH_CP_DURATION_US)
#endif
#endif
#endif
@ -109,9 +110,10 @@ extern "C" {
* wake-up period (WP).
*
* Currently, GoMacH's WP is actually composed of
* @ref GNRC_GOMACH_CP_DURATION_US and (+) @ref GNRC_GOMACH_CP_RANDOM_END_US.
* We currently introduced this random period to avoid beacon collision among
* neighbor nodes. This macro may be removed in the future.
* @ref CONFIG_GNRC_GOMACH_CP_DURATION_US and (+)
* @ref GNRC_GOMACH_CP_RANDOM_END_US. We currently introduced this random
* period to avoid beacon collision amongneighbor nodes. This macro may be
* removed in the future.
*/
#ifndef GNRC_GOMACH_CP_RANDOM_END_US
#define GNRC_GOMACH_CP_RANDOM_END_US (1U * US_PER_MS)
@ -129,7 +131,7 @@ extern "C" {
* reaches this @ref GNRC_GOMACH_CP_DURATION_MAX_US duration.
*/
#ifndef GNRC_GOMACH_CP_DURATION_MAX_US
#define GNRC_GOMACH_CP_DURATION_MAX_US (5LU * GNRC_GOMACH_CP_DURATION_US)
#define GNRC_GOMACH_CP_DURATION_MAX_US (5LU * CONFIG_GNRC_GOMACH_CP_DURATION_US)
#endif
/**

View File

@ -472,18 +472,18 @@ static void gomach_t2k_init(gnrc_netif_t *netif)
* Firstly, put the calculated phase ahead, check whether the neighbor's phase has gone ahead
* of the recorded one */
if (netif->mac.tx.no_ack_counter == (GNRC_GOMACH_REPHASELOCK_THRESHOLD - 2)) {
if ((uint32_t)wait_phase_duration < GNRC_GOMACH_CP_DURATION_US) {
if ((uint32_t)wait_phase_duration < CONFIG_GNRC_GOMACH_CP_DURATION_US) {
wait_phase_duration = (wait_phase_duration + GNRC_GOMACH_SUPERFRAME_DURATION_US) -
GNRC_GOMACH_CP_DURATION_US;
CONFIG_GNRC_GOMACH_CP_DURATION_US;
}
else {
wait_phase_duration = wait_phase_duration - GNRC_GOMACH_CP_DURATION_US;
wait_phase_duration = wait_phase_duration - CONFIG_GNRC_GOMACH_CP_DURATION_US;
}
}
/* If this is the last t2k trial, the phase-lock auto-adjust scheme delays the estimated phase
* a little bit, to see if the real phase is behind the original calculated one. */
if (netif->mac.tx.no_ack_counter == (GNRC_GOMACH_REPHASELOCK_THRESHOLD - 1)) {
wait_phase_duration = wait_phase_duration + GNRC_GOMACH_CP_DURATION_US;
wait_phase_duration = wait_phase_duration + CONFIG_GNRC_GOMACH_CP_DURATION_US;
if ((uint32_t)wait_phase_duration > GNRC_GOMACH_SUPERFRAME_DURATION_US) {
wait_phase_duration = wait_phase_duration - GNRC_GOMACH_SUPERFRAME_DURATION_US;
}
@ -573,16 +573,13 @@ static void _cp_tx_success(gnrc_netif_t *netif)
* phase upon success. Here the new phase will be put ahead to the
* original phase. */
if (netif->mac.tx.no_ack_counter == (GNRC_GOMACH_REPHASELOCK_THRESHOLD - 2)) {
if (netif->mac.tx.current_neighbor->cp_phase >=
GNRC_GOMACH_CP_DURATION_US) {
netif->mac.tx.current_neighbor->cp_phase -=
GNRC_GOMACH_CP_DURATION_US;
if (netif->mac.tx.current_neighbor->cp_phase >= CONFIG_GNRC_GOMACH_CP_DURATION_US) {
netif->mac.tx.current_neighbor->cp_phase -= CONFIG_GNRC_GOMACH_CP_DURATION_US;
}
else {
netif->mac.tx.current_neighbor->cp_phase +=
GNRC_GOMACH_SUPERFRAME_DURATION_US;
netif->mac.tx.current_neighbor->cp_phase -=
GNRC_GOMACH_CP_DURATION_US;
netif->mac.tx.current_neighbor->cp_phase -= CONFIG_GNRC_GOMACH_CP_DURATION_US;
}
}
/* Here is the phase-lock auto-adjust scheme. Use the new adjusted
@ -590,7 +587,7 @@ static void _cp_tx_success(gnrc_netif_t *netif)
* phase. */
if (netif->mac.tx.no_ack_counter == (GNRC_GOMACH_REPHASELOCK_THRESHOLD - 1)) {
netif->mac.tx.current_neighbor->cp_phase +=
(GNRC_GOMACH_CP_DURATION_US + 20 * US_PER_MS);
(CONFIG_GNRC_GOMACH_CP_DURATION_US + 20 * US_PER_MS);
if (netif->mac.tx.current_neighbor->cp_phase >=
GNRC_GOMACH_SUPERFRAME_DURATION_US) {
@ -1486,10 +1483,9 @@ static void gomach_listen_init(gnrc_netif_t *netif)
/* Set listen period timeout. */
uint32_t listen_period = random_uint32_range(0, GNRC_GOMACH_CP_RANDOM_END_US) +
GNRC_GOMACH_CP_DURATION_US;
CONFIG_GNRC_GOMACH_CP_DURATION_US;
gnrc_gomach_set_timeout(netif, GNRC_GOMACH_TIMEOUT_CP_END, listen_period);
gnrc_gomach_set_timeout(netif, GNRC_GOMACH_TIMEOUT_CP_MAX, GNRC_GOMACH_CP_DURATION_MAX_US);
gnrc_netif_set_rx_started(netif, false);
gnrc_gomach_set_pkt_received(netif, false);
netif->mac.prot.gomach.cp_extend_count = 0;
@ -1523,14 +1519,16 @@ static void _cp_listen_get_pkt(gnrc_netif_t *netif)
gnrc_gomach_set_got_preamble(netif, false);
gnrc_gomach_set_cp_end(netif, false);
gnrc_gomach_clear_timeout(netif, GNRC_GOMACH_TIMEOUT_CP_END);
gnrc_gomach_set_timeout(netif, GNRC_GOMACH_TIMEOUT_CP_END, GNRC_GOMACH_CP_DURATION_US);
gnrc_gomach_set_timeout(netif, GNRC_GOMACH_TIMEOUT_CP_END,
CONFIG_GNRC_GOMACH_CP_DURATION_US);
}
else if ((!gnrc_gomach_get_unintd_preamble(netif)) &&
(!gnrc_gomach_get_quit_cycle(netif))) {
gnrc_gomach_set_got_preamble(netif, false);
gnrc_gomach_set_cp_end(netif, false);
gnrc_gomach_clear_timeout(netif, GNRC_GOMACH_TIMEOUT_CP_END);
gnrc_gomach_set_timeout(netif, GNRC_GOMACH_TIMEOUT_CP_END, GNRC_GOMACH_CP_DURATION_US);
gnrc_gomach_set_timeout(netif, GNRC_GOMACH_TIMEOUT_CP_END,
CONFIG_GNRC_GOMACH_CP_DURATION_US);
}
}