Skip to content

Commit

Permalink
csma_sender: proper prefixing for public functions and macros
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Jun 5, 2016
1 parent c1c7974 commit 70b3b14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
20 changes: 10 additions & 10 deletions sys/include/net/gnrc/csma_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,47 +35,47 @@ extern "C" {
/**
* @brief Default Minimal CSMA/CA Backoff Exponent
*/
#define MAC_MIN_BE_DEFAULT (3U)
#define CSMA_SENDER_MIN_BE_DEFAULT (3U)

/**
* @brief Default Maximal CSMA/CA Backoff Exponent
*/
#define MAC_MAX_BE_DEFAULT (5U)
#define CSMA_SENDER_MAX_BE_DEFAULT (5U)

/**
* @brief Default Maximal number of retries for sending
* a given packet with the CSMA/CA method
*/
#define MAC_MAX_CSMA_BACKOFFS_DEFAULT (4U)
#define CSMA_SENDER_MAX_BACKOFFS_DEFAULT (4U)

/**
* @brief CSMA/CA backoff period, in microseconds
*/
#define A_UNIT_BACKOFF_PERIOD_MICROSEC (320U)
#define CSMA_SENDER_BACKOFF_PERIOD_UNIT (320U)

/**
* @brief Define a different (non-standard) value for
* the CSMA macMinBE parameter.
*
* @param[in] val new value for macMinBE
*/
void set_csma_mac_min_be(uint8_t val);
void csma_sender_set_min_be(uint8_t val);

/**
* @brief Define a different (non-standard) value for
* the CSMA macMaxBE parameter.
*
* @param[in] val new value for macMaxBE
*/
void set_csma_mac_max_be(uint8_t val);
void csma_sender_set_max_be(uint8_t val);

/**
* @brief Define a different (non-standard) value for
* the CSMA macMaxCSMABackoffs parameter.
*
* @param[in] val new value for macMaxCSMABackoffs
*/
void set_csma_mac_max_csma_backoffs(uint8_t val);
void csma_sender_set_max_backoffs(uint8_t val);

/**
* @brief Sends a 802.15.4 frame using the CSMA/CA method
Expand All @@ -97,7 +97,7 @@ void set_csma_mac_max_csma_backoffs(uint8_t val);
* @return -EBUSY if radio medium never was available
* to send the given data
*/
int csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt);
int csma_sender_csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt);

/**
* @brief Sends a 802.15.4 frame when medium is avaiable.
Expand All @@ -108,7 +108,7 @@ int csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt);
* It is especially useful for broadcasting specific packets,
* like beacons; or for many sending packets in burst. <br/>
* ATTENTION: It only tries to send the given data once. If you want the
* complete CSMA/CA procedure with retries, use @c csma_ca_send().
* complete CSMA/CA procedure with retries, use @c csma_sender_csma_ca_send().
*
* @param[in] dev netdev device, needs to be already initialized
* @param[in] pkt pointer to the data in the packet buffer;
Expand All @@ -124,7 +124,7 @@ int csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt);
* @return -EBUSY if radio medium was not available
* to send the given data
*/
int cca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt);
int csma_sender_cca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt);


#ifdef __cplusplus
Expand Down
22 changes: 11 additions & 11 deletions sys/net/gnrc/link_layer/csma_sender/gnrc_csma_sender.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@


/** @brief Current value for mac_min_be parameter */
static uint8_t mac_min_be = MAC_MIN_BE_DEFAULT;
static uint8_t mac_min_be = CSMA_SENDER_MIN_BE_DEFAULT;

/** @brief Current value for mac_max_be parameter */
static uint8_t mac_max_be = MAC_MAX_BE_DEFAULT;
static uint8_t mac_max_be = CSMA_SENDER_MAX_BE_DEFAULT;

/** @brief Current value for mac_max_csma_backoffs parameter */
static uint8_t mac_max_csma_backoffs = MAC_MAX_CSMA_BACKOFFS_DEFAULT;
static uint8_t mac_max_csma_backoffs = CSMA_SENDER_MAX_BACKOFFS_DEFAULT;


/*--------------------- "INTERNAL" UTILITY FUNCTIONS ---------------------*/
Expand All @@ -62,11 +62,11 @@ static inline uint32_t choose_backoff_period(int be)
if (be > mac_max_be) {
be = mac_max_be;
}
uint32_t max_backoff = ((1 << be) - 1) * A_UNIT_BACKOFF_PERIOD_MICROSEC;
uint32_t max_backoff = ((1 << be) - 1) * CSMA_SENDER_BACKOFF_PERIOD_UNIT;

uint32_t period = random_uint32() % max_backoff;
if (period < A_UNIT_BACKOFF_PERIOD_MICROSEC) {
period = A_UNIT_BACKOFF_PERIOD_MICROSEC;
if (period < CSMA_SENDER_BACKOFF_PERIOD_UNIT) {
period = CSMA_SENDER_BACKOFF_PERIOD_UNIT;
}

return period;
Expand Down Expand Up @@ -116,23 +116,23 @@ static int send_if_cca(gnrc_netdev_t *device, gnrc_pktsnip_t *data)

/*------------------------- "EXPORTED" FUNCTIONS -------------------------*/

void set_csma_mac_min_be(uint8_t val)
void csma_sender_set_min_be(uint8_t val)
{
mac_min_be = val;
}

void set_csma_mac_max_be(uint8_t val)
void csma_sender_set_max_be(uint8_t val)
{
mac_max_be = val;
}

void set_csma_mac_max_csma_backoffs(uint8_t val)
void csma_sender_set_max_backoffs(uint8_t val)
{
mac_max_csma_backoffs = val;
}


int csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt)
int csma_sender_csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt)
{
netopt_enable_t hwfeat;

Expand Down Expand Up @@ -202,7 +202,7 @@ int csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt)
}


int cca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt)
int csma_sender_cca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt)
{
netopt_enable_t hwfeat;

Expand Down

0 comments on commit 70b3b14

Please sign in to comment.