mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
ng_netconf: ng_at86rf2xx: set retransmissions
Introduces a netconf option to configure the maximum amount of retransmissions and implements this for the at86rf2xx radios.
This commit is contained in:
parent
cfc3bf5f70
commit
76e4c820e5
@ -316,6 +316,27 @@ int16_t ng_at86rf2xx_get_txpower(ng_at86rf2xx_t *dev);
|
||||
*/
|
||||
void ng_at86rf2xx_set_txpower(ng_at86rf2xx_t *dev, int16_t txpower);
|
||||
|
||||
/**
|
||||
* @brief Get the maximum number of retransmissions
|
||||
*
|
||||
* @param[in] dev device to read from
|
||||
*
|
||||
* @return configured number of retransmissions
|
||||
*/
|
||||
uint8_t ng_at86rf2xx_get_max_retries(ng_at86rf2xx_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Set the maximum number of retransmissions
|
||||
*
|
||||
* This setting specifies the number of attempts to retransmit a frame, when it
|
||||
* was not acknowledged by the recipient, before the transaction gets cancelled.
|
||||
* The maximum value is 7.
|
||||
*
|
||||
* @param[in] dev device to write to
|
||||
* @param[in] max the maximum number of retransmissions
|
||||
*/
|
||||
void ng_at86rf2xx_set_max_retries(ng_at86rf2xx_t *dev, uint8_t max);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable driver specific options
|
||||
*
|
||||
|
@ -291,6 +291,15 @@ extern "C" {
|
||||
#define NG_AT86RF2XX_TIMING__RESET_TO_TRX_OFF (37)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Bitfield definitions for the XAH_CTRL_0 register
|
||||
* @{
|
||||
*/
|
||||
#define NG_AT86RF2XX_XAH_CTRL_0__MAX_FRAME_RETRIES (0xF0)
|
||||
#define NG_AT86RF2XX_XAH_CTRL_0__MAX_CSMA_RETRIES (0x0E)
|
||||
#define NG_AT86RF2XX_XAH_CTRL_0__SLOTTED_OPERATION (0x01)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Bitfield definitions for the XAH_CTRL_1 register
|
||||
* @{
|
||||
|
@ -235,6 +235,20 @@ void ng_at86rf2xx_set_txpower(ng_at86rf2xx_t *dev, int16_t txpower)
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t ng_at86rf2xx_get_max_retries(ng_at86rf2xx_t *dev)
|
||||
{
|
||||
return (ng_at86rf2xx_reg_read(dev, NG_AT86RF2XX_REG__XAH_CTRL_0) >> 4);
|
||||
}
|
||||
|
||||
void ng_at86rf2xx_set_max_retries(ng_at86rf2xx_t *dev, uint8_t max)
|
||||
{
|
||||
max = (max > 7) ? 7 : max;
|
||||
uint8_t tmp = ng_at86rf2xx_reg_read(dev, NG_AT86RF2XX_REG__XAH_CTRL_0);
|
||||
tmp &= ~(NG_AT86RF2XX_XAH_CTRL_0__MAX_FRAME_RETRIES);
|
||||
tmp |= (max << 4);
|
||||
ng_at86rf2xx_reg_write(dev, NG_AT86RF2XX_REG__XAH_CTRL_0, tmp);
|
||||
}
|
||||
|
||||
void ng_at86rf2xx_set_option(ng_at86rf2xx_t *dev, uint16_t option, bool state)
|
||||
{
|
||||
uint8_t tmp;
|
||||
|
@ -445,6 +445,13 @@ static int _get(ng_netdev_t *device, ng_netconf_opt_t opt,
|
||||
}
|
||||
return sizeof(ng_netconf_enable_t);
|
||||
|
||||
case NETCONF_OPT_RETRANS:
|
||||
if (max_len < sizeof(uint8_t)) {
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
*((uint8_t *)val) = ng_at86rf2xx_get_max_retries(dev);
|
||||
return sizeof(uint8_t);
|
||||
|
||||
case NETCONF_OPT_PROMISCUOUSMODE:
|
||||
if (dev->options & NG_AT86RF2XX_OPT_PROMISCUOUS) {
|
||||
*((ng_netconf_enable_t *)val) = NETCONF_ENABLE;
|
||||
@ -577,6 +584,13 @@ static int _set(ng_netdev_t *device, ng_netconf_opt_t opt,
|
||||
((bool *)val)[0]);
|
||||
return sizeof(ng_netconf_enable_t);
|
||||
|
||||
case NETCONF_OPT_RETRANS:
|
||||
if (len > sizeof(uint8_t)) {
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
ng_at86rf2xx_set_max_retries(dev, *((uint8_t *)val));
|
||||
return sizeof(uint8_t);
|
||||
|
||||
case NETCONF_OPT_PRELOADING:
|
||||
ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_PRELOADING,
|
||||
((bool *)val)[0]);
|
||||
|
@ -72,6 +72,8 @@ typedef enum {
|
||||
* the current state */
|
||||
NETCONF_OPT_AUTOACK, /**< en/disable link layer auto ACKs or read
|
||||
* the current state */
|
||||
NETCONF_OPT_RETRANS, /**< get/set the maximum number of
|
||||
retransmissions. */
|
||||
NETCONF_OPT_PROTO, /**< get/set the protocol for the layer
|
||||
* as type ng_nettype_t. */
|
||||
NETCONF_OPT_STATE, /**< get/set the state of network devices as
|
||||
|
Loading…
Reference in New Issue
Block a user