From aaaf457e8ec7265d31ba3acc8f57a7d27a43030d Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 14:57:56 +0100 Subject: [PATCH 01/31] Create directory for CMakeLists and add stub README --- as-lib/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 as-lib/README.md diff --git a/as-lib/README.md b/as-lib/README.md new file mode 100644 index 000000000..7bea81e70 --- /dev/null +++ b/as-lib/README.md @@ -0,0 +1,5 @@ +# LoRaMac-node 'as-lib' + +**WIP** + +This directory is provided to allow LoRaMac-node to be built as a static library for inclusion in other projects. \ No newline at end of file From 580737a03af1f5a8fe0b58dcb2a8bbc3545bf56e Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 15:20:34 +0100 Subject: [PATCH 02/31] Allow CMake subdirectory to be switched based on LORAMAC_AS_LIB option --- CMakeLists.txt | 8 +++++++- as-lib/CMakeLists.txt | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 as-lib/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 312688202..81971e4b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,4 +18,10 @@ project(loramac-node) cmake_minimum_required(VERSION 3.6) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) +option(LORAMAC_AS_LIB "If enabled, will configure LoRaMac-node to be built as a static library, otherwise will build example projects" OFF) + +if (LORAMAC_AS_LIB) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/as-lib) +else() + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) +endif() diff --git a/as-lib/CMakeLists.txt b/as-lib/CMakeLists.txt new file mode 100644 index 000000000..afa427323 --- /dev/null +++ b/as-lib/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.23) + + From e0c0504a06d7abe6b247e02a15486186758d424a Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 15:30:14 +0100 Subject: [PATCH 03/31] Add subdirectories to mirror src directory organisation --- as-lib/CMakeLists.txt | 6 +++++- as-lib/board/CMakeLists.txt | 1 + as-lib/mac/CMakeLists.txt | 1 + as-lib/peripheral/CMakeLists.txt | 1 + as-lib/radio/CMakeLists.txt | 1 + as-lib/system/CMakeLists.txt | 1 + 6 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 as-lib/board/CMakeLists.txt create mode 100644 as-lib/mac/CMakeLists.txt create mode 100644 as-lib/peripheral/CMakeLists.txt create mode 100644 as-lib/radio/CMakeLists.txt create mode 100644 as-lib/system/CMakeLists.txt diff --git a/as-lib/CMakeLists.txt b/as-lib/CMakeLists.txt index afa427323..909598b18 100644 --- a/as-lib/CMakeLists.txt +++ b/as-lib/CMakeLists.txt @@ -1,3 +1,7 @@ cmake_minimum_required(VERSION 3.23) - +add_subdirectory(board) +add_subdirectory(system) +add_subdirectory(radio) +add_subdirectory(peripheral) +add_subdirectory(mac) diff --git a/as-lib/board/CMakeLists.txt b/as-lib/board/CMakeLists.txt new file mode 100644 index 000000000..ce7a746c7 --- /dev/null +++ b/as-lib/board/CMakeLists.txt @@ -0,0 +1 @@ +cmake_minimum_required(VERSION 3.23) \ No newline at end of file diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt new file mode 100644 index 000000000..ce7a746c7 --- /dev/null +++ b/as-lib/mac/CMakeLists.txt @@ -0,0 +1 @@ +cmake_minimum_required(VERSION 3.23) \ No newline at end of file diff --git a/as-lib/peripheral/CMakeLists.txt b/as-lib/peripheral/CMakeLists.txt new file mode 100644 index 000000000..ce7a746c7 --- /dev/null +++ b/as-lib/peripheral/CMakeLists.txt @@ -0,0 +1 @@ +cmake_minimum_required(VERSION 3.23) \ No newline at end of file diff --git a/as-lib/radio/CMakeLists.txt b/as-lib/radio/CMakeLists.txt new file mode 100644 index 000000000..ce7a746c7 --- /dev/null +++ b/as-lib/radio/CMakeLists.txt @@ -0,0 +1 @@ +cmake_minimum_required(VERSION 3.23) \ No newline at end of file diff --git a/as-lib/system/CMakeLists.txt b/as-lib/system/CMakeLists.txt new file mode 100644 index 000000000..ce7a746c7 --- /dev/null +++ b/as-lib/system/CMakeLists.txt @@ -0,0 +1 @@ +cmake_minimum_required(VERSION 3.23) \ No newline at end of file From ccba4fdaf9aa7b84aa4467ae88eb4910475a6846 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 15:39:57 +0100 Subject: [PATCH 04/31] Add board sources to board target --- as-lib/CMakeLists.txt | 2 ++ as-lib/board/CMakeLists.txt | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/as-lib/CMakeLists.txt b/as-lib/CMakeLists.txt index 909598b18..d250c0cab 100644 --- a/as-lib/CMakeLists.txt +++ b/as-lib/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.23) +cmake_path(SET LORAMAC_SOURCE_DIR NORMALIZE ${CMAKE_CURRENT_SOURCE_DIR}/../src) + add_subdirectory(board) add_subdirectory(system) add_subdirectory(radio) diff --git a/as-lib/board/CMakeLists.txt b/as-lib/board/CMakeLists.txt index ce7a746c7..862808958 100644 --- a/as-lib/board/CMakeLists.txt +++ b/as-lib/board/CMakeLists.txt @@ -1 +1,35 @@ -cmake_minimum_required(VERSION 3.23) \ No newline at end of file +cmake_minimum_required(VERSION 3.23) + +project(loramac-board C) + +if (NOT TARGET ${PROJECT_NAME}) + add_library(${PROJECT_NAME} STATIC) + target_sources( + ${PROJECT_NAME} + + PUBLIC + ${LORAMAC_SOURCE_DIR}/boards/adc-board.h + ${LORAMAC_SOURCE_DIR}/boards/board.h + ${LORAMAC_SOURCE_DIR}/boards/delay-board.h + ${LORAMAC_SOURCE_DIR}/boards/display-board.h + ${LORAMAC_SOURCE_DIR}/boards/eeprom-board.h + ${LORAMAC_SOURCE_DIR}/boards/gpio-board.h + ${LORAMAC_SOURCE_DIR}/boards/gps-board.h + ${LORAMAC_SOURCE_DIR}/boards/i2c-board.h + ${LORAMAC_SOURCE_DIR}/boards/lpm-board.h + ${LORAMAC_SOURCE_DIR}/boards/lr1110-board.h + ${LORAMAC_SOURCE_DIR}/boards/pinName-board.h + ${LORAMAC_SOURCE_DIR}/boards/pinName-ioe.h + ${LORAMAC_SOURCE_DIR}/boards/rtc-board.h + ${LORAMAC_SOURCE_DIR}/boards/sx126x-board.h + ${LORAMAC_SOURCE_DIR}/boards/sx1272-board.h + ${LORAMAC_SOURCE_DIR}/boards/sx1276-board.h + ${LORAMAC_SOURCE_DIR}/boards/uart-board.h + ${LORAMAC_SOURCE_DIR}/boards/uart-usb-board.h + ${LORAMAC_SOURCE_DIR}/boards/utilities.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/boards/mcu/utilities.c + ) + target_include_directories(${PROJECT_NAME} PUBLIC ${LORAMAC_SOURCE_DIR}/boards) +endif() From 9bad232a22b234c0373995a54a2bdad00f00518b Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 15:42:27 +0100 Subject: [PATCH 05/31] Add system sources to system target --- as-lib/system/CMakeLists.txt | 50 +++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/as-lib/system/CMakeLists.txt b/as-lib/system/CMakeLists.txt index ce7a746c7..f882c6e0e 100644 --- a/as-lib/system/CMakeLists.txt +++ b/as-lib/system/CMakeLists.txt @@ -1 +1,49 @@ -cmake_minimum_required(VERSION 3.23) \ No newline at end of file +cmake_minimum_required(VERSION 3.23) + +project(loramac-system C) + +if (NOT TARGET ${PROJECT_NAME}) + + add_library(${PROJECT_NAME} STATIC) + + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/system/adc.h + ${LORAMAC_SOURCE_DIR}/system/delay.h + ${LORAMAC_SOURCE_DIR}/system/fifo.h + ${LORAMAC_SOURCE_DIR}/system/gpio.h + ${LORAMAC_SOURCE_DIR}/system/gps.h + ${LORAMAC_SOURCE_DIR}/system/i2c.h + ${LORAMAC_SOURCE_DIR}/system/nvmm.h + ${LORAMAC_SOURCE_DIR}/system/serial.h + ${LORAMAC_SOURCE_DIR}/system/spi.h + ${LORAMAC_SOURCE_DIR}/system/systime.h + ${LORAMAC_SOURCE_DIR}/system/timer.h + ${LORAMAC_SOURCE_DIR}/system/uart.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/system/adc.c + ${LORAMAC_SOURCE_DIR}/system/delay.c + ${LORAMAC_SOURCE_DIR}/system/fifo.c + ${LORAMAC_SOURCE_DIR}/system/gpio.c + ${LORAMAC_SOURCE_DIR}/system/gps.c + ${LORAMAC_SOURCE_DIR}/system/i2c.c + ${LORAMAC_SOURCE_DIR}/system/nvmm.c + ${LORAMAC_SOURCE_DIR}/system/systime.c + ${LORAMAC_SOURCE_DIR}/system/timer.c + ${LORAMAC_SOURCE_DIR}/system/uart.c + ) + + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/system + ) + + target_link_libraries( + ${PROJECT_NAME} + PUBLIC + loramac-boards + ) +endif() From a176e3234c0aa3fc416639039f3de84e4ebece6b Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 15:43:02 +0100 Subject: [PATCH 06/31] Improve formatting --- as-lib/board/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/as-lib/board/CMakeLists.txt b/as-lib/board/CMakeLists.txt index 862808958..8588679c0 100644 --- a/as-lib/board/CMakeLists.txt +++ b/as-lib/board/CMakeLists.txt @@ -3,7 +3,9 @@ cmake_minimum_required(VERSION 3.23) project(loramac-board C) if (NOT TARGET ${PROJECT_NAME}) + add_library(${PROJECT_NAME} STATIC) + target_sources( ${PROJECT_NAME} @@ -31,5 +33,11 @@ if (NOT TARGET ${PROJECT_NAME}) PRIVATE ${LORAMAC_SOURCE_DIR}/boards/mcu/utilities.c ) - target_include_directories(${PROJECT_NAME} PUBLIC ${LORAMAC_SOURCE_DIR}/boards) + + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/boards + ) + endif() From 045328e8c9927afffa6675de1d00f4a0ac21edd1 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 15:53:23 +0100 Subject: [PATCH 07/31] Add radio sources to radio target --- as-lib/radio/CMakeLists.txt | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/as-lib/radio/CMakeLists.txt b/as-lib/radio/CMakeLists.txt index ce7a746c7..07120b09b 100644 --- a/as-lib/radio/CMakeLists.txt +++ b/as-lib/radio/CMakeLists.txt @@ -1 +1,33 @@ -cmake_minimum_required(VERSION 3.23) \ No newline at end of file +cmake_minimum_required(VERSION 3.23) + +project(loramac-radio C) + +if (NOT TARGET ${PROJECT_NAME}) + + add_library(${PROJECT_NAME} STATIC) + + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/radio.h + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276.h + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276Regs-Fsk.h + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276Regs-LoRa.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276.c + ) + + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio + ) + + target_link_libraries( + ${PROJECT_NAME} + PUBLIC + loramac-system + ) + +endif() From 2589f94d85aee028618bc0857178ef2368f97604 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 15:53:38 +0100 Subject: [PATCH 08/31] Add peripheral sources to peripheral target --- as-lib/peripheral/CMakeLists.txt | 46 +++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/as-lib/peripheral/CMakeLists.txt b/as-lib/peripheral/CMakeLists.txt index ce7a746c7..9a0473a88 100644 --- a/as-lib/peripheral/CMakeLists.txt +++ b/as-lib/peripheral/CMakeLists.txt @@ -1 +1,45 @@ -cmake_minimum_required(VERSION 3.23) \ No newline at end of file +cmake_minimum_required(VERSION 3.23) + +project(loramac-peripheral C) + +if (NOT TARGET ${PROJECT_NAME}) + add_library(${PROJECT_NAME} STATIC) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/peripherals/gpio-ioe.h + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/aes.h + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/cmac.h + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/se-identity.h + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se-hal.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/peripherals/gpio-ioe.c + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/aes.c + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/cmac.c + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se.c + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se-hal.c + ) + + target_compile_definitions( + ${PROJECT_NAME} + PUBLIC + SOFT_SE + AES_DEC_PREKEYED + ) + + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se + ${LORAMAC_SOURCE_DIR}/mac + ) + + target_link_libraries( + ${PROJECT_NAME} + PUBLIC + loramac-board + loramac-radio + loramac-system + ) +endif() From 7f8b18ce7c937ba92dc56ad0845138eecb72fda0 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 15:53:50 +0100 Subject: [PATCH 09/31] Fix spelling of board target --- as-lib/system/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/as-lib/system/CMakeLists.txt b/as-lib/system/CMakeLists.txt index f882c6e0e..6a7f87359 100644 --- a/as-lib/system/CMakeLists.txt +++ b/as-lib/system/CMakeLists.txt @@ -44,6 +44,6 @@ if (NOT TARGET ${PROJECT_NAME}) target_link_libraries( ${PROJECT_NAME} PUBLIC - loramac-boards + loramac-board ) endif() From 02a420b4321cacc87e67e37d83601af320bb7875 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 16:50:36 +0100 Subject: [PATCH 10/31] Add mac sources to mac target --- as-lib/mac/CMakeLists.txt | 92 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt index ce7a746c7..2b253d4d7 100644 --- a/as-lib/mac/CMakeLists.txt +++ b/as-lib/mac/CMakeLists.txt @@ -1 +1,91 @@ -cmake_minimum_required(VERSION 3.23) \ No newline at end of file +cmake_minimum_required(VERSION 3.23) + +project(loramac${LORAMAC_SUFFIX} C) + +message(STATUS ${PROJECT_NAME}) + +if (NOT TARGET ${PROJECT_NAME}) + add_library(${PROJECT_NAME} STATIC) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler/LmHandler.h + ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler/LmHandlerTypes.h + ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler/packages/LmhPackage.h + ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/NvmDataMgmt.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMac.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacAdr.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacClassB.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacClassBConfig.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacClassBNvm.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacCommands.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacConfirmQueue.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacCrypto.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacCryptoNvm.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacHeaderTypes.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacMessageTypes.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacParser.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacSerializer.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacTest.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacTypes.h + ${LORAMAC_SOURCE_DIR}/mac/secure-element.h + ${LORAMAC_SOURCE_DIR}/mac/secure-element-nvm.h + ${LORAMAC_SOURCE_DIR}/mac/region/Region.h + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.h + $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionEU868.h> + $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionAS923.h> + $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionAU915.h> + $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionUS915.h> + $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.h> + + PRIVATE + ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler/LmHandler.c + ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/NvmDataMgmt.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMac.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacAdr.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacClassB.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacCommands.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacConfirmQueue.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacCrypto.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacParser.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacSerializer.c + ${LORAMAC_SOURCE_DIR}/mac/region/Region.c + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.c + $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionEU868.c> + $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionAS923.c> + $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionAU915.c> + $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionUS915.c> + + $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c> + ) + + target_compile_definitions( + ${PROJECT_NAME} + PUBLIC + $<$:REGION_EU868> + $<$:REGION_AS923> + $<$:REGION_AU915> + $<$:REGION_US915> + ACTIVE_REGION # TODO: remove from lmHandler.c? + ) + + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler + ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler/packages + ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common + ${LORAMAC_SOURCE_DIR}/mac + ${LORAMAC_SOURCE_DIR}/mac/region + ) + + target_link_libraries( + ${PROJECT_NAME} + PUBLIC + loramac-board + loramac-system + loramac-radio + loramac-peripheral + ) + +endif() \ No newline at end of file From c36dc123d809fde976c5e9d3b42a037342e5302d Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 17:28:45 +0100 Subject: [PATCH 11/31] Include region sources based on option flags --- as-lib/mac/CMakeLists.txt | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt index 2b253d4d7..632ffe513 100644 --- a/as-lib/mac/CMakeLists.txt +++ b/as-lib/mac/CMakeLists.txt @@ -5,6 +5,9 @@ project(loramac${LORAMAC_SUFFIX} C) message(STATUS ${PROJECT_NAME}) if (NOT TARGET ${PROJECT_NAME}) + + set(LORAMAC_REGION_LIST EU868 US915 CN779 EU433 AU915 AS923 CN470 KR920 IN865 RU864) + add_library(${PROJECT_NAME} STATIC) target_sources( ${PROJECT_NAME} @@ -32,10 +35,6 @@ if (NOT TARGET ${PROJECT_NAME}) ${LORAMAC_SOURCE_DIR}/mac/secure-element-nvm.h ${LORAMAC_SOURCE_DIR}/mac/region/Region.h ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.h - $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionEU868.h> - $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionAS923.h> - $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionAU915.h> - $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionUS915.h> $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.h> PRIVATE @@ -51,21 +50,33 @@ 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 - $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionEU868.c> - $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionAS923.c> - $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionAU915.c> - $<$:${LORAMAC_SOURCE_DIR}/mac/region/RegionUS915.c> - - $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c> + $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c> ) + foreach(REGION ${LORAMAC_REGION_LIST}) + if (${REGION_${REGION}}) + + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/mac/region/Region${REGION}.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/mac/region/Region${REGION}.c + ) + + target_compile_definitions( + ${PROJECT_NAME} + PUBLIC + $<$:REGION_${REGION}> + ) + + endif() + endforeach() + target_compile_definitions( ${PROJECT_NAME} PUBLIC - $<$:REGION_EU868> - $<$:REGION_AS923> - $<$:REGION_AU915> - $<$:REGION_US915> ACTIVE_REGION # TODO: remove from lmHandler.c? ) From a3e69ca9d72b9f2a81ac1ccbdc9b66235bd2b84b Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 18:28:14 +0100 Subject: [PATCH 12/31] Remove debug message --- as-lib/mac/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt index 632ffe513..ff872f579 100644 --- a/as-lib/mac/CMakeLists.txt +++ b/as-lib/mac/CMakeLists.txt @@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.23) project(loramac${LORAMAC_SUFFIX} C) -message(STATUS ${PROJECT_NAME}) - if (NOT TARGET ${PROJECT_NAME}) set(LORAMAC_REGION_LIST EU868 US915 CN779 EU433 AU915 AS923 CN470 KR920 IN865 RU864) From 5f3aa15a8bf8e2a7b9dfc0be0dccc2e1166ce4df Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 18:28:49 +0100 Subject: [PATCH 13/31] Add support for all secure elements --- as-lib/peripheral/CMakeLists.txt | 77 ++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 19 deletions(-) diff --git a/as-lib/peripheral/CMakeLists.txt b/as-lib/peripheral/CMakeLists.txt index 9a0473a88..5b1cb4b4c 100644 --- a/as-lib/peripheral/CMakeLists.txt +++ b/as-lib/peripheral/CMakeLists.txt @@ -3,29 +3,68 @@ cmake_minimum_required(VERSION 3.23) project(loramac-peripheral C) if (NOT TARGET ${PROJECT_NAME}) + + option(LORAMAC_SECURE_ELEMENT_PRE_PROVISIONED "Secure-element pre-provisioning" ON) + option(LORAMAC_AES_DEC_PREKEYED "AES DEC Prekeyed" ON) + add_library(${PROJECT_NAME} STATIC) - target_sources( - ${PROJECT_NAME} - PUBLIC - ${LORAMAC_SOURCE_DIR}/peripherals/gpio-ioe.h - ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/aes.h - ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/cmac.h - ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/se-identity.h - ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se-hal.h - - PRIVATE - ${LORAMAC_SOURCE_DIR}/peripherals/gpio-ioe.c - ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/aes.c - ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/cmac.c - ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se.c - ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se-hal.c - ) + + if (LORAMAC_SECURE_ELEMENT MATCHES SOFT_SE) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/aes.h + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/cmac.h + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/se-identity.h + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se-hal.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/aes.c + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/cmac.c + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se.c + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se-hal.c + ) + target_compile_definitions( + ${PROJECT_NAME} + PUBLIC + SOFT_SE + $<$:AES_DEC_PREKEYED> + ) + elseif(LORAMAC_SECURE_ELEMENT MATCHES LR1110_SE) + if (LORAMAC_RADIO MATCHES lr1110) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/lr1110-se-hal.h + ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/se-identity.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/lr1110-se.c + ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/lr1110-se-hal.c + ) + else() + message(FATAL_ERROR "LR1110_SE secure element can only be used when LR1110 radio is selected.") + endif() + elseif(LORAMAC_SECURE_ELEMENT MATCHES ATECC608A_TNGLORA_SE) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/atca_config.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/atecc608a-tnglora-se-hal.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/se-identity.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/atecc608a-tnglora-se.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/atecc608a-tnglora-se-hal.c + ) + else() + message(FATAL_ERROR "LORAMAC_SECURE_ELEMENT not defined") + endif() target_compile_definitions( ${PROJECT_NAME} - PUBLIC - SOFT_SE - AES_DEC_PREKEYED + PRIVATE + $<$:SECURE_ELEMENT_PRE_PROVISIONED> ) target_include_directories( From 43c36d1935f15d27f537c8bcd44e6f5fbbf7775a Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 18:46:15 +0100 Subject: [PATCH 14/31] Set LORAMAC_SUFFIX as cache variable if not already set --- as-lib/mac/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt index ff872f579..41c740d8e 100644 --- a/as-lib/mac/CMakeLists.txt +++ b/as-lib/mac/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.23) +if (NOT DEFINED LORAMAC_SUFFIX) + set(LORAMAC_SUFFIX "" CACHE STRING "Default suffix for LoRaMac Static Library builds") +endif() + project(loramac${LORAMAC_SUFFIX} C) if (NOT TARGET ${PROJECT_NAME}) From e73d7fe671c470094ad80591bb72480c91a01193 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 18:46:56 +0100 Subject: [PATCH 15/31] Make LORAMAC_SECURE_ELEMENT a cache variable and set property strings for GUI --- as-lib/peripheral/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/as-lib/peripheral/CMakeLists.txt b/as-lib/peripheral/CMakeLists.txt index 5b1cb4b4c..be9e4eead 100644 --- a/as-lib/peripheral/CMakeLists.txt +++ b/as-lib/peripheral/CMakeLists.txt @@ -7,6 +7,10 @@ if (NOT TARGET ${PROJECT_NAME}) option(LORAMAC_SECURE_ELEMENT_PRE_PROVISIONED "Secure-element pre-provisioning" ON) option(LORAMAC_AES_DEC_PREKEYED "AES DEC Prekeyed" ON) + set(LORAMAC_SECURE_ELEMENT_LIST SOFT_SE LR1110_SE ATECC608A_TNGLORA_SE) + set(LORAMAC_SECURE_ELEMENT SOFT_SE CACHE STRING "Default secure element is SOFT_SE") + set_property(CACHE LORAMAC_SECURE_ELEMENT PROPERTY STRINGS ${LORAMAC_SECURE_ELEMENT_LIST}) + add_library(${PROJECT_NAME} STATIC) if (LORAMAC_SECURE_ELEMENT MATCHES SOFT_SE) From 09211a7afceb1d76d02f159051827e12f8aa059b Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 18:56:44 +0100 Subject: [PATCH 16/31] Make AES_DEC_PREKEYED only relative to SOFT_SE --- as-lib/peripheral/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/as-lib/peripheral/CMakeLists.txt b/as-lib/peripheral/CMakeLists.txt index be9e4eead..5998f8c8c 100644 --- a/as-lib/peripheral/CMakeLists.txt +++ b/as-lib/peripheral/CMakeLists.txt @@ -5,7 +5,7 @@ project(loramac-peripheral C) if (NOT TARGET ${PROJECT_NAME}) option(LORAMAC_SECURE_ELEMENT_PRE_PROVISIONED "Secure-element pre-provisioning" ON) - option(LORAMAC_AES_DEC_PREKEYED "AES DEC Prekeyed" ON) + option(LORAMAC_SOFT_SE_AES_DEC_PREKEYED "Whether SOFT SE AES is DEC Prekeyed" ON) set(LORAMAC_SECURE_ELEMENT_LIST SOFT_SE LR1110_SE ATECC608A_TNGLORA_SE) set(LORAMAC_SECURE_ELEMENT SOFT_SE CACHE STRING "Default secure element is SOFT_SE") @@ -32,7 +32,7 @@ if (NOT TARGET ${PROJECT_NAME}) ${PROJECT_NAME} PUBLIC SOFT_SE - $<$:AES_DEC_PREKEYED> + $<$:AES_DEC_PREKEYED> ) elseif(LORAMAC_SECURE_ELEMENT MATCHES LR1110_SE) if (LORAMAC_RADIO MATCHES lr1110) From e199890368ab0c7c2d0062f93116fe84db2f8aca Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 18:57:02 +0100 Subject: [PATCH 17/31] Add options and explanations to README --- as-lib/README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/as-lib/README.md b/as-lib/README.md index 7bea81e70..359a1f077 100644 --- a/as-lib/README.md +++ b/as-lib/README.md @@ -2,4 +2,14 @@ **WIP** -This directory is provided to allow LoRaMac-node to be built as a static library for inclusion in other projects. \ No newline at end of file +This directory is provided to allow LoRaMac-node to be built as a static library for inclusion in other projects. + +## CMake Options + +- LORAMAC_AS_LIB:BOOL Whether to build the project as a static library (when ON), or to build the example applications +- LORAMAC_SUFFIX:STRING Defaults to empty, but can be set to any string to allow for multiple static libraries to + be build (for example with different region support) +- LORAMAC_SECURE_ELEMENT Name of the secure element, defaults to SOFT_SE +- LORAMAC_SECURE_ELEMENT_PRE_PROVISIONED Whether the secure element is pre-provisioned (default ON) +- LORAMAC_SOFT_SE_AES_DEC_PREKEYED Whether the SOFT SE secure elements AES support is DEC Prekeyed (default ON) +- LORAMAC_RADIO Name of the radio driver, defaults to SX1276 \ No newline at end of file From d1f801ad20b3757f57b9610eeefaf48cd18ac73c Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 13 Oct 2022 19:20:22 +0100 Subject: [PATCH 18/31] Add support for all radio drivers --- as-lib/README.md | 7 ++- as-lib/radio/CMakeLists.txt | 112 +++++++++++++++++++++++++++++++----- 2 files changed, 105 insertions(+), 14 deletions(-) diff --git a/as-lib/README.md b/as-lib/README.md index 359a1f077..52e2ff140 100644 --- a/as-lib/README.md +++ b/as-lib/README.md @@ -12,4 +12,9 @@ This directory is provided to allow LoRaMac-node to be built as a static library - LORAMAC_SECURE_ELEMENT Name of the secure element, defaults to SOFT_SE - LORAMAC_SECURE_ELEMENT_PRE_PROVISIONED Whether the secure element is pre-provisioned (default ON) - LORAMAC_SOFT_SE_AES_DEC_PREKEYED Whether the SOFT SE secure elements AES support is DEC Prekeyed (default ON) -- LORAMAC_RADIO Name of the radio driver, defaults to SX1276 \ No newline at end of file +- LORAMAC_RADIO Name of the radio driver, defaults to sx1272 +- LORAMAC_USE_RADIO_DEBUG Enable Radio Debug GPIO's (default OFF) + +## TODO + +- Submodule update (for LR1110 radio and ATECC608A secure element) \ No newline at end of file diff --git a/as-lib/radio/CMakeLists.txt b/as-lib/radio/CMakeLists.txt index 07120b09b..bb0762212 100644 --- a/as-lib/radio/CMakeLists.txt +++ b/as-lib/radio/CMakeLists.txt @@ -3,21 +3,107 @@ cmake_minimum_required(VERSION 3.23) project(loramac-radio C) if (NOT TARGET ${PROJECT_NAME}) - + + set(LORAMAC_RADIO_LIST sx1272 sx1276 sx126x lr1110) + set(LORAMAC_RADIO sx1272 CACHE STRING "Default radio is sx1272") + set_property(CACHE LORAMAC_RADIO PROPERTY STRINGS ${LORAMAC_RADIO_LIST}) + set_property(CACHE LORAMAC_RADIO PROPERTY ADVANCED) + add_library(${PROJECT_NAME} STATIC) - - target_sources( - ${PROJECT_NAME} - PUBLIC - ${LORAMAC_SOURCE_DIR}/radio/radio.h - ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276.h - ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276Regs-Fsk.h - ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276Regs-LoRa.h - PRIVATE - ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276.c - ) - + if (${LORAMAC_RADIO} MATCHES lr1110) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_bootloader.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_bootloader_types.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_crypto_engine.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_crypto_engine_types.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_driver_version.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_gnss.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_gnss_types.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_radio.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_radio_types.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_regmem.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_system.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_system_types.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_wifi.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_wifi_types.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/radio/lr1110/radio.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_bootloader.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_crypto_engine.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_driver_version.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_gnss.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_radio.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_regmem.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_system.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_wifi.c + ) + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/lr1110 + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src + + ) + elseif (${LORAMAC_RADIO} MATCHES sx126x) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/sx126x/sx126x.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/radio/sx126x/radio.c + ${LORAMAC_SOURCE_DIR}/radio/sx126x/sx126x.c + ) + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/sx126x + ) + elseif (${LORAMAC_RADIO} MATCHES sx1272) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/sx1272/sx1272.h + ${LORAMAC_SOURCE_DIR}/radio/sx1272/sx1272Regs-Fsk.h + ${LORAMAC_SOURCE_DIR}/radio/sx1272/sx1272Regs-LoRa.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/radio/sx1272/sx1272.c + ) + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/sx1272 + ) + elseif (${LORAMAC_RADIO} MATCHES sx1276) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/radio.h + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276.h + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276Regs-Fsk.h + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276Regs-LoRa.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276.c + ) + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/sx1276 + ) + else() + message(FATAL_ERROR "Unsupported radio driver selected...") + endif() + + option(LORAMAC_USE_RADIO_DEBUG "Enable Radio Debug GPIO's" OFF) + target_compile_definitions(${PROJECT_NAME} PUBLIC $<$:USE_RADIO_DEBUG>) + target_include_directories( ${PROJECT_NAME} PUBLIC From 5bbd643542a9b8aca20981d22bc0f7a08d324781 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Fri, 14 Oct 2022 10:36:08 +0100 Subject: [PATCH 19/31] Use file GLOB to include aetcc608a-tnglora-se cryptoauthlib --- as-lib/peripheral/CMakeLists.txt | 113 ++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 26 deletions(-) diff --git a/as-lib/peripheral/CMakeLists.txt b/as-lib/peripheral/CMakeLists.txt index 5998f8c8c..c04fe3f44 100644 --- a/as-lib/peripheral/CMakeLists.txt +++ b/as-lib/peripheral/CMakeLists.txt @@ -14,15 +14,17 @@ if (NOT TARGET ${PROJECT_NAME}) add_library(${PROJECT_NAME} STATIC) if (LORAMAC_SECURE_ELEMENT MATCHES SOFT_SE) - target_sources( - ${PROJECT_NAME} - PUBLIC + list( + APPEND + ${PROJECT_NAME}_HEADERS ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/aes.h ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/cmac.h ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/se-identity.h ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se-hal.h - - PRIVATE + ) + list( + APPEND + ${PROJECT_NAME}_SOURCES ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/aes.c ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/cmac.c ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se.c @@ -34,48 +36,107 @@ if (NOT TARGET ${PROJECT_NAME}) SOFT_SE $<$:AES_DEC_PREKEYED> ) + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se + ${LORAMAC_SOURCE_DIR}/mac + ) elseif(LORAMAC_SECURE_ELEMENT MATCHES LR1110_SE) if (LORAMAC_RADIO MATCHES lr1110) - target_sources( - ${PROJECT_NAME} - PUBLIC + list( + APPEND + ${PROJECT_NAME}_HEADERS ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/lr1110-se-hal.h ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/se-identity.h - - PRIVATE + ) + list( + APPEND + ${PROJECT_NAME}_SOURCES ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/lr1110-se.c ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/lr1110-se-hal.c ) + target_include_directories( + ${PROJECT_NAME} PUBLIC + ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se + ) else() message(FATAL_ERROR "LR1110_SE secure element can only be used when LR1110 radio is selected.") endif() elseif(LORAMAC_SECURE_ELEMENT MATCHES ATECC608A_TNGLORA_SE) - target_sources( - ${PROJECT_NAME} - PUBLIC - ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/atca_config.h - ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/atecc608a-tnglora-se-hal.h - ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/se-identity.h - - PRIVATE - ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/atecc608a-tnglora-se.c - ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/atecc608a-tnglora-se-hal.c + file( + GLOB + ${PROJECT_NAME}_HEADERS + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/*.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/*.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/basic/*.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto/*.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto/hashes/*.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/hal/atca_hal.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/host/*.h + ) + file( + GLOB + ${PROJECT_NAME}_SOURCES + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/*.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/*.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/basic/*.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto/*.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto/hashes/*.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/hal/atca_hal.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/host/*.c + ) + target_include_directories( + ${PROJECT_NAME} PUBLIC + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/basic + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto/hashes + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/hal + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/host ) else() message(FATAL_ERROR "LORAMAC_SECURE_ELEMENT not defined") endif() - target_compile_definitions( + list( + APPEND + ${PROJECT_NAME}_HEADERS + ${LORAMAC_SOURCE_DIR}/peripherals/gpio-ioe.h + ${LORAMAC_SOURCE_DIR}/peripherals/mag3110.h + ${LORAMAC_SOURCE_DIR}/peripherals/mma8451.h + ${LORAMAC_SOURCE_DIR}/peripherals/mpl3115.h + ${LORAMAC_SOURCE_DIR}/peripherals/pam7q.h + ${LORAMAC_SOURCE_DIR}/peripherals/sx1509.h + ${LORAMAC_SOURCE_DIR}/peripherals/sx9500.h + ) + + list( + APPEND + ${PROJECT_NAME}_SOURCES + ${LORAMAC_SOURCE_DIR}/peripherals/gpio-ioe.c + ${LORAMAC_SOURCE_DIR}/peripherals/mag3110.c + ${LORAMAC_SOURCE_DIR}/peripherals/mma8451.c + ${LORAMAC_SOURCE_DIR}/peripherals/mpl3115.c + ${LORAMAC_SOURCE_DIR}/peripherals/pam7q.c + ${LORAMAC_SOURCE_DIR}/peripherals/sx1509.c + ${LORAMAC_SOURCE_DIR}/peripherals/sx9500.c + ) + + target_sources( ${PROJECT_NAME} + PUBLIC + ${${PROJECT_NAME}_HEADERS} + PRIVATE - $<$:SECURE_ELEMENT_PRE_PROVISIONED> + ${${PROJECT_NAME}_SOURCES} ) - target_include_directories( + target_compile_definitions( ${PROJECT_NAME} - PUBLIC - ${LORAMAC_SOURCE_DIR}/peripherals/soft-se - ${LORAMAC_SOURCE_DIR}/mac + PRIVATE + $<$:SECURE_ELEMENT_PRE_PROVISIONED> ) target_link_libraries( From b6aa97a5dacbbd38e27901ed46cb517acd4f67f6 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Fri, 14 Oct 2022 10:36:26 +0100 Subject: [PATCH 20/31] Update TODOs --- as-lib/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/as-lib/README.md b/as-lib/README.md index 52e2ff140..91215428d 100644 --- a/as-lib/README.md +++ b/as-lib/README.md @@ -17,4 +17,5 @@ This directory is provided to allow LoRaMac-node to be built as a static library ## TODO -- Submodule update (for LR1110 radio and ATECC608A secure element) \ No newline at end of file +- FetchContent should not override GIT_SUBMODULES or lr1110-driver and atecc608a-tnglora-se/cryptoauthlib won't be loaded +- AES_DEC_PREKEYED - why did I define this in the project, it may not be needed \ No newline at end of file From b020abed56d63306f89ba26b686402463497ac9e Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Fri, 14 Oct 2022 11:52:43 +0100 Subject: [PATCH 21/31] Remove LmHandler, not part of LoRaMac API --- as-lib/mac/CMakeLists.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt index 41c740d8e..cb96636d8 100644 --- a/as-lib/mac/CMakeLists.txt +++ b/as-lib/mac/CMakeLists.txt @@ -14,10 +14,6 @@ if (NOT TARGET ${PROJECT_NAME}) target_sources( ${PROJECT_NAME} PUBLIC - ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler/LmHandler.h - ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler/LmHandlerTypes.h - ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler/packages/LmhPackage.h - ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/NvmDataMgmt.h ${LORAMAC_SOURCE_DIR}/mac/LoRaMac.h ${LORAMAC_SOURCE_DIR}/mac/LoRaMacAdr.h ${LORAMAC_SOURCE_DIR}/mac/LoRaMacClassB.h @@ -40,8 +36,6 @@ if (NOT TARGET ${PROJECT_NAME}) $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.h> PRIVATE - ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler/LmHandler.c - ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/NvmDataMgmt.c ${LORAMAC_SOURCE_DIR}/mac/LoRaMac.c ${LORAMAC_SOURCE_DIR}/mac/LoRaMacAdr.c ${LORAMAC_SOURCE_DIR}/mac/LoRaMacClassB.c @@ -79,15 +73,11 @@ if (NOT TARGET ${PROJECT_NAME}) target_compile_definitions( ${PROJECT_NAME} PUBLIC - ACTIVE_REGION # TODO: remove from lmHandler.c? ) target_include_directories( ${PROJECT_NAME} PUBLIC - ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler - ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common/LmHandler/packages - ${LORAMAC_SOURCE_DIR}/apps/LoRaMac/common ${LORAMAC_SOURCE_DIR}/mac ${LORAMAC_SOURCE_DIR}/mac/region ) From b9f7c594db1c642c4a4d9eeeb4298228c9db71e9 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Sat, 15 Oct 2022 17:42:40 +0100 Subject: [PATCH 22/31] Expand README with guidance on building with FetchContent --- as-lib/README.md | 96 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 88 insertions(+), 8 deletions(-) diff --git a/as-lib/README.md b/as-lib/README.md index 91215428d..b08a5a181 100644 --- a/as-lib/README.md +++ b/as-lib/README.md @@ -2,20 +2,100 @@ **WIP** +## Purpose + This directory is provided to allow LoRaMac-node to be built as a static library for inclusion in other projects. -## CMake Options +This directory contains a set of CMakeLists.txt files that shadow the directory structure under `src`. A backwards +compatible change is made to the project root CMakeLists.txt which, when provided with the option `LORAMAC_AS_LIB`, +will direct CMake to reference the as-lib directory instead of src. The option default is OFF so that the past +build behaviour is preserved as the default. + +CMake configuration options are provided that mirror equivalent options in the `src` configuration tree, but a +standard `LORAMAC_` prefix is applied to all options to aid interoperability with other project sources. + +## Supported CMake Configuration Options - LORAMAC_AS_LIB:BOOL Whether to build the project as a static library (when ON), or to build the example applications - LORAMAC_SUFFIX:STRING Defaults to empty, but can be set to any string to allow for multiple static libraries to be build (for example with different region support) -- LORAMAC_SECURE_ELEMENT Name of the secure element, defaults to SOFT_SE -- LORAMAC_SECURE_ELEMENT_PRE_PROVISIONED Whether the secure element is pre-provisioned (default ON) -- LORAMAC_SOFT_SE_AES_DEC_PREKEYED Whether the SOFT SE secure elements AES support is DEC Prekeyed (default ON) -- LORAMAC_RADIO Name of the radio driver, defaults to sx1272 -- LORAMAC_USE_RADIO_DEBUG Enable Radio Debug GPIO's (default OFF) +- LORAMAC_SECURE_ELEMENT:STRING Name of the secure element, defaults to SOFT_SE +- LORAMAC_SECURE_ELEMENT_PRE_PROVISIONED:BOOL Whether the secure element is pre-provisioned (default ON) +- LORAMAC_RADIO:STRING Name of the radio driver, defaults to sx1272 +- LORAMAC_USE_RADIO_DEBUG:BOOL Enable Radio Debug GPIO's (default OFF) + +## Preparation for loading and building + +You must establish your toolchain prior to your first CMake `project()` call (which triggers toolchain detection). It +is beyond the scope of this document to describe how to do that for your platform. + +You will need to provide a board implementation that suits your project. A number of standard boards are provided +in the LoRaMac-node project which can be copied after the first CMake configure pass. Typically you will copy one of these +(from the `/src/boards` directory) into your own project sources and make any necessary changes. + +NB: Pre-built board implementation targets are not provided due to the complexity of providing included or project +specific HAL libraries. `CMakeLists.txt` files are included in the board implementation directories that can be used +as a starting point for your own project. + +Depending on your platform, you may need to obtain Hardware Abstraction Libraries that are used by the board +implementation that you choose. LoRaMac-node includes some of these for the provided board implementations (in the +`/src/board/mcu` directory), but you may wish provide your own version (perhaps via FetchContent from the official +sources). + +## Configuring via FetchContent to create a single library + +``` +FetchContent_Declare( + loramac + GIT_REPOSITORY https://github.com/Lora-net/LoRaMac-node + GIT_TAG master # branch or version tag, such a v4.7.0 +) + +set(LORAMAC_AS_LIB ON) +set(LORAMAC_RADIO sx1276) +set(REGION_EU868 ON) +FetchContent_MakeAvailable(loramac) + +# add your own target + +add_executable(MyProject C) +target_sources(MyProject main.c) +target_link_libraries(MyProject loramac) +``` + +## Configuring via FetchContent to create multiple libraries + +FetchContent should be used to load the project at CMake configure time (rather than build time using ExternalProject). + +``` +FetchContent_Declare( + loramac + GIT_REPOSITORY https://github.com/Lora-net/LoRaMac-node + GIT_TAG master +) + +FetchContent_GetProperties(loramac) +if (NOT loramac_POPULATED) + FetchContent_Populate(loramac) +endif() + +set(LORAMAC_AS_LIB ON) +set(LORAMAC_RADIO sx1276) +set(LORAMAC_SUFFIX -Europe) +set(REGION_EU868 ON) +add_subdirectory(loramac_SOURCE_DIR loramac${LORAMAC_SUFFIX}) + +set(REGION_EU868 OFF) +set(REGION_US915 ON) +set(LORAMAC_SUFFIX -US) +add_subdirectory(loramac_SOURCE_DIR loramac${LORAMAC_SUFFIX}) + +# You now have targets loramac-Europe and loramac-US to link to your own targets + +add_executable(MyProject C) +target_sources(MyProject main.c) +target_link_libraries(MyProject loramac-Europe) +``` ## TODO -- FetchContent should not override GIT_SUBMODULES or lr1110-driver and atecc608a-tnglora-se/cryptoauthlib won't be loaded -- AES_DEC_PREKEYED - why did I define this in the project, it may not be needed \ No newline at end of file From 2e90b60a7e07c278539951452878f894f1530069 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Sat, 15 Oct 2022 17:43:14 +0100 Subject: [PATCH 23/31] Renove LORAMAC_SOFT_SE_AES_DEC_PREKEYED as not exposed by `src` tree --- as-lib/peripheral/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/as-lib/peripheral/CMakeLists.txt b/as-lib/peripheral/CMakeLists.txt index c04fe3f44..f614193a9 100644 --- a/as-lib/peripheral/CMakeLists.txt +++ b/as-lib/peripheral/CMakeLists.txt @@ -5,7 +5,6 @@ project(loramac-peripheral C) if (NOT TARGET ${PROJECT_NAME}) option(LORAMAC_SECURE_ELEMENT_PRE_PROVISIONED "Secure-element pre-provisioning" ON) - option(LORAMAC_SOFT_SE_AES_DEC_PREKEYED "Whether SOFT SE AES is DEC Prekeyed" ON) set(LORAMAC_SECURE_ELEMENT_LIST SOFT_SE LR1110_SE ATECC608A_TNGLORA_SE) set(LORAMAC_SECURE_ELEMENT SOFT_SE CACHE STRING "Default secure element is SOFT_SE") @@ -34,7 +33,6 @@ if (NOT TARGET ${PROJECT_NAME}) ${PROJECT_NAME} PUBLIC SOFT_SE - $<$:AES_DEC_PREKEYED> ) target_include_directories( ${PROJECT_NAME} From 7aa0fc507c5010e09598fee7a027517de9f02775 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Sat, 15 Oct 2022 18:01:37 +0100 Subject: [PATCH 24/31] Clarify that ExternalProject is not currently supported --- as-lib/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/as-lib/README.md b/as-lib/README.md index b08a5a181..d34db6c35 100644 --- a/as-lib/README.md +++ b/as-lib/README.md @@ -67,11 +67,13 @@ target_link_libraries(MyProject loramac) FetchContent should be used to load the project at CMake configure time (rather than build time using ExternalProject). +`ExternalProject_Add` is not supported at this time. + ``` FetchContent_Declare( loramac GIT_REPOSITORY https://github.com/Lora-net/LoRaMac-node - GIT_TAG master + GIT_TAG master # branch or version tag, such a v4.7.0 ) FetchContent_GetProperties(loramac) From 7b27312e865f30f0f4b6c8fe2de1a8840bad7bdc Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Sat, 15 Oct 2022 18:25:04 +0100 Subject: [PATCH 25/31] Expand README on region support, rename region variables to have LORAMAC_ prefix --- as-lib/README.md | 23 ++++++++++++++++++++++- as-lib/mac/CMakeLists.txt | 12 ++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/as-lib/README.md b/as-lib/README.md index d34db6c35..fb923829d 100644 --- a/as-lib/README.md +++ b/as-lib/README.md @@ -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 @@ -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 @@ -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}) diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt index cb96636d8..63452b53a 100644 --- a/as-lib/mac/CMakeLists.txt +++ b/as-lib/mac/CMakeLists.txt @@ -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 - $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c> + $<$,$>:${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} @@ -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 From 526f05b58798c0c9eeacb6de8c065f77ec1a4ec9 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Sat, 15 Oct 2022 18:39:16 +0100 Subject: [PATCH 26/31] Fix lack of LORAMAC_ prefix when passing region options --- as-lib/mac/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt index 63452b53a..347d3a326 100644 --- a/as-lib/mac/CMakeLists.txt +++ b/as-lib/mac/CMakeLists.txt @@ -33,7 +33,7 @@ if (NOT TARGET ${PROJECT_NAME}) ${LORAMAC_SOURCE_DIR}/mac/secure-element-nvm.h ${LORAMAC_SOURCE_DIR}/mac/region/Region.h ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.h - $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.h> + $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.h> PRIVATE ${LORAMAC_SOURCE_DIR}/mac/LoRaMac.c @@ -68,7 +68,7 @@ if (NOT TARGET ${PROJECT_NAME}) target_compile_definitions( ${PROJECT_NAME} PUBLIC - $<$:REGION_${REGION}> + $<$:REGION_${REGION}> ) endif() From a7a07e8bf37f278120c0252939582e7c1ef0aaa1 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Sat, 15 Oct 2022 18:41:48 +0100 Subject: [PATCH 27/31] Update README to note that LORAMAC_SUFFIX must use FORCE override --- as-lib/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/as-lib/README.md b/as-lib/README.md index fb923829d..4e52fc94a 100644 --- a/as-lib/README.md +++ b/as-lib/README.md @@ -104,13 +104,13 @@ endif() set(LORAMAC_AS_LIB ON) set(LORAMAC_RADIO sx1276) -set(LORAMAC_SUFFIX -Europe) +set(LORAMAC_SUFFIX -Europe CACHE STRING "" FORCE) # must force override set(REGION_EU868 ON) add_subdirectory(loramac_SOURCE_DIR loramac${LORAMAC_SUFFIX}) set(REGION_EU868 OFF) # NB: Override last pass set(REGION_US915 ON) -set(LORAMAC_SUFFIX -US) +set(LORAMAC_SUFFIX -US CACHE STRING "" FORCE) # must force override add_subdirectory(loramac_SOURCE_DIR loramac${LORAMAC_SUFFIX}) # You now have targets loramac-Europe and loramac-US to link to your own targets From 065b25de699001c13c8bff62e8a2d0453cd12316 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 27 Apr 2023 17:11:46 +0100 Subject: [PATCH 28/31] Add RegionCN470B20.c/h when building for CN470 --- as-lib/mac/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt index 347d3a326..f5e5cc225 100644 --- a/as-lib/mac/CMakeLists.txt +++ b/as-lib/mac/CMakeLists.txt @@ -34,6 +34,7 @@ if (NOT TARGET ${PROJECT_NAME}) ${LORAMAC_SOURCE_DIR}/mac/region/Region.h ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.h $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.h> + $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.h> PRIVATE ${LORAMAC_SOURCE_DIR}/mac/LoRaMac.c @@ -47,6 +48,7 @@ if (NOT TARGET ${PROJECT_NAME}) ${LORAMAC_SOURCE_DIR}/mac/region/Region.c ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.c $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c> + $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.c> ) set(ACTIVE_REGION_COUNT 0) From be38c56d6332217d254f918726b4b5cf81e31930 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 27 Apr 2023 17:16:55 +0100 Subject: [PATCH 29/31] Add RegionCN470{X}2{X}.c/h all variants when building for CN470 --- as-lib/mac/CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt index f5e5cc225..80d345734 100644 --- a/as-lib/mac/CMakeLists.txt +++ b/as-lib/mac/CMakeLists.txt @@ -34,7 +34,12 @@ if (NOT TARGET ${PROJECT_NAME}) ${LORAMAC_SOURCE_DIR}/mac/region/Region.h ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.h $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.h> - $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.h> + $<$,$>: + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A20.h + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.h + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A26.h + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B26.h + > PRIVATE ${LORAMAC_SOURCE_DIR}/mac/LoRaMac.c @@ -48,7 +53,12 @@ if (NOT TARGET ${PROJECT_NAME}) ${LORAMAC_SOURCE_DIR}/mac/region/Region.c ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.c $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c> - $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.c> + $<$,$>: + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A20.c + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.c + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A26.c + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B26.c + > ) set(ACTIVE_REGION_COUNT 0) From 6cdda80f292134935ac8769f65d9431e16429188 Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 27 Apr 2023 17:40:03 +0100 Subject: [PATCH 30/31] Remove unnecessary OR when including CN470 --- as-lib/mac/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt index 80d345734..8aefe4279 100644 --- a/as-lib/mac/CMakeLists.txt +++ b/as-lib/mac/CMakeLists.txt @@ -34,7 +34,7 @@ if (NOT TARGET ${PROJECT_NAME}) ${LORAMAC_SOURCE_DIR}/mac/region/Region.h ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.h $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.h> - $<$,$>: + $<$: ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A20.h ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.h ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A26.h @@ -53,7 +53,7 @@ if (NOT TARGET ${PROJECT_NAME}) ${LORAMAC_SOURCE_DIR}/mac/region/Region.c ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.c $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c> - $<$,$>: + $<$: ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A20.c ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.c ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A26.c From 28840ecc59b4f8b422496c695e3131935d102c5b Mon Sep 17 00:00:00 2001 From: Dave Meehan Date: Thu, 27 Apr 2023 17:43:57 +0100 Subject: [PATCH 31/31] Fix incorrect use of BOOL when including CN470 --- as-lib/mac/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt index 8aefe4279..ea1b33459 100644 --- a/as-lib/mac/CMakeLists.txt +++ b/as-lib/mac/CMakeLists.txt @@ -34,7 +34,7 @@ if (NOT TARGET ${PROJECT_NAME}) ${LORAMAC_SOURCE_DIR}/mac/region/Region.h ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.h $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.h> - $<$: + $<$: ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A20.h ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.h ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A26.h @@ -53,7 +53,7 @@ if (NOT TARGET ${PROJECT_NAME}) ${LORAMAC_SOURCE_DIR}/mac/region/Region.c ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.c $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c> - $<$: + $<$: ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A20.c ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.c ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A26.c