mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
gnrc/gomach : Move GNRC_GOMACH_SUPERFRAME_DURATION_US to 'CONFIG_'
This commit is contained in:
parent
ab3e197c3f
commit
e6da0bab49
@ -82,25 +82,25 @@ extern "C" {
|
||||
* listening. In GoMacH, by default, we regard the wake-up period (WP) as the
|
||||
* beginning of a cycle.
|
||||
*
|
||||
* @note GoMacH's superframe duration @ref GNRC_GOMACH_SUPERFRAME_DURATION_US
|
||||
* should not be shorter than 10 times of
|
||||
* @ref CONFIG_GNRC_GOMACH_CP_DURATION_US and not shorter than the RTT tickle
|
||||
* interval.
|
||||
* @note GoMacH's superframe duration
|
||||
* @ref CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US 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)
|
||||
#ifndef CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US
|
||||
#define CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US (300LU * US_PER_MS)
|
||||
#endif
|
||||
|
||||
#ifndef RTT_FREQUENCY
|
||||
#error "RTT_FREQUENCY undefined."
|
||||
#else
|
||||
#if ((GNRC_GOMACH_SUPERFRAME_DURATION_US < ((1000LU *US_PER_MS) / RTT_FREQUENCY)) || \
|
||||
(GNRC_GOMACH_SUPERFRAME_DURATION_US < (10 * CONFIG_GNRC_GOMACH_CP_DURATION_US)))
|
||||
#undef GNRC_GOMACH_SUPERFRAME_DURATION_US
|
||||
#if ((CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US < ((1000LU *US_PER_MS) / RTT_FREQUENCY)) || \
|
||||
(CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US < (10 * CONFIG_GNRC_GOMACH_CP_DURATION_US)))
|
||||
#undef CONFIG_GNRC_GOMACH_SUPERFRAME_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)
|
||||
#define CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US ((1000LU * US_PER_MS) / RTT_FREQUENCY)
|
||||
#else
|
||||
#define GNRC_GOMACH_SUPERFRAME_DURATION_US (10 * CONFIG_GNRC_GOMACH_CP_DURATION_US)
|
||||
#define CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US (10 * CONFIG_GNRC_GOMACH_CP_DURATION_US)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@ -218,9 +218,9 @@ extern "C" {
|
||||
*
|
||||
* In GoMacH, when sending a broadcast packet, the sender broadcasts the same
|
||||
* packet frame on its two public channels simultaneously, with a total duration
|
||||
* of @ref GNRC_GOMACH_SUPERFRAME_DURATION_US to guarantee that all neighbors
|
||||
* will get a copy. This macro defines the time interval between sending two
|
||||
* consecutive broadcast copies.
|
||||
* of @ref CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US to guarantee that all
|
||||
* neighbors will get a copy. This macro defines the time interval between
|
||||
* ending two consecutive broadcast copies.
|
||||
*/
|
||||
#ifndef GNRC_GOMACH_BCAST_INTERVAL_US
|
||||
#define GNRC_GOMACH_BCAST_INTERVAL_US (1U * US_PER_MS)
|
||||
@ -235,10 +235,11 @@ extern "C" {
|
||||
* in a critical case that one public channel is jammed, the sender repeatedly
|
||||
* broadcasts a stream of preamble packets with the broadcast duration
|
||||
* (preamble duration) slightly longer than twice of
|
||||
* @ref GNRC_GOMACH_SUPERFRAME_DURATION_US.
|
||||
* @ref CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US.
|
||||
*/
|
||||
#ifndef GNRC_GOMACH_PREAMBLE_DURATION_US
|
||||
#define GNRC_GOMACH_PREAMBLE_DURATION_US (21LU * GNRC_GOMACH_SUPERFRAME_DURATION_US / 10)
|
||||
#define GNRC_GOMACH_PREAMBLE_DURATION_US \
|
||||
(21LU * CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US / 10)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -193,7 +193,7 @@ static void _gomach_rtt_handler(uint32_t event, gnrc_netif_t *netif)
|
||||
|
||||
/* Set next cycle's starting time. */
|
||||
uint32_t alarm = netif->mac.prot.gomach.last_wakeup +
|
||||
RTT_US_TO_TICKS(GNRC_GOMACH_SUPERFRAME_DURATION_US);
|
||||
RTT_US_TO_TICKS(CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US);
|
||||
rtt_set_alarm(alarm, _gomach_rtt_cb, NULL);
|
||||
|
||||
/* Update neighbors' public channel phases. */
|
||||
@ -241,7 +241,7 @@ static void gomach_bcast_init(gnrc_netif_t *netif)
|
||||
}
|
||||
|
||||
gnrc_gomach_set_timeout(netif, GNRC_GOMACH_TIMEOUT_BCAST_FINISH,
|
||||
GNRC_GOMACH_SUPERFRAME_DURATION_US);
|
||||
CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US);
|
||||
|
||||
gnrc_priority_pktqueue_flush(&netif->mac.rx.queue);
|
||||
netif->mac.tx.bcast_state = GNRC_GOMACH_BCAST_SEND;
|
||||
@ -402,7 +402,7 @@ static void gomach_init_prepare(gnrc_netif_t *netif)
|
||||
rtt_clear_alarm();
|
||||
|
||||
/* Random delay for avoiding the same wake-up phase among devices. */
|
||||
uint32_t random_backoff = random_uint32_range(0, GNRC_GOMACH_SUPERFRAME_DURATION_US);
|
||||
uint32_t random_backoff = random_uint32_range(0, CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US);
|
||||
xtimer_usleep(random_backoff);
|
||||
|
||||
gnrc_gomach_set_quit_cycle(netif, false);
|
||||
@ -463,7 +463,7 @@ static void gomach_t2k_init(gnrc_netif_t *netif)
|
||||
gnrc_gomach_phase_now(netif);
|
||||
|
||||
if (wait_phase_duration < 0) {
|
||||
wait_phase_duration += GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
wait_phase_duration += CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
}
|
||||
|
||||
/* Upon several times of t2k failure, we now doubt that the phase-lock may fail due to drift.
|
||||
@ -473,7 +473,8 @@ static void gomach_t2k_init(gnrc_netif_t *netif)
|
||||
* of the recorded one */
|
||||
if (netif->mac.tx.no_ack_counter == (GNRC_GOMACH_REPHASELOCK_THRESHOLD - 2)) {
|
||||
if ((uint32_t)wait_phase_duration < CONFIG_GNRC_GOMACH_CP_DURATION_US) {
|
||||
wait_phase_duration = (wait_phase_duration + GNRC_GOMACH_SUPERFRAME_DURATION_US) -
|
||||
wait_phase_duration = (wait_phase_duration +
|
||||
CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US) -
|
||||
CONFIG_GNRC_GOMACH_CP_DURATION_US;
|
||||
}
|
||||
else {
|
||||
@ -484,13 +485,13 @@ static void gomach_t2k_init(gnrc_netif_t *netif)
|
||||
* 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 + 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;
|
||||
if ((uint32_t)wait_phase_duration > CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US) {
|
||||
wait_phase_duration = wait_phase_duration - CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint32_t)wait_phase_duration > GNRC_GOMACH_SUPERFRAME_DURATION_US) {
|
||||
wait_phase_duration = wait_phase_duration % GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
if ((uint32_t)wait_phase_duration > CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US) {
|
||||
wait_phase_duration = wait_phase_duration % CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
}
|
||||
gnrc_gomach_set_timeout(netif, GNRC_GOMACH_TIMEOUT_WAIT_CP, (uint32_t)wait_phase_duration);
|
||||
|
||||
@ -577,8 +578,7 @@ static void _cp_tx_success(gnrc_netif_t *netif)
|
||||
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 += CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
netif->mac.tx.current_neighbor->cp_phase -= CONFIG_GNRC_GOMACH_CP_DURATION_US;
|
||||
}
|
||||
}
|
||||
@ -590,9 +590,9 @@ static void _cp_tx_success(gnrc_netif_t *netif)
|
||||
(CONFIG_GNRC_GOMACH_CP_DURATION_US + 20 * US_PER_MS);
|
||||
|
||||
if (netif->mac.tx.current_neighbor->cp_phase >=
|
||||
GNRC_GOMACH_SUPERFRAME_DURATION_US) {
|
||||
CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US) {
|
||||
netif->mac.tx.current_neighbor->cp_phase -=
|
||||
GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1446,7 +1446,7 @@ static void _gomach_phase_backoff(gnrc_netif_t *netif)
|
||||
netif->mac.prot.gomach.last_wakeup = rtt_get_counter();
|
||||
|
||||
uint32_t alarm = netif->mac.prot.gomach.last_wakeup +
|
||||
RTT_US_TO_TICKS(GNRC_GOMACH_SUPERFRAME_DURATION_US);
|
||||
RTT_US_TO_TICKS(CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US);
|
||||
|
||||
rtt_set_alarm(alarm, _gomach_rtt_cb, NULL);
|
||||
|
||||
|
@ -463,7 +463,8 @@ int gnrc_gomach_send_beacon(gnrc_netif_t *netif)
|
||||
uint8_t slots_list[GNRC_GOMACH_SLOSCH_UNIT_COUNT];
|
||||
|
||||
/* Check the maximum number of slots that can be allocated to senders. */
|
||||
uint16_t max_slot_num = (GNRC_GOMACH_SUPERFRAME_DURATION_US - gnrc_gomach_phase_now(netif)) /
|
||||
uint16_t max_slot_num = (CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US -
|
||||
gnrc_gomach_phase_now(netif)) /
|
||||
GNRC_GOMACH_VTDMA_SLOT_SIZE_US;
|
||||
|
||||
for (i = 0; i < GNRC_GOMACH_SLOSCH_UNIT_COUNT; i++) {
|
||||
@ -939,17 +940,19 @@ void gnrc_gomach_process_preamble_ack(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
||||
gomach_preamble_ack_hdr->phase_in_us;
|
||||
|
||||
if (phase_us < 0) {
|
||||
phase_us += GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
phase_us += CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
}
|
||||
|
||||
if (((uint32_t)phase_us > (GNRC_GOMACH_SUPERFRAME_DURATION_US - GNRC_GOMACH_CP_MIN_GAP_US)) ||
|
||||
if (((uint32_t)phase_us > (CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US -
|
||||
GNRC_GOMACH_CP_MIN_GAP_US)) ||
|
||||
((uint32_t)phase_us < GNRC_GOMACH_CP_MIN_GAP_US)) {
|
||||
LOG_DEBUG("[GOMACH] t2u: own phase is close to the neighbor's.\n");
|
||||
gnrc_gomach_set_phase_backoff(netif, true);
|
||||
/* Set a random phase-backoff value. */
|
||||
netif->mac.prot.gomach.backoff_phase_us =
|
||||
random_uint32_range(GNRC_GOMACH_CP_MIN_GAP_US,
|
||||
(GNRC_GOMACH_SUPERFRAME_DURATION_US - GNRC_GOMACH_CP_MIN_GAP_US));
|
||||
(CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US -
|
||||
GNRC_GOMACH_CP_MIN_GAP_US));
|
||||
}
|
||||
|
||||
netif->mac.tx.current_neighbor->cp_phase = phase_us;
|
||||
@ -1393,7 +1396,7 @@ void gnrc_gomach_update_neighbor_phase(gnrc_netif_t *netif)
|
||||
long int tmp = netif->mac.tx.neighbors[i].cp_phase -
|
||||
netif->mac.prot.gomach.backoff_phase_us;
|
||||
if (tmp < 0) {
|
||||
tmp += GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
tmp += CONFIG_GNRC_GOMACH_SUPERFRAME_DURATION_US;
|
||||
|
||||
/* Toggle the neighbor's public channel phase if tmp < 0. */
|
||||
if (netif->mac.tx.neighbors[i].pub_chanseq ==
|
||||
|
Loading…
Reference in New Issue
Block a user