CSMA/CA helper

This interface allows code from layer 2 (MAC) or higher to send packets with CSMA/CA, whatever the abilities and/or configuration of a given radio transceiver device are.

const csma_sender_conf_t CSMA_SENDER_CONF_DEFAULT

Default configuration.

int csma_sender_csma_ca_send(netdev.h::netdev_t * dev, iolist.h::iolist_t * iolist, const csma_sender_conf_t * conf)

Sends a 802.15.4 frame using the CSMA/CA method.

If the transceiver can (and is configured to) do hardware-assisted CSMA/CA, this feature is used. Otherwise, a software procedure is used.

Parameters

dev:netdev device, needs to be already initialized
iolist:pointer to the data
conf:configuration for the backoff; will be set to csma_sender.h::CSMA_SENDER_CONF_DEFAULT if NULL.

Return values

  • number of bytes that were actually send out
  • -ENODEV if dev is invalid
  • -ENOMSG if pkt is invalid
  • -EOVERFLOW if the payload size of pkt exceeds the payload size that can be handled by the device
  • -ECANCELED if an internal driver error occured
  • -EBUSY if radio medium never was available to send the given data
int csma_sender_cca_send(netdev.h::netdev_t * dev, iolist.h::iolist_t * iolist)

Sends a 802.15.4 frame when medium is avaiable.

This function is useful for sending packets without the whole CSMA/CA procedure, but after ensuring medium is available, that is after a successful CCA.

It is especially useful for broadcasting specific packets, like beacons; or for many sending packets in burst.

Parameters

dev:netdev device, needs to be already initialized
iolist:pointer to the data

Return values

  • number of bytes that were actually send out
  • -ENODEV if dev is invalid
  • -ENOMSG if pkt is invalid
  • -EOVERFLOW if the payload size of pkt exceeds the payload size that can be handled by the device
  • -ECANCELED if an internal driver error occured
  • -EBUSY if radio medium was not available to send the given data
CSMA_SENDER_MIN_BE_DEFAULT

Default Minimal CSMA/CA Backoff Exponent.

1
(3U)
CSMA_SENDER_MAX_BE_DEFAULT

Default Maximal CSMA/CA Backoff Exponent.

1
(5U)
CSMA_SENDER_MAX_BACKOFFS_DEFAULT

Default Maximal number of retries for sending a given packet with the CSMA/CA method.

1
(4U)
CSMA_SENDER_BACKOFF_PERIOD_UNIT

CSMA/CA backoff period, in microseconds.

1
(320U)
struct csma_sender_conf_t

Configuration type for backoff.

uint8_t min_be

minimum backoff exponent

uint8_t max_be

maximum backoff exponent

uint16_t max_backoffs

maximum number of retries

uint32_t backoff_period

backoff period in microseconds