1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

net/gnrc_lorawan: add MIB for setting RX2 datarate

This commit is contained in:
Jose Alamos 2019-12-03 14:47:18 +01:00
parent 1e9bb7c175
commit 8999528390
5 changed files with 24 additions and 7 deletions

View File

@ -74,7 +74,8 @@ typedef enum {
*/
typedef enum {
MIB_ACTIVATION_METHOD, /**< type is activation method */
MIB_DEV_ADDR /**< type is dev addr */
MIB_DEV_ADDR, /**< type is dev addr */
MIB_RX2_DR, /**< type is rx2 DR */
} mlme_mib_type_t;
/**
@ -105,6 +106,7 @@ typedef struct {
union {
mlme_activation_t activation; /**< holds activation mechanism */
void *dev_addr; /**< pointer to the dev_addr */
uint8_t rx2_dr; /** datarate of second rx window */
};
} mlme_mib_t;

View File

@ -61,7 +61,7 @@ static inline void gnrc_lorawan_mcps_reset(gnrc_lorawan_t *mac)
mac->mcps.fcnt_down = 0;
}
static inline void _set_rx2_dr(gnrc_lorawan_t *mac, uint8_t rx2_dr)
void gnrc_lorawan_set_rx2_dr(gnrc_lorawan_t *mac, uint8_t rx2_dr)
{
mac->dl_settings &= ~GNRC_LORAWAN_DL_RX2_DR_MASK;
mac->dl_settings |= (rx2_dr << GNRC_LORAWAN_DL_RX2_DR_POS) &
@ -98,7 +98,7 @@ void gnrc_lorawan_reset(gnrc_lorawan_t *mac)
uint32_t rx_timeout = 0;
netdev_set_pass(&mac->netdev, NETOPT_RX_TIMEOUT, &rx_timeout, sizeof(rx_timeout));
_set_rx2_dr(mac, LORAMAC_DEFAULT_RX2_DR);
gnrc_lorawan_set_rx2_dr(mac, LORAMAC_DEFAULT_RX2_DR);
mac->toa = 0;
gnrc_lorawan_mcps_reset(mac);
@ -281,10 +281,6 @@ int gnrc_lorawan_netdev_set(netdev_t *dev, netopt_t opt, const void *value, size
}
switch (opt) {
case NETOPT_LORAWAN_RX2_DR:
assert(len == sizeof(uint8_t));
_set_rx2_dr(mac, *((uint8_t *) value));
break;
default:
netdev_set_pass(dev, opt, value, len);
break;

View File

@ -193,6 +193,10 @@ static void _mlme_set(gnrc_lorawan_t *mac, const mlme_request_t *mlme_request,
mlme_confirm->status = GNRC_LORAWAN_REQ_STATUS_SUCCESS;
memcpy(&mac->dev_addr, mlme_request->mib.dev_addr, sizeof(uint32_t));
break;
case MIB_RX2_DR:
mlme_confirm->status = GNRC_LORAWAN_REQ_STATUS_SUCCESS;
gnrc_lorawan_set_rx2_dr(mac, mlme_request->mib.rx2_dr);
break;
default:
break;
}

View File

@ -446,6 +446,14 @@ static inline void gnrc_lorawan_mac_release(gnrc_lorawan_t *mac)
mac->busy = false;
}
/**
* @brief Set the datarate of the second reception window
*
* @param[in] mac pointer to the MAC descriptor
* @param[in] rx2_dr datarate of RX2
*/
void gnrc_lorawan_set_rx2_dr(gnrc_lorawan_t *mac, uint8_t rx2_dr);
#ifdef __cplusplus
}
#endif

View File

@ -361,6 +361,13 @@ static int _set(gnrc_netif_t *netif, const gnrc_netapi_opt_t *opt)
case NETOPT_LINK_CHECK:
netif->lorawan.flags |= GNRC_NETIF_LORAWAN_FLAGS_LINK_CHECK;
break;
case NETOPT_LORAWAN_RX2_DR:
assert(opt->data_len == sizeof(uint8_t));
mlme_request.type = MLME_SET;
mlme_request.mib.type = MIB_RX2_DR;
mlme_request.mib.rx2_dr = *((uint8_t*) opt->data);
gnrc_lorawan_mlme_request(&netif->lorawan.mac, &mlme_request, &mlme_confirm);
break;
default:
res = netif->lorawan.mac.netdev.driver->set(&netif->lorawan.mac.netdev, opt->opt, opt->data, opt->data_len);
break;