From d5086ecf6070776310c37fbb3cf2b7b28bf1d071 Mon Sep 17 00:00:00 2001 From: Akshai M Date: Mon, 23 Nov 2020 18:12:31 +0100 Subject: [PATCH] net/lorawan : Move 'LORAMAC_DEFAULT_RX2_DR' to 'CONFIG_' Added symbols 'CONFIG_LORAMAC_DEFAULT_RX2_DR_XX' to define choice in Kconfig --- drivers/rn2xx3/rn2xx3.c | 2 +- examples/gnrc_lorawan/Makefile | 2 +- sys/include/net/loramac.h | 40 +++++++++++++++++-- .../gnrc/link_layer/lorawan/gnrc_lorawan.c | 2 +- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/drivers/rn2xx3/rn2xx3.c b/drivers/rn2xx3/rn2xx3.c index 665284710f..1ef41229f9 100644 --- a/drivers/rn2xx3/rn2xx3.c +++ b/drivers/rn2xx3/rn2xx3.c @@ -258,7 +258,7 @@ int rn2xx3_mac_init(rn2xx3_t *dev) rn2xx3_mac_set_linkchk_interval(dev, CONFIG_LORAMAC_DEFAULT_LINKCHK); rn2xx3_mac_set_rx1_delay(dev, CONFIG_LORAMAC_DEFAULT_RX1_DELAY); rn2xx3_mac_set_ar(dev, IS_ACTIVE(CONFIG_RN2XX3_DEFAULT_AR)); - rn2xx3_mac_set_rx2_dr(dev, LORAMAC_DEFAULT_RX2_DR); + rn2xx3_mac_set_rx2_dr(dev, CONFIG_LORAMAC_DEFAULT_RX2_DR); rn2xx3_mac_set_rx2_freq(dev, LORAMAC_DEFAULT_RX2_FREQ); return RN2XX3_OK; diff --git a/examples/gnrc_lorawan/Makefile b/examples/gnrc_lorawan/Makefile index 98d05a671e..953b698233 100644 --- a/examples/gnrc_lorawan/Makefile +++ b/examples/gnrc_lorawan/Makefile @@ -35,7 +35,7 @@ CFLAGS += -DCONFIG_LORAMAC_DEV_EUI_DEFAULT=\"CCCCCCCCCCCCCCCC\" #CFLAGS += -DCONFIG_LORAMAC_DEV_ADDR_DEFAULT=\"00000000\" #CFLAGS += -DCONFIG_LORAMAC_NWK_SKEY_DEFAULT=\"00000000000000000000000000000000\" #CFLAGS += -DCONFIG_LORAMAC_APP_SKEY_DEFAULT=\"00000000000000000000000000000000\" -#CFLAGS += -DLORAMAC_DEFAULT_RX2_DR=LORAMAC_DR_3 +#CFLAGS += -DCONFIG_LORAMAC_DEFAULT_RX2_DR=LORAMAC_DR_3 # Comment/uncomment as necessary CFLAGS += -DLORAMAC_DEFAULT_JOIN_PROCEDURE=LORAMAC_JOIN_OTAA diff --git a/sys/include/net/loramac.h b/sys/include/net/loramac.h index 8a4e0f71ec..256a31d1a4 100644 --- a/sys/include/net/loramac.h +++ b/sys/include/net/loramac.h @@ -294,11 +294,45 @@ extern "C" { /** * @brief Default second RX window datarate index */ -#ifndef LORAMAC_DEFAULT_RX2_DR +#if IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_0) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_0) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_1) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_1) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_2) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_2) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_3) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_3) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_4) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_4) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_5) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_5) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_6) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_6) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_7) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_7) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_8) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_8) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_9) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_9) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_10) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_10) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_11) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_11) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_12) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_12) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_13) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_13) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_14) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_14) +#elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_15) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_15) +#endif + +#ifndef CONFIG_LORAMAC_DEFAULT_RX2_DR #if IS_ACTIVE(CONFIG_LORAMAC_REGION_EU_868) -#define LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_0) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_0) #elif IS_ACTIVE(CONFIG_LORAMAC_REGION_IN_865) -#define LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_2) +#define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_2) #endif #endif diff --git a/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c b/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c index 0aef6041be..19f99a6e0c 100644 --- a/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c +++ b/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c @@ -107,7 +107,7 @@ void gnrc_lorawan_reset(gnrc_lorawan_t *mac) dev->driver->set(dev, NETOPT_RX_TIMEOUT, &rx_timeout, sizeof(rx_timeout)); - gnrc_lorawan_set_rx2_dr(mac, LORAMAC_DEFAULT_RX2_DR); + gnrc_lorawan_set_rx2_dr(mac, CONFIG_LORAMAC_DEFAULT_RX2_DR); mac->toa = 0; gnrc_lorawan_mcps_reset(mac);