gnrc/lwmac : Move GNRC_LWMAC_TIME_BETWEEN_WR_US to 'CONFIG_'

This commit is contained in:
Akshai M 2020-05-22 23:02:28 +05:30
parent 1be3264ab3
commit e38dca5d42
3 changed files with 30 additions and 28 deletions

View File

@ -126,18 +126,18 @@ extern "C" {
* *
* In LWMAC, when a sender initiates a transmission to a receiver, it starts * In LWMAC, when a sender initiates a transmission to a receiver, it starts
* with sending a stream of repeated WR packets with * with sending a stream of repeated WR packets with
* @ref GNRC_LWMAC_TIME_BETWEEN_WR_US interval between two consecutive WRs. * @ref CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US interval between two consecutive
* After sending one WR (preamble) packet, the sender turns to the listen mode * WRs. After sending one WR (preamble) packet, the sender turns to the listen
* to receive the potential incoming WA (preamble-ACK) packet with a timeout of * mode to receive the potential incoming WA (preamble-ACK) packet with a
* @ref GNRC_LWMAC_TIME_BETWEEN_WR_US. If no WA is received during * timeout of @ref CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US. If no WA is received
* @ref GNRC_LWMAC_TIME_BETWEEN_WR_US, the sender starts sending the next WR. * during @ref CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US, the sender starts sending
* It is referenced to the beginning of both WRs, but due to internal * the next WR. It is referenced to the beginning of both WRs, but due to
* overhead, the exact spacing is slightly higher. The minimum possible value * internal overhead, the exact spacing is slightly higher. The minimum
* depends on the time it takes to completely send a WR with the given hardware * possible value depends on the time it takes to completely send a WR with the
* (including processor) and data rate. * given hardware (including processor) and data rate.
*/ */
#ifndef GNRC_LWMAC_TIME_BETWEEN_WR_US #ifndef CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US
#define GNRC_LWMAC_TIME_BETWEEN_WR_US (5U *US_PER_MS) #define CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US (5U *US_PER_MS)
#endif #endif
/** /**
@ -148,14 +148,14 @@ extern "C" {
* period of @ref GNRC_LWMAC_WAKEUP_DURATION_US in each cycle. In the rest of * period of @ref GNRC_LWMAC_WAKEUP_DURATION_US in each cycle. In the rest of
* the cycle, the node turns off the radio to conserve power. * the cycle, the node turns off the radio to conserve power.
* @ref GNRC_LWMAC_WAKEUP_DURATION_US is set to twice the duration of * @ref GNRC_LWMAC_WAKEUP_DURATION_US is set to twice the duration of
* @ref GNRC_LWMAC_TIME_BETWEEN_WR_US, to guarantee that the wake-up period is * @ref CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US, to guarantee that the wake-up
* long enough that receiver will not miss the WR (preamble) packet. * period is long enough that receiver will not miss the WR (preamble) packet.
* Receiver needs to support @ref NETDEV_EVENT_RX_STARTED event in order to use * Receiver needs to support @ref NETDEV_EVENT_RX_STARTED event in order to use
* time-between-WR as a sensible default here. Otherwise the duration of WRs as * time-between-WR as a sensible default here. Otherwise the duration of WRs as
* well as longest possible data broadcasts need to be taken into account. * well as longest possible data broadcasts need to be taken into account.
*/ */
#ifndef GNRC_LWMAC_WAKEUP_DURATION_US #ifndef GNRC_LWMAC_WAKEUP_DURATION_US
#define GNRC_LWMAC_WAKEUP_DURATION_US (GNRC_LWMAC_TIME_BETWEEN_WR_US * 2) #define GNRC_LWMAC_WAKEUP_DURATION_US (CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US * 2)
#endif #endif
/** /**
@ -178,17 +178,18 @@ extern "C" {
* @brief Time to idle between two successive broadcast packets, referenced to * @brief Time to idle between two successive broadcast packets, referenced to
* the start of the packet. * the start of the packet.
* *
* The same limitation as for @ref GNRC_LWMAC_TIME_BETWEEN_WR_US apply here. In * The same limitation as for @ref CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US apply
* LWMAC, when a sender initiates a broadcast, it starts with sending a stream * here. In LWMAC, when a sender initiates a broadcast, it starts with sending
* ofrepeated broadcast packets with @ref GNRC_LWMAC_TIME_BETWEEN_BROADCAST_US * a stream ofrepeated broadcast packets with
* interval between two consecutive broadcast packets. After sending one * @ref GNRC_LWMAC_TIME_BETWEEN_BROADCAST_US interval between two consecutive
* broadcast packet, the sender turns to the listen mode with a timeout of * broadcast packets. After sending one broadcast packet, the sender turns to
* the listen mode with a timeout of
* @ref GNRC_LWMAC_TIME_BETWEEN_BROADCAST_US. When this timeout expires, the * @ref GNRC_LWMAC_TIME_BETWEEN_BROADCAST_US. When this timeout expires, the
* sender sends the next broadcast packet until reaching the maximum broadcast * sender sends the next broadcast packet until reaching the maximum broadcast
* duration of @ref GNRC_LWMAC_BROADCAST_DURATION_US. * duration of @ref GNRC_LWMAC_BROADCAST_DURATION_US.
*/ */
#ifndef GNRC_LWMAC_TIME_BETWEEN_BROADCAST_US #ifndef GNRC_LWMAC_TIME_BETWEEN_BROADCAST_US
#define GNRC_LWMAC_TIME_BETWEEN_BROADCAST_US (GNRC_LWMAC_TIME_BETWEEN_WR_US) #define GNRC_LWMAC_TIME_BETWEEN_BROADCAST_US (CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US)
#endif #endif
/** /**
@ -260,7 +261,7 @@ extern "C" {
* this macro here defines the largest number of packets allowed to be sent in * this macro here defines the largest number of packets allowed to be sent in
* one consecutive sequence. In case a sender has multi packets for one * one consecutive sequence. In case a sender has multi packets for one
* receiver,the burst transmission procedure is as follows: * receiver,the burst transmission procedure is as follows:
* *
* 1. The sender first uses WR stream to locate the receiver's wake-up period * 1. The sender first uses WR stream to locate the receiver's wake-up period
* (if the sender has already phase-locked the receiver's phase, normally * (if the sender has already phase-locked the receiver's phase, normally
* the sender only cost one WR to get the first WA from the receiver) and * the sender only cost one WR to get the first WA from the receiver) and
@ -269,13 +270,13 @@ extern "C" {
* WR to the receiver for starting the second round of transmission of the * WR to the receiver for starting the second round of transmission of the
* second data. The receiver should also immediately reply WA for continue * second data. The receiver should also immediately reply WA for continue
* receiving data packets. In case the sender doesn't receive WA during * receiving data packets. In case the sender doesn't receive WA during
* @ref GNRC_LWMAC_TIME_BETWEEN_WR_US, it regards the consecutive (burst) * @ref CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US, it regards the consecutive
* transmission failed and quits TX procedure (the data will be queued back * (burst) transmission failed and quits TX procedure (the data will be
* to the transmission queue for normal transmission attempt in following * queued back to the transmission queue for normal transmission attempt in
* cycles). * following cycles).
* 3. In case the second transmission succeeds, the sender repeats step (2) to * 3. In case the second transmission succeeds, the sender repeats step (2) to
* send all the following pending packets. * send all the following pending packets.
* *
* In short, in burst transmission mode, the sender doesn't tolerate no-WA * In short, in burst transmission mode, the sender doesn't tolerate no-WA
* event. All the pending data packets should be sent with only one WR cost for * event. All the pending data packets should be sent with only one WR cost for
* leading the transmission. * leading the transmission.

View File

@ -398,7 +398,7 @@ static void _sleep_management(gnrc_netif_t *netif)
* always holding the medium (if the receiver's phase is recorded earlier in this * always holding the medium (if the receiver's phase is recorded earlier in this
* particular node) */ * particular node) */
uint32_t random_backoff; uint32_t random_backoff;
random_backoff = random_uint32_range(0, GNRC_LWMAC_TIME_BETWEEN_WR_US); random_backoff = random_uint32_range(0, CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US);
time_until_tx = time_until_tx + random_backoff; time_until_tx = time_until_tx + random_backoff;
gnrc_lwmac_set_timeout(netif, GNRC_LWMAC_TIMEOUT_WAIT_DEST_WAKEUP, time_until_tx); gnrc_lwmac_set_timeout(netif, GNRC_LWMAC_TIMEOUT_WAIT_DEST_WAKEUP, time_until_tx);

View File

@ -663,7 +663,8 @@ static bool _lwmac_tx_update(gnrc_netif_t *netif)
netif->mac.tx.wr_sent++; netif->mac.tx.wr_sent++;
/* Set timeout for next WR in case no WA will be received */ /* Set timeout for next WR in case no WA will be received */
gnrc_lwmac_set_timeout(netif, GNRC_LWMAC_TIMEOUT_WR, GNRC_LWMAC_TIME_BETWEEN_WR_US); gnrc_lwmac_set_timeout(netif, GNRC_LWMAC_TIMEOUT_WR,
CONFIG_GNRC_LWMAC_TIME_BETWEEN_WR_US);
/* Debug WR timing */ /* Debug WR timing */
LOG_DEBUG("[LWMAC-tx] Destination phase was: %" PRIu32 "\n", LOG_DEBUG("[LWMAC-tx] Destination phase was: %" PRIu32 "\n",