From 349d20349db748e2fcd6a1e5721aa88b13af5f0c Mon Sep 17 00:00:00 2001 From: Akshai M Date: Tue, 8 Sep 2020 19:01:04 +0530 Subject: [PATCH] net/lora : Move 'LORA_BW_DEFAULT' to 'CONFIG_' Added choices and moved 'LORA_BW_DEFAULT" to 'CONFIG_' namespace --- drivers/sx127x/sx127x.c | 2 +- sys/include/net/lora.h | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/sx127x/sx127x.c b/drivers/sx127x/sx127x.c index 7aec999207..7bfe92eab7 100644 --- a/drivers/sx127x/sx127x.c +++ b/drivers/sx127x/sx127x.c @@ -171,7 +171,7 @@ void sx127x_init_radio_settings(sx127x_t *dev) sx127x_set_channel(dev, SX127X_CHANNEL_DEFAULT); sx127x_set_modem(dev, SX127X_MODEM_DEFAULT); sx127x_set_tx_power(dev, SX127X_RADIO_TX_POWER); - sx127x_set_bandwidth(dev, LORA_BW_DEFAULT); + sx127x_set_bandwidth(dev, CONFIG_LORA_BW_DEFAULT); sx127x_set_spreading_factor(dev, LORA_SF_DEFAULT); sx127x_set_coding_rate(dev, LORA_CR_DEFAULT); sx127x_set_crc(dev, LORA_PAYLOAD_CRC_ON_DEFAULT); diff --git a/sys/include/net/lora.h b/sys/include/net/lora.h index 39bfc8923e..2b51fdb156 100644 --- a/sys/include/net/lora.h +++ b/sys/include/net/lora.h @@ -24,6 +24,8 @@ #include #include +#include "kernel_defines.h" + #ifdef __cplusplus extern "C" { #endif @@ -48,9 +50,17 @@ extern "C" { #define CONFIG_LORA_SYMBOL_TIMEOUT_DEFAULT (10U) #endif +#if IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_125) +#define CONFIG_LORA_BW_DEFAULT (LORA_BW_125_KHZ) +#elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_250) +#define CONFIG_LORA_BW_DEFAULT (LORA_BW_250_KHZ) +#elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_500) +#define CONFIG_LORA_BW_DEFAULT (LORA_BW_500_KHZ) +#endif + /** @brief Set default bandwidth to 125kHz */ -#ifndef LORA_BW_DEFAULT -#define LORA_BW_DEFAULT (LORA_BW_125_KHZ) +#ifndef CONFIG_LORA_BW_DEFAULT +#define CONFIG_LORA_BW_DEFAULT (LORA_BW_125_KHZ) #endif /** @brief Set default spreading factor to 12 */