Skip to content

Commit 0a6d732

Browse files
committed
Expand README on region support, rename region variables to have LORAMAC_ prefix
1 parent 35dbe82 commit 0a6d732

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

as-lib/README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ standard `LORAMAC_` prefix is applied to all options to aid interoperability wit
2424
- LORAMAC_RADIO:STRING Name of the radio driver, defaults to sx1272
2525
- LORAMAC_USE_RADIO_DEBUG:BOOL Enable Radio Debug GPIO's (default OFF)
2626

27+
## Region support
28+
29+
Note that unlike the `src` build, the supported regions are not configured as CMake cache options. This is to
30+
support easier override when building multiple regions (where cache FORCE would be needed to override which).
31+
32+
At least one region must be enabled, and there are no regions enabled by default. A fatal CMake configure error
33+
will be generated if no regions are supported.
34+
35+
- LORAMAC_REGION_EU868:BOOL Enable support for EU868
36+
- LORAMAC_REGION_US915:BOOL Enable support for US915
37+
- LORAMAC_REGION_CN779:BOOL Enable support for CN779
38+
- LORAMAC_REGION_EU433:BOOL Enable support for EU433
39+
- LORAMAC_REGION_AU915:BOOL Enable support for AU915
40+
- LORAMAC_REGION_AS923:BOOL Enable support for AS923
41+
- LORAMAC_REGION_CN470:BOOL Enable support for CN470
42+
- LORAMAC_REGION_KR920:BOOL Enable support for KR920
43+
- LORAMAC_REGION_IN865:BOOL Enable support for IN865
44+
- LORAMAC_REGION_RU864:BOOL Enable support for RU864
45+
2746
## Preparation for loading and building
2847

2948
You must establish your toolchain prior to your first CMake `project()` call (which triggers toolchain detection). It
@@ -69,6 +88,8 @@ FetchContent should be used to load the project at CMake configure time (rather
6988

7089
`ExternalProject_Add` is not supported at this time.
7190

91+
NB: If building multiple static libraries for regional variants, ensure that you set the previous passes region to OFF
92+
7293
```
7394
FetchContent_Declare(
7495
loramac
@@ -87,7 +108,7 @@ set(LORAMAC_SUFFIX -Europe)
87108
set(REGION_EU868 ON)
88109
add_subdirectory(loramac_SOURCE_DIR loramac${LORAMAC_SUFFIX})
89110
90-
set(REGION_EU868 OFF)
111+
set(REGION_EU868 OFF) # NB: Override last pass
91112
set(REGION_US915 ON)
92113
set(LORAMAC_SUFFIX -US)
93114
add_subdirectory(loramac_SOURCE_DIR loramac${LORAMAC_SUFFIX})

as-lib/mac/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@ if (NOT TARGET ${PROJECT_NAME})
4646
${LORAMAC_SOURCE_DIR}/mac/LoRaMacSerializer.c
4747
${LORAMAC_SOURCE_DIR}/mac/region/Region.c
4848
${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.c
49-
$<$<OR:$<BOOL:${REGION_AU915}>,$<BOOL:${REGION_US915}>>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c>
49+
$<$<OR:$<BOOL:${LORAMAC_REGION_AU915}>,$<BOOL:${LORAMAC_REGION_US915}>>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c>
5050
)
5151

52+
set(ACTIVE_REGION_COUNT 0)
53+
5254
foreach(REGION ${LORAMAC_REGION_LIST})
53-
if (${REGION_${REGION}})
55+
if (${LORAMAC_REGION_${REGION}})
56+
57+
MATH(EXPR ACTIVE_REGION_COUNT "${ACTIVE_REGION_COUNT}+1")
5458

5559
target_sources(
5660
${PROJECT_NAME}
@@ -70,6 +74,10 @@ if (NOT TARGET ${PROJECT_NAME})
7074
endif()
7175
endforeach()
7276

77+
if (${ACTIVE_REGION_COUNT} LESS 1)
78+
message(FATAL_ERROR "No LORAMAC_REGION_xxx's specified")
79+
endif()
80+
7381
target_compile_definitions(
7482
${PROJECT_NAME}
7583
PUBLIC

0 commit comments

Comments
 (0)