Skip to content

Commit

Permalink
Expand README on region support, rename region variables to have LORA…
Browse files Browse the repository at this point in the history
…MAC_ prefix
  • Loading branch information
dmeehan1968 committed Oct 15, 2022
1 parent 35dbe82 commit 0a6d732
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
23 changes: 22 additions & 1 deletion as-lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ standard `LORAMAC_` prefix is applied to all options to aid interoperability wit
- LORAMAC_RADIO:STRING Name of the radio driver, defaults to sx1272
- LORAMAC_USE_RADIO_DEBUG:BOOL Enable Radio Debug GPIO's (default OFF)

## Region support

Note that unlike the `src` build, the supported regions are not configured as CMake cache options. This is to
support easier override when building multiple regions (where cache FORCE would be needed to override which).

At least one region must be enabled, and there are no regions enabled by default. A fatal CMake configure error
will be generated if no regions are supported.

- LORAMAC_REGION_EU868:BOOL Enable support for EU868
- LORAMAC_REGION_US915:BOOL Enable support for US915
- LORAMAC_REGION_CN779:BOOL Enable support for CN779
- LORAMAC_REGION_EU433:BOOL Enable support for EU433
- LORAMAC_REGION_AU915:BOOL Enable support for AU915
- LORAMAC_REGION_AS923:BOOL Enable support for AS923
- LORAMAC_REGION_CN470:BOOL Enable support for CN470
- LORAMAC_REGION_KR920:BOOL Enable support for KR920
- LORAMAC_REGION_IN865:BOOL Enable support for IN865
- LORAMAC_REGION_RU864:BOOL Enable support for RU864

## Preparation for loading and building

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

`ExternalProject_Add` is not supported at this time.

NB: If building multiple static libraries for regional variants, ensure that you set the previous passes region to OFF

```
FetchContent_Declare(
loramac
Expand All @@ -87,7 +108,7 @@ set(LORAMAC_SUFFIX -Europe)
set(REGION_EU868 ON)
add_subdirectory(loramac_SOURCE_DIR loramac${LORAMAC_SUFFIX})
set(REGION_EU868 OFF)
set(REGION_EU868 OFF) # NB: Override last pass
set(REGION_US915 ON)
set(LORAMAC_SUFFIX -US)
add_subdirectory(loramac_SOURCE_DIR loramac${LORAMAC_SUFFIX})
Expand Down
12 changes: 10 additions & 2 deletions as-lib/mac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ if (NOT TARGET ${PROJECT_NAME})
${LORAMAC_SOURCE_DIR}/mac/LoRaMacSerializer.c
${LORAMAC_SOURCE_DIR}/mac/region/Region.c
${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.c
$<$<OR:$<BOOL:${REGION_AU915}>,$<BOOL:${REGION_US915}>>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c>
$<$<OR:$<BOOL:${LORAMAC_REGION_AU915}>,$<BOOL:${LORAMAC_REGION_US915}>>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c>
)

set(ACTIVE_REGION_COUNT 0)

foreach(REGION ${LORAMAC_REGION_LIST})
if (${REGION_${REGION}})
if (${LORAMAC_REGION_${REGION}})

MATH(EXPR ACTIVE_REGION_COUNT "${ACTIVE_REGION_COUNT}+1")

target_sources(
${PROJECT_NAME}
Expand All @@ -70,6 +74,10 @@ if (NOT TARGET ${PROJECT_NAME})
endif()
endforeach()

if (${ACTIVE_REGION_COUNT} LESS 1)
message(FATAL_ERROR "No LORAMAC_REGION_xxx's specified")
endif()

target_compile_definitions(
${PROJECT_NAME}
PUBLIC
Expand Down

0 comments on commit 0a6d732

Please sign in to comment.