From d69256c90b3dd995f045d26732915b7fc9f924dc Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Tue, 13 Jul 2021 21:13:34 +0200 Subject: [PATCH 1/6] Revert "tests/driver_sx127x: use uint8_t for NETOPT_RX_SYMBOL_TIMEOUT" This reverts commit 5ef4c0a778ab7d4f625d63fdafe5e8347bfe479d. --- tests/driver_sx127x/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/driver_sx127x/main.c b/tests/driver_sx127x/main.c index 34402065b0..4fe1257c04 100644 --- a/tests/driver_sx127x/main.c +++ b/tests/driver_sx127x/main.c @@ -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) { From f7dd532dd3ebbbc4ddc445db2e8dfe4e6618bea9 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Tue, 13 Jul 2021 21:14:03 +0200 Subject: [PATCH 2/6] Revert "net/gnrc_lorawan: use uint8_t for NETOPT_RX_SYMBOL_TIMEOUT" This reverts commit e791a86971785babb9a7750a4be01cce760a7527. --- sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c b/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c index 53e33b7884..3a3cfa1ff8 100644 --- a/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c +++ b/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c @@ -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)); } From 6ffecfe8d664e7c9487737181e850455e2df420c Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Tue, 13 Jul 2021 21:14:19 +0200 Subject: [PATCH 3/6] Revert "pkg/semtech-loramac: use uint8_t for NETOPT_RX_SYMBOL_TIMEOUT" This reverts commit 79e194783c1b34d6249dbb56a888e4beac162255. --- pkg/semtech-loramac/contrib/semtech_loramac_radio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/semtech-loramac/contrib/semtech_loramac_radio.c b/pkg/semtech-loramac/contrib/semtech_loramac_radio.c index 3303daa492..ea05dcb2ac 100644 --- a/pkg/semtech-loramac/contrib/semtech_loramac_radio.c +++ b/pkg/semtech-loramac/contrib/semtech_loramac_radio.c @@ -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)); } From c6da77a4546f672a14302bbc5fec9cc213d90222 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Tue, 13 Jul 2021 21:14:28 +0200 Subject: [PATCH 4/6] Revert "drivers/sx127x: fix size of rx symbol timeout" This reverts commit 26ead7b5be88453b6904c5551591ecdfb8ba4688. --- drivers/include/sx127x.h | 2 +- drivers/sx127x/sx127x_getset.c | 6 +++--- drivers/sx127x/sx127x_netdev.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/include/sx127x.h b/drivers/include/sx127x.h index 386effcf67..bddce07705 100644 --- a/drivers/include/sx127x.h +++ b/drivers/include/sx127x.h @@ -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 diff --git a/drivers/sx127x/sx127x_getset.c b/drivers/sx127x/sx127x_getset.c index cc781802a5..9ec4bcd8c3 100644 --- a/drivers/sx127x/sx127x_getset.c +++ b/drivers/sx127x/sx127x_getset.c @@ -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) diff --git a/drivers/sx127x/sx127x_netdev.c b/drivers/sx127x/sx127x_netdev.c index 329ca0f70d..c4d9667f24 100644 --- a/drivers/sx127x/sx127x_netdev.c +++ b/drivers/sx127x/sx127x_netdev.c @@ -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: From 986fe58704d1d98890b547b224c32bab31f89bde Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Tue, 13 Jul 2021 21:21:46 +0200 Subject: [PATCH 5/6] netopt: fix NETOPT_RX_SYMBOL_TIMEOUT documentation --- sys/include/net/netopt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/include/net/netopt.h b/sys/include/net/netopt.h index 0089d9c5e8..da1fa1e5f4 100644 --- a/sys/include/net/netopt.h +++ b/sys/include/net/netopt.h @@ -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, From b299299ad3f10e45f202d8520fd19d8eab3c9ddc Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Wed, 14 Jul 2021 12:02:16 +0200 Subject: [PATCH 6/6] drivers/sx126x: fix NETOPT_RX_SYMBOL_TIMEOUT --- drivers/include/sx126x.h | 2 +- drivers/sx126x/sx126x_netdev.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/include/sx126x.h b/drivers/include/sx126x.h index 78d0eba604..127c0f10bb 100644 --- a/drivers/include/sx126x.h +++ b/drivers/include/sx126x.h @@ -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 */ }; diff --git a/drivers/sx126x/sx126x_netdev.c b/drivers/sx126x/sx126x_netdev.c index bf0ca8e764..3fee95d5da 100644 --- a/drivers/sx126x/sx126x_netdev.c +++ b/drivers/sx126x/sx126x_netdev.c @@ -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));