From 44f2bade6ea5b1b7cf24683a7647a02e63d7639c Mon Sep 17 00:00:00 2001 From: Terry Moore Date: Mon, 22 Feb 2021 07:57:57 -0500 Subject: [PATCH] Fix #606: don't use defined() in macros --- src/lmic/lmic_config_preconditions.h | 83 ++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 12 deletions(-) diff --git a/src/lmic/lmic_config_preconditions.h b/src/lmic/lmic_config_preconditions.h index 875d71b4..f9fc752c 100644 --- a/src/lmic/lmic_config_preconditions.h +++ b/src/lmic/lmic_config_preconditions.h @@ -117,6 +117,62 @@ Revision history: (1 << LMIC_REGION_in866) | \ 0) +// LMIC_CFG_*_ENA -- either 1 or 0 based on whether that region +// is enabled. +#if defined(CFG_eu868) +# define LMIC_CFG_eu868_ENA 1 +#else +# define LMIC_CFG_eu868_ENA 0 +#endif + +#if defined(CFG_us915) +# define LMIC_CFG_us915_ENA 1 +#else +# define LMIC_CFG_us915_ENA 0 +#endif + +#if defined(CFG_cn783) +# define LMIC_CFG_cn783_ENA 1 +#else +# define LMIC_CFG_cn783_ENA 0 +#endif + +#if defined(CFG_eu433) +# define LMIC_CFG_eu433_ENA 1 +#else +# define LMIC_CFG_eu433_ENA 0 +#endif + +#if defined(CFG_au915) +# define LMIC_CFG_au915_ENA 1 +#else +# define LMIC_CFG_au915_ENA 0 +#endif + +#if defined(CFG_cn490) +# define LMIC_CFG_cn490_ENA 1 +#else +# define LMIC_CFG_cn490_ENA 0 +#endif + +#if defined(CFG_as923) +# define LMIC_CFG_as923_ENA 1 +#else +# define LMIC_CFG_as923_ENA 0 +#endif + +#if defined(CFG_kr920) +# define LMIC_CFG_kr920_ENA 1 +#else +# define LMIC_CFG_kr920_ENA 0 +#endif + +#if defined(CFG_in866) +# define LMIC_CFG_in866_ENA 1 +#else +# define LMIC_CFG_in866_ENA 0 +#endif + // // Our input is a -D of one of CFG_eu868, CFG_us915, CFG_as923, CFG_au915, CFG_in866 // More will be added in the the future. So at this point we create CFG_region with @@ -129,16 +185,16 @@ Revision history: // TODO(tmm@mcci.com) consider moving this block to a central file as it's not // user-editable. // -# define CFG_LMIC_REGION_MASK \ - ((defined(CFG_eu868) << LMIC_REGION_eu868) | \ - (defined(CFG_us915) << LMIC_REGION_us915) | \ - (defined(CFG_cn783) << LMIC_REGION_cn783) | \ - (defined(CFG_eu433) << LMIC_REGION_eu433) | \ - (defined(CFG_au915) << LMIC_REGION_au915) | \ - (defined(CFG_cn490) << LMIC_REGION_cn490) | \ - (defined(CFG_as923) << LMIC_REGION_as923) | \ - (defined(CFG_kr920) << LMIC_REGION_kr920) | \ - (defined(CFG_in866) << LMIC_REGION_in866) | \ +# define CFG_LMIC_REGION_MASK \ + ((LMIC_CFG_eu868_ENA) << LMIC_REGION_eu868) | \ + (LMIC_CFG_us915_ENA) << LMIC_REGION_us915) | \ + (LMIC_CFG_cn783_ENA) << LMIC_REGION_cn783) | \ + (LMIC_CFG_eu433_ENA) << LMIC_REGION_eu433) | \ + (LMIC_CFG_au915_ENA) << LMIC_REGION_au915) | \ + (LMIC_CFG_cn490_ENA) << LMIC_REGION_cn490) | \ + (LMIC_CFG_as923_ENA) << LMIC_REGION_as923) | \ + (LMIC_CFG_kr920_ENA) << LMIC_REGION_kr920) | \ + (LMIC_CFG_in866_ENA) << LMIC_REGION_in866) | \ 0) // the selected region. @@ -171,7 +227,7 @@ Revision history: #endif // a bitmask of EU-like regions -- these are regions which have up to 16 -// channels indidually programmable via downloink. +// channels individually programmable via downlink. // // TODO(tmm@mcci.com) consider moving this block to a central file as it's not // user-editable. @@ -210,11 +266,14 @@ Revision history: // TODO(tmm@mcci.com) consider moving this block to a central file as it's not // user-editable. // + +/// \brief true if configured region is EU-like, false otherwise. #define CFG_LMIC_EU_like (!!(CFG_LMIC_REGION_MASK & CFG_LMIC_EU_like_MASK)) +/// \brief true if configured region is US-like, false otherwise. #define CFG_LMIC_US_like (!!(CFG_LMIC_REGION_MASK & CFG_LMIC_US_like_MASK)) // -// The supported LMIC LoRaWAAN spec versions. These need to be numerically ordered, +// The supported LMIC LoRaWAN spec versions. These need to be numerically ordered, // so that we can (for example) compare // // LMIC_LORAWAN_SPEC_VERSION < LMIC_LORAWAN_SPEC_VERSION_1_0_3.