Skip to content

Commit

Permalink
Merge pull request #16640 from jia200x/pr/revert/rx_symbol
Browse files Browse the repository at this point in the history
net/lorawan: Revert #16604 and fix NETOPT_RX_SYMBOL_TIMEOUT documentation
  • Loading branch information
leandrolanzieri committed Jul 14, 2021
2 parents 9c8b62a + b299299 commit 9ca9efd
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion drivers/include/sx126x.h
Expand Up @@ -107,7 +107,7 @@ struct sx126x {
sx126x_pkt_params_lora_t pkt_params; /**< Lora packet parameters */
sx126x_mod_params_lora_t mod_params; /**< Lora modulation parameters */
uint32_t channel; /**< Current channel frequency (in Hz) */
uint8_t rx_timeout; /**< Rx Timeout in terms of symbols */
uint16_t rx_timeout; /**< Rx Timeout in terms of symbols */
bool radio_sleep; /**< Radio sleep status */
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/include/sx127x.h
Expand Up @@ -637,7 +637,7 @@ void sx127x_set_preamble_length(sx127x_t *dev, uint16_t preamble);
* @param[in] dev The sx127x device descriptor
* @param[in] timeout The LoRa symbol timeout
*/
void sx127x_set_symbol_timeout(sx127x_t *dev, uint8_t timeout);
void sx127x_set_symbol_timeout(sx127x_t *dev, uint16_t timeout);

/**
* @brief Sets the SX127X RX timeout
Expand Down
6 changes: 3 additions & 3 deletions drivers/sx126x/sx126x_netdev.c
Expand Up @@ -425,9 +425,9 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
return sizeof(netopt_enable_t);

case NETOPT_RX_SYMBOL_TIMEOUT:
assert(len <= sizeof(uint8_t));
dev->rx_timeout = *(const uint8_t *)val;
return sizeof(uint8_t);
assert(len <= sizeof(uint16_t));
dev->rx_timeout = *(const uint16_t *)val;
return sizeof(uint16_t);

case NETOPT_TX_POWER:
assert(len <= sizeof(int16_t));
Expand Down
6 changes: 3 additions & 3 deletions drivers/sx127x/sx127x_getset.c
Expand Up @@ -866,16 +866,16 @@ void sx127x_set_tx_timeout(sx127x_t *dev, uint32_t timeout)
dev->settings.lora.tx_timeout = timeout;
}

void sx127x_set_symbol_timeout(sx127x_t *dev, uint8_t timeout)
void sx127x_set_symbol_timeout(sx127x_t *dev, uint16_t timeout)
{
DEBUG("[sx127x] Set symbol timeout: %d\n", timeout);

uint8_t config2_reg = sx127x_reg_read(dev, SX127X_REG_LR_MODEMCONFIG2);

config2_reg &= SX127X_RF_LORA_MODEMCONFIG2_SYMBTIMEOUTMSB_MASK;
config2_reg |= timeout & ~SX127X_RF_LORA_MODEMCONFIG2_SYMBTIMEOUTMSB_MASK;
config2_reg |= (timeout >> 8) & ~SX127X_RF_LORA_MODEMCONFIG2_SYMBTIMEOUTMSB_MASK;
sx127x_reg_write(dev, SX127X_REG_LR_MODEMCONFIG2, config2_reg);
sx127x_reg_write(dev, SX127X_REG_LR_SYMBTIMEOUTLSB, timeout);
sx127x_reg_write(dev, SX127X_REG_LR_SYMBTIMEOUTLSB, timeout & 0xFF);
}

bool sx127x_get_iq_invert(const sx127x_t *dev)
Expand Down
4 changes: 2 additions & 2 deletions drivers/sx127x/sx127x_netdev.c
Expand Up @@ -444,8 +444,8 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
return sizeof(netopt_enable_t);

case NETOPT_RX_SYMBOL_TIMEOUT:
assert(len <= sizeof(uint8_t));
sx127x_set_symbol_timeout(dev, *((const uint8_t *)val));
assert(len <= sizeof(uint16_t));
sx127x_set_symbol_timeout(dev, *((const uint16_t *)val));
return sizeof(uint16_t);

case NETOPT_RX_TIMEOUT:
Expand Down
5 changes: 1 addition & 4 deletions pkg/semtech-loramac/contrib/semtech_loramac_radio.c
Expand Up @@ -127,10 +127,7 @@ void SX127XSetRxConfig(RadioModems_t modem, uint32_t bandwidth,
loramac_netdev_ptr->driver->set(loramac_netdev_ptr, NETOPT_CHANNEL_HOP_PERIOD, &hopPeriod, sizeof(uint8_t));
netopt_enable_t iq_inverted = (iqInverted) ? NETOPT_ENABLE : NETOPT_DISABLE;
loramac_netdev_ptr->driver->set(loramac_netdev_ptr, NETOPT_IQ_INVERT, &iq_inverted, sizeof(netopt_enable_t));
assert(symbTimeout <= UINT8_MAX);
uint8_t symbol_timeout = symbTimeout;
loramac_netdev_ptr->driver->set(loramac_netdev_ptr, NETOPT_RX_SYMBOL_TIMEOUT,
&symbol_timeout, sizeof(symbol_timeout));
loramac_netdev_ptr->driver->set(loramac_netdev_ptr, NETOPT_RX_SYMBOL_TIMEOUT, &symbTimeout, sizeof(uint16_t));
netopt_enable_t single_rx = rxContinuous ? NETOPT_DISABLE : NETOPT_ENABLE;
loramac_netdev_ptr->driver->set(loramac_netdev_ptr, NETOPT_SINGLE_RECEIVE, &single_rx, sizeof(netopt_enable_t));
}
Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/netopt.h
Expand Up @@ -748,7 +748,7 @@ typedef enum {
NETOPT_RANDOM,

/**
* @brief (uint8_t) Get or set the number of PHY symbols before assuming there's no data
* @brief (uint16_t) Get or set the number of PHY symbols before assuming there's no data
*/
NETOPT_RX_SYMBOL_TIMEOUT,

Expand Down
2 changes: 1 addition & 1 deletion sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c
Expand Up @@ -129,7 +129,7 @@ static void _config_radio(gnrc_lorawan_t *mac, uint32_t channel_freq,
/* Switch to single listen mode */
const netopt_enable_t single = true;
dev->driver->set(dev, NETOPT_SINGLE_RECEIVE, &single, sizeof(single));
const uint8_t timeout = CONFIG_GNRC_LORAWAN_MIN_SYMBOLS_TIMEOUT;
const uint16_t timeout = CONFIG_GNRC_LORAWAN_MIN_SYMBOLS_TIMEOUT;
dev->driver->set(dev, NETOPT_RX_SYMBOL_TIMEOUT, &timeout,
sizeof(timeout));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/driver_sx127x/main.c
Expand Up @@ -359,7 +359,7 @@ int rx_timeout_cmd(int argc, char **argv)
}

netdev_t *netdev = &sx127x.netdev;
uint8_t rx_timeout;
uint16_t rx_timeout;

if (strstr(argv[1], "set") != NULL) {
if (argc < 3) {
Expand Down

0 comments on commit 9ca9efd

Please sign in to comment.