From e54d3ecf3407c2b9a0abe86ce406de76b2b5a180 Mon Sep 17 00:00:00 2001 From: Miguel Luis Date: Mon, 18 Jan 2021 13:31:12 +0100 Subject: [PATCH] Fixed compiling issues --- CHANGELOG.md | 16 + README.md | 4 +- src/apps/LoRaMac/CMakeLists.txt | 339 +++---- .../fuota-test-01/B-L072Z-LRWAN1/main.c | 2 +- .../LoRaMac/fuota-test-01/NAMote72/main.c | 2 +- .../LoRaMac/fuota-test-01/NucleoL073/main.c | 2 +- .../LoRaMac/fuota-test-01/NucleoL152/main.c | 2 +- .../LoRaMac/fuota-test-01/NucleoL476/main.c | 2 +- src/apps/LoRaMac/fuota-test-01/SAMR34/main.c | 2 +- .../LoRaMac/fuota-test-01/SKiM880B/main.c | 2 +- .../LoRaMac/fuota-test-01/SKiM881AXL/main.c | 2 +- .../LoRaMac/fuota-test-01/SKiM980A/main.c | 2 +- .../periodic-uplink-lpp/B-L072Z-LRWAN1/main.c | 2 +- .../periodic-uplink-lpp/NAMote72/main.c | 2 +- .../periodic-uplink-lpp/NucleoL073/main.c | 2 +- .../periodic-uplink-lpp/NucleoL152/main.c | 2 +- .../periodic-uplink-lpp/NucleoL476/main.c | 2 +- .../LoRaMac/periodic-uplink-lpp/SAMR34/main.c | 2 +- .../periodic-uplink-lpp/SKiM880B/main.c | 2 +- .../periodic-uplink-lpp/SKiM881AXL/main.c | 2 +- .../periodic-uplink-lpp/SKiM980A/main.c | 2 +- src/mac/CMakeLists.txt | 227 ++--- src/mac/LoRaMac.h | 38 +- src/mac/region/RegionRU864.h | 894 +++++++++--------- 24 files changed, 786 insertions(+), 768 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d8ffffcb..4b36a1750 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,22 @@ Please refer to [Releases pre-certification-results](https://github.com/Lora-net ## [Unreleased] +## [4.4.7] - 2021-01-18 + +### General + +- Release based on "LoRaWAN specification 1.0.3" and "LoRaWAN Regional Parameters v1.0.3revA" +- **Release 4.4.7 is an hotfix of 4.4.6 and is the last one supporting "LoRaWAN specification 1.0.3"** + +### Changed + +- Changed examples GitHub version to 4.4.7 + +### Fixed + +- Fixed compiling issues when KR920 or RU864 regions are selected +- Fixed compiling issues for `fuota-test-01` example + ## [4.4.6] - 2020-12-18 ### General diff --git a/README.md b/README.md index 8921b5387..fd955b6d8 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,8 @@ This project has 2 active branches in place. | Branch | L2 spec | RP spec | Tag/Milestone | Class | Comments | | ------------- |:-------------:|:---------:|:---------:|:---------:|:--------------| -| | [1.0.3](https://lora-alliance.org/resource-hub/lorawanr-specification-v103) | [v1.0.3revA](https://www.lora-alliance.org/resource-hub/lorawanr-regional-parameters-v103reva) | [v4.4.6](https://github.com/Lora-net/LoRaMac-node/releases/tag/v4.4.6) | A/B/C | LoRaWAN L2 1.0.3 - **_Released_ (last release based on 1.0.3)** | -| [master](https://github.com/Lora-net/LoRaMac-node/tree/master) | [1.0.4](https://lora-alliance.org/resource-hub/lorawan-104-specification-package) | [2-1.0.1](https://lora-alliance.org/sites/default/files/2020-02/rp_2-1.0.1.pdf) | [M 4.5.0](https://github.com/Lora-net/LoRaMac-node/milestone/5) | A/B/C | LoRaWAN L2 1.0.4 | +| | [1.0.3](https://lora-alliance.org/resource-hub/lorawanr-specification-v103) | [v1.0.3revA](https://www.lora-alliance.org/resource-hub/lorawanr-regional-parameters-v103reva) | [v4.4.7](https://github.com/Lora-net/LoRaMac-node/releases/tag/v4.4.7) | A/B/C | LoRaWAN L2 1.0.3 - **_Released_ (last release based on 1.0.3)** | +| [master](https://github.com/Lora-net/LoRaMac-node/tree/master) | [1.0.4](https://lora-alliance.org/resource-hub/lorawan-104-specification-package) | [2-1.0.1](https://lora-alliance.org/sites/default/files/2020-02/rp_2-1.0.1.pdf) | [v4.5.0](https://github.com/Lora-net/LoRaMac-node/releases/tag/v4.5.0) | A/B/C | LoRaWAN L2 1.0.4 | | [develop](https://github.com/Lora-net/LoRaMac-node/tree/develop) | [1.0.4](https://lora-alliance.org/resource-hub/lorawan-104-specification-package) / [1.1.1](https://lora-alliance.org/resource-hub/lorawanr-specification-v11) | [2-1.0.1](https://lora-alliance.org/sites/default/files/2020-02/rp_2-1.0.1.pdf) | [M 4.6.0](https://github.com/Lora-net/LoRaMac-node/milestone/3) | A/B/C | LoRaWAN L2 1.0.4 / 1.1.1 | This project fully implements ClassA, ClassB and ClassC end-device classes and it also provides SX1272/73, SX1276/77/78/79, SX1261/2 and LR1110 radio drivers. diff --git a/src/apps/LoRaMac/CMakeLists.txt b/src/apps/LoRaMac/CMakeLists.txt index c51a5323b..3471fdec6 100644 --- a/src/apps/LoRaMac/CMakeLists.txt +++ b/src/apps/LoRaMac/CMakeLists.txt @@ -1,169 +1,170 @@ -## -## ______ _ -## / _____) _ | | -## ( (____ _____ ____ _| |_ _____ ____| |__ -## \____ \| ___ | (_ _) ___ |/ ___) _ \ -## _____) ) ____| | | || |_| ____( (___| | | | -## (______/|_____)_|_|_| \__)_____)\____)_| |_| -## (C)2013-2017 Semtech -## ___ _____ _ ___ _ _____ ___ ___ ___ ___ -## / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| -## \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| -## |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| -## embedded.connectivity.solutions.============== -## -## License: Revised BSD License, see LICENSE.TXT file included in the project -## Authors: Johannes Bruder (STACKFORCE), Miguel Luis (Semtech) -## -project(LoRaMac) -cmake_minimum_required(VERSION 3.6) - -#--------------------------------------------------------------------------------------- -# Options -#--------------------------------------------------------------------------------------- - -# Allow switching of sub projects -set(SUB_PROJECT_LIST periodic-uplink-lpp fuota-test-01) -set(SUB_PROJECT periodic-uplink-lpp CACHE STRING "Default sub project is periodic-uplink-lpp") -set_property(CACHE SUB_PROJECT PROPERTY STRINGS ${SUB_PROJECT_LIST}) - -# Allow switching of active region -set(ACTIVE_REGION_LIST LORAMAC_REGION_EU868 LORAMAC_REGION_US915 LORAMAC_REGION_CN779 - LORAMAC_REGION_EU433 LORAMAC_REGION_AU915 LORAMAC_REGION_AS923 LORAMAC_REGION_CN470 - LORAMAC_REGION_KR920 LORAMAC_REGION_IN865 LORAMAC_REGION_RU864 -) -set(ACTIVE_REGION LORAMAC_REGION_EU868 CACHE STRING "Default active region is EU868") -set_property(CACHE ACTIVE_REGION PROPERTY STRINGS ${ACTIVE_REGION_LIST}) - -if((SUB_PROJECT STREQUAL periodic-uplink-lpp OR SUB_PROJECT STREQUAL fuota-test-01) AND NOT CLASSB_ENABLED ) - message(FATAL_ERROR "Please turn on Class B support of LoRaMac ( CLASSB_ENABLED=ON ) to use periodic-uplink-lpp, fuota-test-01 sub projects") -endif() - -# Allow selection of secure-element provisioning method -option(SECURE_ELEMENT_PRE_PROVISIONED "Secure-element pre-provisioning" ON) - -if(SUB_PROJECT STREQUAL periodic-uplink-lpp) - - #--------------------------------------------------------------------------------------- - # Application common features handling - #--------------------------------------------------------------------------------------- - list(APPEND ${PROJECT_NAME}_COMMON - "${CMAKE_CURRENT_LIST_DIR}/common/CayenneLpp.c" - "${CMAKE_CURRENT_LIST_DIR}/common/cli.c" - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandlerMsgDisplay.c" - "${CMAKE_CURRENT_LIST_DIR}/common/NvmDataMgmt.c" - ) - - #--------------------------------------------------------------------------------------- - # Application LoRaMac handler - #--------------------------------------------------------------------------------------- - list(APPEND ${PROJECT_NAME}_LMH - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/LmHandler.c" - ) - - #--------------------------------------------------------------------------------------- - # LoRaMac handler applicative packages - #--------------------------------------------------------------------------------------- - list(APPEND ${PROJECT_NAME}_LMHP - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/FragDecoder.c" - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpClockSync.c" - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpCompliance.c" - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpFragmentation.c" - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpRemoteMcastSetup.c" - ) - -elseif(SUB_PROJECT STREQUAL fuota-test-01) - - #--------------------------------------------------------------------------------------- - # Application common features handling - #--------------------------------------------------------------------------------------- - list(APPEND ${PROJECT_NAME}_COMMON - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandlerMsgDisplay.c" - "${CMAKE_CURRENT_LIST_DIR}/common/NvmDataMgmt.c" - ) - - #--------------------------------------------------------------------------------------- - # Application LoRaMac handler - #--------------------------------------------------------------------------------------- - list(APPEND ${PROJECT_NAME}_LMH - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/LmHandler.c" - ) - - #--------------------------------------------------------------------------------------- - # LoRaMac handler applicative packages - #--------------------------------------------------------------------------------------- - list(APPEND ${PROJECT_NAME}_LMHP - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/FragDecoder.c" - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpClockSync.c" - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpCompliance.c" - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpFragmentation.c" - "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpRemoteMcastSetup.c" - ) - -else() - message(FATAL_ERROR "Unknown SUB_PROJECT") -endif() - -#--------------------------------------------------------------------------------------- -# Application -#--------------------------------------------------------------------------------------- -file(GLOB ${PROJECT_NAME}_SOURCES "${CMAKE_CURRENT_LIST_DIR}/${SUB_PROJECT}/${BOARD}/*.c") - -add_executable(${PROJECT_NAME}-${SUB_PROJECT} - ${${PROJECT_NAME}_COMMON} - ${${PROJECT_NAME}_LMH} - ${${PROJECT_NAME}_LMHP} - ${${PROJECT_NAME}_SOURCES} - $ - $ - $ - $ - $ -) - -target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE $<$:LORAMAC_CLASSB_ENABLED>) -target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE ACTIVE_REGION=${ACTIVE_REGION}) -if(${SECURE_ELEMENT_PRE_PROVISIONED} MATCHES ON) - target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE -DSECURE_ELEMENT_PRE_PROVISIONED) -endif() -if(${SECURE_ELEMENT} MATCHES SOFT_SE) - target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE -DSOFT_SE) -endif() -target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PUBLIC - $> -) - -target_include_directories(${PROJECT_NAME}-${SUB_PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/common - ${CMAKE_CURRENT_SOURCE_DIR}/common/LmHandler - ${CMAKE_CURRENT_SOURCE_DIR}/common/LmHandler/packages - ${CMAKE_CURRENT_SOURCE_DIR}/${SUB_PROJECT}/${BOARD} - $> - $> - $> - $> - $> -) - -set_property(TARGET ${PROJECT_NAME}-${SUB_PROJECT} PROPERTY C_STANDARD 11) - -target_link_libraries(${PROJECT_NAME}-${SUB_PROJECT} m) - -#--------------------------------------------------------------------------------------- -# Debugging and Binutils -#--------------------------------------------------------------------------------------- - -include(gdb-helper) -include(binutils-arm-none-eabi) - -# Generate debugger configurations -generate_run_gdb_stlink(${PROJECT_NAME}-${SUB_PROJECT}) -generate_run_gdb_openocd(${PROJECT_NAME}-${SUB_PROJECT}) -generate_vscode_launch_openocd(${PROJECT_NAME}-${SUB_PROJECT}) - -# Print section sizes of target -print_section_sizes(${PROJECT_NAME}-${SUB_PROJECT}) - -# Create output in hex and binary format -create_bin_output(${PROJECT_NAME}-${SUB_PROJECT}) -create_hex_output(${PROJECT_NAME}-${SUB_PROJECT}) +## +## ______ _ +## / _____) _ | | +## ( (____ _____ ____ _| |_ _____ ____| |__ +## \____ \| ___ | (_ _) ___ |/ ___) _ \ +## _____) ) ____| | | || |_| ____( (___| | | | +## (______/|_____)_|_|_| \__)_____)\____)_| |_| +## (C)2013-2017 Semtech +## ___ _____ _ ___ _ _____ ___ ___ ___ ___ +## / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| +## \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| +## |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| +## embedded.connectivity.solutions.============== +## +## License: Revised BSD License, see LICENSE.TXT file included in the project +## Authors: Johannes Bruder (STACKFORCE), Miguel Luis (Semtech) +## +project(LoRaMac) +cmake_minimum_required(VERSION 3.6) + +#--------------------------------------------------------------------------------------- +# Options +#--------------------------------------------------------------------------------------- + +# Allow switching of sub projects +set(SUB_PROJECT_LIST periodic-uplink-lpp fuota-test-01) +set(SUB_PROJECT periodic-uplink-lpp CACHE STRING "Default sub project is periodic-uplink-lpp") +set_property(CACHE SUB_PROJECT PROPERTY STRINGS ${SUB_PROJECT_LIST}) + +# Allow switching of active region +set(ACTIVE_REGION_LIST LORAMAC_REGION_EU868 LORAMAC_REGION_US915 LORAMAC_REGION_CN779 + LORAMAC_REGION_EU433 LORAMAC_REGION_AU915 LORAMAC_REGION_AS923 LORAMAC_REGION_CN470 + LORAMAC_REGION_KR920 LORAMAC_REGION_IN865 LORAMAC_REGION_RU864 +) +set(ACTIVE_REGION LORAMAC_REGION_EU868 CACHE STRING "Default active region is EU868") +set_property(CACHE ACTIVE_REGION PROPERTY STRINGS ${ACTIVE_REGION_LIST}) + +if((SUB_PROJECT STREQUAL periodic-uplink-lpp OR SUB_PROJECT STREQUAL fuota-test-01) AND NOT CLASSB_ENABLED ) + message(FATAL_ERROR "Please turn on Class B support of LoRaMac ( CLASSB_ENABLED=ON ) to use periodic-uplink-lpp, fuota-test-01 sub projects") +endif() + +# Allow selection of secure-element provisioning method +option(SECURE_ELEMENT_PRE_PROVISIONED "Secure-element pre-provisioning" ON) + +if(SUB_PROJECT STREQUAL periodic-uplink-lpp) + + #--------------------------------------------------------------------------------------- + # Application common features handling + #--------------------------------------------------------------------------------------- + list(APPEND ${PROJECT_NAME}_COMMON + "${CMAKE_CURRENT_LIST_DIR}/common/CayenneLpp.c" + "${CMAKE_CURRENT_LIST_DIR}/common/cli.c" + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandlerMsgDisplay.c" + "${CMAKE_CURRENT_LIST_DIR}/common/NvmDataMgmt.c" + ) + + #--------------------------------------------------------------------------------------- + # Application LoRaMac handler + #--------------------------------------------------------------------------------------- + list(APPEND ${PROJECT_NAME}_LMH + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/LmHandler.c" + ) + + #--------------------------------------------------------------------------------------- + # LoRaMac handler applicative packages + #--------------------------------------------------------------------------------------- + list(APPEND ${PROJECT_NAME}_LMHP + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/FragDecoder.c" + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpClockSync.c" + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpCompliance.c" + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpFragmentation.c" + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpRemoteMcastSetup.c" + ) + +elseif(SUB_PROJECT STREQUAL fuota-test-01) + + #--------------------------------------------------------------------------------------- + # Application common features handling + #--------------------------------------------------------------------------------------- + list(APPEND ${PROJECT_NAME}_COMMON + "${CMAKE_CURRENT_LIST_DIR}/common/cli.c" + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandlerMsgDisplay.c" + "${CMAKE_CURRENT_LIST_DIR}/common/NvmDataMgmt.c" + ) + + #--------------------------------------------------------------------------------------- + # Application LoRaMac handler + #--------------------------------------------------------------------------------------- + list(APPEND ${PROJECT_NAME}_LMH + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/LmHandler.c" + ) + + #--------------------------------------------------------------------------------------- + # LoRaMac handler applicative packages + #--------------------------------------------------------------------------------------- + list(APPEND ${PROJECT_NAME}_LMHP + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/FragDecoder.c" + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpClockSync.c" + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpCompliance.c" + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpFragmentation.c" + "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpRemoteMcastSetup.c" + ) + +else() + message(FATAL_ERROR "Unknown SUB_PROJECT") +endif() + +#--------------------------------------------------------------------------------------- +# Application +#--------------------------------------------------------------------------------------- +file(GLOB ${PROJECT_NAME}_SOURCES "${CMAKE_CURRENT_LIST_DIR}/${SUB_PROJECT}/${BOARD}/*.c") + +add_executable(${PROJECT_NAME}-${SUB_PROJECT} + ${${PROJECT_NAME}_COMMON} + ${${PROJECT_NAME}_LMH} + ${${PROJECT_NAME}_LMHP} + ${${PROJECT_NAME}_SOURCES} + $ + $ + $ + $ + $ +) + +target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE $<$:LORAMAC_CLASSB_ENABLED>) +target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE ACTIVE_REGION=${ACTIVE_REGION}) +if(${SECURE_ELEMENT_PRE_PROVISIONED} MATCHES ON) + target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE -DSECURE_ELEMENT_PRE_PROVISIONED) +endif() +if(${SECURE_ELEMENT} MATCHES SOFT_SE) + target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE -DSOFT_SE) +endif() +target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PUBLIC + $> +) + +target_include_directories(${PROJECT_NAME}-${SUB_PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/common + ${CMAKE_CURRENT_SOURCE_DIR}/common/LmHandler + ${CMAKE_CURRENT_SOURCE_DIR}/common/LmHandler/packages + ${CMAKE_CURRENT_SOURCE_DIR}/${SUB_PROJECT}/${BOARD} + $> + $> + $> + $> + $> +) + +set_property(TARGET ${PROJECT_NAME}-${SUB_PROJECT} PROPERTY C_STANDARD 11) + +target_link_libraries(${PROJECT_NAME}-${SUB_PROJECT} m) + +#--------------------------------------------------------------------------------------- +# Debugging and Binutils +#--------------------------------------------------------------------------------------- + +include(gdb-helper) +include(binutils-arm-none-eabi) + +# Generate debugger configurations +generate_run_gdb_stlink(${PROJECT_NAME}-${SUB_PROJECT}) +generate_run_gdb_openocd(${PROJECT_NAME}-${SUB_PROJECT}) +generate_vscode_launch_openocd(${PROJECT_NAME}-${SUB_PROJECT}) + +# Print section sizes of target +print_section_sizes(${PROJECT_NAME}-${SUB_PROJECT}) + +# Create output in hex and binary format +create_bin_output(${PROJECT_NAME}-${SUB_PROJECT}) +create_hex_output(${PROJECT_NAME}-${SUB_PROJECT}) diff --git a/src/apps/LoRaMac/fuota-test-01/B-L072Z-LRWAN1/main.c b/src/apps/LoRaMac/fuota-test-01/B-L072Z-LRWAN1/main.c index 9ae56fb26..296117ae8 100644 --- a/src/apps/LoRaMac/fuota-test-01/B-L072Z-LRWAN1/main.c +++ b/src/apps/LoRaMac/fuota-test-01/B-L072Z-LRWAN1/main.c @@ -318,7 +318,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "fuota-test-01", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/fuota-test-01/NAMote72/main.c b/src/apps/LoRaMac/fuota-test-01/NAMote72/main.c index b656382ae..3d4b42a60 100644 --- a/src/apps/LoRaMac/fuota-test-01/NAMote72/main.c +++ b/src/apps/LoRaMac/fuota-test-01/NAMote72/main.c @@ -307,7 +307,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "fuota-test-01", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/fuota-test-01/NucleoL073/main.c b/src/apps/LoRaMac/fuota-test-01/NucleoL073/main.c index 9aa933bd0..210247223 100644 --- a/src/apps/LoRaMac/fuota-test-01/NucleoL073/main.c +++ b/src/apps/LoRaMac/fuota-test-01/NucleoL073/main.c @@ -303,7 +303,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "fuota-test-01", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/fuota-test-01/NucleoL152/main.c b/src/apps/LoRaMac/fuota-test-01/NucleoL152/main.c index c4ca731f0..175afab50 100644 --- a/src/apps/LoRaMac/fuota-test-01/NucleoL152/main.c +++ b/src/apps/LoRaMac/fuota-test-01/NucleoL152/main.c @@ -303,7 +303,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "fuota-test-01", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/fuota-test-01/NucleoL476/main.c b/src/apps/LoRaMac/fuota-test-01/NucleoL476/main.c index ae2b5a55a..2f0f0d814 100644 --- a/src/apps/LoRaMac/fuota-test-01/NucleoL476/main.c +++ b/src/apps/LoRaMac/fuota-test-01/NucleoL476/main.c @@ -303,7 +303,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "fuota-test-01", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/fuota-test-01/SAMR34/main.c b/src/apps/LoRaMac/fuota-test-01/SAMR34/main.c index 060b14db6..b6836b796 100644 --- a/src/apps/LoRaMac/fuota-test-01/SAMR34/main.c +++ b/src/apps/LoRaMac/fuota-test-01/SAMR34/main.c @@ -276,7 +276,7 @@ int main( void ) TimerSetValue( &Led1Timer, 100 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "fuota-test-01", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/fuota-test-01/SKiM880B/main.c b/src/apps/LoRaMac/fuota-test-01/SKiM880B/main.c index e34866e45..38850e90d 100644 --- a/src/apps/LoRaMac/fuota-test-01/SKiM880B/main.c +++ b/src/apps/LoRaMac/fuota-test-01/SKiM880B/main.c @@ -291,7 +291,7 @@ int main( void ) TimerSetValue( &Led2Timer, 100 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "fuota-test-01", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/fuota-test-01/SKiM881AXL/main.c b/src/apps/LoRaMac/fuota-test-01/SKiM881AXL/main.c index eeb23734d..99234e1c4 100644 --- a/src/apps/LoRaMac/fuota-test-01/SKiM881AXL/main.c +++ b/src/apps/LoRaMac/fuota-test-01/SKiM881AXL/main.c @@ -291,7 +291,7 @@ int main( void ) TimerSetValue( &Led2Timer, 100 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "fuota-test-01", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/fuota-test-01/SKiM980A/main.c b/src/apps/LoRaMac/fuota-test-01/SKiM980A/main.c index cb69cf692..80da7b068 100644 --- a/src/apps/LoRaMac/fuota-test-01/SKiM980A/main.c +++ b/src/apps/LoRaMac/fuota-test-01/SKiM980A/main.c @@ -291,7 +291,7 @@ int main( void ) TimerSetValue( &Led2Timer, 100 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "fuota-test-01", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.c b/src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.c index 35d7ed936..87fa7b2b6 100644 --- a/src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.c +++ b/src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.c @@ -273,7 +273,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "periodic-uplink-lpp", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/periodic-uplink-lpp/NAMote72/main.c b/src/apps/LoRaMac/periodic-uplink-lpp/NAMote72/main.c index 3f0fd8d87..a91109111 100644 --- a/src/apps/LoRaMac/periodic-uplink-lpp/NAMote72/main.c +++ b/src/apps/LoRaMac/periodic-uplink-lpp/NAMote72/main.c @@ -262,7 +262,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "periodic-uplink-lpp", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL073/main.c b/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL073/main.c index 504587eb2..174fd9128 100644 --- a/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL073/main.c +++ b/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL073/main.c @@ -258,7 +258,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "periodic-uplink-lpp", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL152/main.c b/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL152/main.c index bcae7c1f4..ccad774f0 100644 --- a/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL152/main.c +++ b/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL152/main.c @@ -258,7 +258,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "periodic-uplink-lpp", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL476/main.c b/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL476/main.c index e46300d75..a23306b69 100644 --- a/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL476/main.c +++ b/src/apps/LoRaMac/periodic-uplink-lpp/NucleoL476/main.c @@ -258,7 +258,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "periodic-uplink-lpp", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/periodic-uplink-lpp/SAMR34/main.c b/src/apps/LoRaMac/periodic-uplink-lpp/SAMR34/main.c index 6d2307418..d495631a2 100644 --- a/src/apps/LoRaMac/periodic-uplink-lpp/SAMR34/main.c +++ b/src/apps/LoRaMac/periodic-uplink-lpp/SAMR34/main.c @@ -257,7 +257,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "periodic-uplink-lpp", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/periodic-uplink-lpp/SKiM880B/main.c b/src/apps/LoRaMac/periodic-uplink-lpp/SKiM880B/main.c index 7a4b6cf1a..7accdd7ab 100644 --- a/src/apps/LoRaMac/periodic-uplink-lpp/SKiM880B/main.c +++ b/src/apps/LoRaMac/periodic-uplink-lpp/SKiM880B/main.c @@ -259,7 +259,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "periodic-uplink-lpp", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/periodic-uplink-lpp/SKiM881AXL/main.c b/src/apps/LoRaMac/periodic-uplink-lpp/SKiM881AXL/main.c index bfb9db7f0..832f1a191 100644 --- a/src/apps/LoRaMac/periodic-uplink-lpp/SKiM881AXL/main.c +++ b/src/apps/LoRaMac/periodic-uplink-lpp/SKiM881AXL/main.c @@ -259,7 +259,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "periodic-uplink-lpp", &appVersion, &gitHubVersion ); diff --git a/src/apps/LoRaMac/periodic-uplink-lpp/SKiM980A/main.c b/src/apps/LoRaMac/periodic-uplink-lpp/SKiM980A/main.c index c24b8c521..723ad4b48 100644 --- a/src/apps/LoRaMac/periodic-uplink-lpp/SKiM980A/main.c +++ b/src/apps/LoRaMac/periodic-uplink-lpp/SKiM980A/main.c @@ -259,7 +259,7 @@ int main( void ) TimerSetValue( &LedBeaconTimer, 5000 ); const Version_t appVersion = { .Fields.Major = 1, .Fields.Minor = 0, .Fields.Patch = 0 }; - const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 5 }; + const Version_t gitHubVersion = { .Fields.Major = 4, .Fields.Minor = 4, .Fields.Patch = 7 }; DisplayAppInfo( "periodic-uplink-lpp", &appVersion, &gitHubVersion ); diff --git a/src/mac/CMakeLists.txt b/src/mac/CMakeLists.txt index d1e278e1a..c548e633b 100644 --- a/src/mac/CMakeLists.txt +++ b/src/mac/CMakeLists.txt @@ -1,113 +1,114 @@ -## -## ______ _ -## / _____) _ | | -## ( (____ _____ ____ _| |_ _____ ____| |__ -## \____ \| ___ | (_ _) ___ |/ ___) _ \ -## _____) ) ____| | | || |_| ____( (___| | | | -## (______/|_____)_|_|_| \__)_____)\____)_| |_| -## (C)2013-2017 Semtech -## ___ _____ _ ___ _ _____ ___ ___ ___ ___ -## / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| -## \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| -## |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| -## embedded.connectivity.solutions.============== -## -## License: Revised BSD License, see LICENSE.TXT file included in the project -## Authors: Johannes Bruder (STACKFORCE), Miguel Luis (Semtech) -## -project(mac) -cmake_minimum_required(VERSION 3.6) - -#--------------------------------------------------------------------------------------- -# Options -#--------------------------------------------------------------------------------------- - -# Allow selection of region -option(REGION_EU868 "Region EU868" ON) -option(REGION_US915 "Region US915" OFF) -option(REGION_CN779 "Region CN779" OFF) -option(REGION_EU433 "Region EU433" OFF) -option(REGION_AU915 "Region AU915" OFF) -option(REGION_AS923 "Region AS923" OFF) -option(REGION_CN470 "Region CN470" OFF) -option(REGION_KR920 "Region KR920" OFF) -option(REGION_IN865 "Region IN865" OFF) -option(REGION_RU864 "Region RU864" OFF) -set(REGION_LIST REGION_EU868 REGION_US915 REGION_CN779 REGION_EU433 REGION_AU915 REGION_AS923 REGION_CN470 REGION_KR920 REGION_IN865 REGION_RU864) - -# AS923 Channel Plan -set(REGION_AS923_DEFAULT_CHANNEL_PLAN_LIST CHANNEL_PLAN_GROUP_AS923_1, CHANNEL_PLAN_GROUP_AS923_2, CHANNEL_PLAN_GROUP_AS923_3, CHANNEL_PLAN_GROUP_AS923_1_JP) -set(REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1 CACHE STRING "Default channel plan for AS923 is CHANNEL_PLAN_GROUP_AS923_1") -set_property(CACHE REGION_AS923_DEFAULT_CHANNEL_PLAN PROPERTY STRINGS ${REGION_AS923_DEFAULT_CHANNEL_PLAN_LIST}) - -#--------------------------------------------------------------------------------------- -# Target -#--------------------------------------------------------------------------------------- -set( MAC_BUILD_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionAS923.c - ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionCN779.c - ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionEU433.c - ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionEU868.c - ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionIN865.c - ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionRU864.c - ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionBaseUS.c - ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionCommon.c - ${CMAKE_CURRENT_SOURCE_DIR}/region/Region.c - ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMac.c - ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacAdr.c - ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacClassB.c - ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacCommands.c - ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacConfirmQueue.c - ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacCrypto.c - ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacParser.c - ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacSerializer.c ) - -if(REGION_US915 STREQUAL ON) -set( MAC_BUILD_SOURCES - ${MAC_BUILD_SOURCES} - "${CMAKE_CURRENT_SOURCE_DIR}/region/RegionUS915.c" ) -endif() - -if(REGION_AU915 STREQUAL ON) -set( MAC_BUILD_SOURCES - ${MAC_BUILD_SOURCES} - "${CMAKE_CURRENT_SOURCE_DIR}/region/RegionAU915.c" ) -endif() - -if(REGION_CN470 STREQUAL ON) -set( MAC_BUILD_SOURCES - ${MAC_BUILD_SOURCES} - "${CMAKE_CURRENT_SOURCE_DIR}/region/RegionCN470.c" ) -endif() - -add_library(${PROJECT_NAME} OBJECT EXCLUDE_FROM_ALL ${MAC_BUILD_SOURCES}) - -# Loops through all regions and add compile time definitions for the enabled ones. -foreach( REGION ${REGION_LIST} ) - if(${REGION}) - target_compile_definitions(${PROJECT_NAME} PUBLIC -D"${REGION}") - endif() -endforeach() - -# Applies AS923 channel plan -target_compile_definitions(${PROJECT_NAME} PRIVATE -DREGION_AS923_DEFAULT_CHANNEL_PLAN=${REGION_AS923_DEFAULT_CHANNEL_PLAN}) - -# Add define if class B is supported -target_compile_definitions(${PROJECT_NAME} PRIVATE $<$:LORAMAC_CLASSB_ENABLED>) - -# SecureElement NVM -if(${SECURE_ELEMENT} MATCHES SOFT_SE) - target_compile_definitions(${PROJECT_NAME} PRIVATE -DSOFT_SE) -endif() - -add_dependencies(${PROJECT_NAME} board) - -target_include_directories( ${PROJECT_NAME} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/region - $ - $ - $ -) - -set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) +## +## ______ _ +## / _____) _ | | +## ( (____ _____ ____ _| |_ _____ ____| |__ +## \____ \| ___ | (_ _) ___ |/ ___) _ \ +## _____) ) ____| | | || |_| ____( (___| | | | +## (______/|_____)_|_|_| \__)_____)\____)_| |_| +## (C)2013-2017 Semtech +## ___ _____ _ ___ _ _____ ___ ___ ___ ___ +## / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| +## \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| +## |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| +## embedded.connectivity.solutions.============== +## +## License: Revised BSD License, see LICENSE.TXT file included in the project +## Authors: Johannes Bruder (STACKFORCE), Miguel Luis (Semtech) +## +project(mac) +cmake_minimum_required(VERSION 3.6) + +#--------------------------------------------------------------------------------------- +# Options +#--------------------------------------------------------------------------------------- + +# Allow selection of region +option(REGION_EU868 "Region EU868" ON) +option(REGION_US915 "Region US915" OFF) +option(REGION_CN779 "Region CN779" OFF) +option(REGION_EU433 "Region EU433" OFF) +option(REGION_AU915 "Region AU915" OFF) +option(REGION_AS923 "Region AS923" OFF) +option(REGION_CN470 "Region CN470" OFF) +option(REGION_KR920 "Region KR920" OFF) +option(REGION_IN865 "Region IN865" OFF) +option(REGION_RU864 "Region RU864" OFF) +set(REGION_LIST REGION_EU868 REGION_US915 REGION_CN779 REGION_EU433 REGION_AU915 REGION_AS923 REGION_CN470 REGION_KR920 REGION_IN865 REGION_RU864) + +# AS923 Channel Plan +set(REGION_AS923_DEFAULT_CHANNEL_PLAN_LIST CHANNEL_PLAN_GROUP_AS923_1, CHANNEL_PLAN_GROUP_AS923_2, CHANNEL_PLAN_GROUP_AS923_3, CHANNEL_PLAN_GROUP_AS923_1_JP) +set(REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1 CACHE STRING "Default channel plan for AS923 is CHANNEL_PLAN_GROUP_AS923_1") +set_property(CACHE REGION_AS923_DEFAULT_CHANNEL_PLAN PROPERTY STRINGS ${REGION_AS923_DEFAULT_CHANNEL_PLAN_LIST}) + +#--------------------------------------------------------------------------------------- +# Target +#--------------------------------------------------------------------------------------- +set( MAC_BUILD_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionAS923.c + ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionCN779.c + ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionEU433.c + ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionEU868.c + ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionIN865.c + ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionKR920.c + ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionRU864.c + ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionBaseUS.c + ${CMAKE_CURRENT_SOURCE_DIR}/region/RegionCommon.c + ${CMAKE_CURRENT_SOURCE_DIR}/region/Region.c + ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMac.c + ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacAdr.c + ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacClassB.c + ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacCommands.c + ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacConfirmQueue.c + ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacCrypto.c + ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacParser.c + ${CMAKE_CURRENT_SOURCE_DIR}/LoRaMacSerializer.c ) + +if(REGION_US915 STREQUAL ON) +set( MAC_BUILD_SOURCES + ${MAC_BUILD_SOURCES} + "${CMAKE_CURRENT_SOURCE_DIR}/region/RegionUS915.c" ) +endif() + +if(REGION_AU915 STREQUAL ON) +set( MAC_BUILD_SOURCES + ${MAC_BUILD_SOURCES} + "${CMAKE_CURRENT_SOURCE_DIR}/region/RegionAU915.c" ) +endif() + +if(REGION_CN470 STREQUAL ON) +set( MAC_BUILD_SOURCES + ${MAC_BUILD_SOURCES} + "${CMAKE_CURRENT_SOURCE_DIR}/region/RegionCN470.c" ) +endif() + +add_library(${PROJECT_NAME} OBJECT EXCLUDE_FROM_ALL ${MAC_BUILD_SOURCES}) + +# Loops through all regions and add compile time definitions for the enabled ones. +foreach( REGION ${REGION_LIST} ) + if(${REGION}) + target_compile_definitions(${PROJECT_NAME} PUBLIC -D"${REGION}") + endif() +endforeach() + +# Applies AS923 channel plan +target_compile_definitions(${PROJECT_NAME} PRIVATE -DREGION_AS923_DEFAULT_CHANNEL_PLAN=${REGION_AS923_DEFAULT_CHANNEL_PLAN}) + +# Add define if class B is supported +target_compile_definitions(${PROJECT_NAME} PRIVATE $<$:LORAMAC_CLASSB_ENABLED>) + +# SecureElement NVM +if(${SECURE_ELEMENT} MATCHES SOFT_SE) + target_compile_definitions(${PROJECT_NAME} PRIVATE -DSOFT_SE) +endif() + +add_dependencies(${PROJECT_NAME} board) + +target_include_directories( ${PROJECT_NAME} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/region + $ + $ + $ +) + +set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) diff --git a/src/mac/LoRaMac.h b/src/mac/LoRaMac.h index dc6209cf9..7b40d6a11 100644 --- a/src/mac/LoRaMac.h +++ b/src/mac/LoRaMac.h @@ -575,15 +575,15 @@ typedef struct sLoRaMacNvmDataGroup1 typedef struct sLoRaMacNvmDataGroup2 { - /* + /*! * LoRaMac region. */ LoRaMacRegion_t Region; - /* + /*! * LoRaMac parameters */ LoRaMacParams_t MacParams; - /* + /*! * LoRaMac default parameters */ LoRaMacParams_t MacParamsDefaults; @@ -595,11 +595,11 @@ typedef struct sLoRaMacNvmDataGroup2 * Channels data rate */ int8_t ChannelsDatarateDefault; - /* + /*! * Network ID ( 3 bytes ) */ uint32_t NetID; - /* + /*! * Mote Address */ uint32_t DevAddr; @@ -607,11 +607,11 @@ typedef struct sLoRaMacNvmDataGroup2 * Multicast channel list */ MulticastCtx_t MulticastChannelList[LORAMAC_MAX_MC_CTX]; - /* + /*! * Actual device class */ DeviceClass_t DeviceClass; - /* + /*! * Indicates if the node is connected to * a private or public network */ @@ -620,30 +620,30 @@ typedef struct sLoRaMacNvmDataGroup2 * LoRaMac ADR control status */ bool AdrCtrlOn; - /* + /*! * Maximum duty cycle * \remark Possibility to shutdown the device. */ uint8_t MaxDCycle; - /* - * Enables/Disables duty cycle management (Test only) - */ + /*! + * Enables/Disables duty cycle management (Test only) + */ bool DutyCycleOn; - /* + /*! * Aggregated duty cycle management */ uint16_t AggregatedDCycle; - /* - * Stores the time at LoRaMac initialization. - * - * \remark Used for the BACKOFF_DC computation. - */ + /*! + * Stores the time at LoRaMac initialization. + * + * \remark Used for the BACKOFF_DC computation. + */ SysTime_t InitializationTime; - /* + /*! * Current LoRaWAN Version */ Version_t Version; - /* + /*! * End-Device network activation */ ActivationType_t NetworkActivation; diff --git a/src/mac/region/RegionRU864.h b/src/mac/region/RegionRU864.h index fb5193acf..d704639e6 100644 --- a/src/mac/region/RegionRU864.h +++ b/src/mac/region/RegionRU864.h @@ -1,447 +1,447 @@ -/*! - * \file RegionRU864.h - * - * \brief Region definition for RU864 - * - * \copyright Revised BSD License, see section \ref LICENSE. - * - * \code - * ______ _ - * / _____) _ | | - * ( (____ _____ ____ _| |_ _____ ____| |__ - * \____ \| ___ | (_ _) ___ |/ ___) _ \ - * _____) ) ____| | | || |_| ____( (___| | | | - * (______/|_____)_|_|_| \__)_____)\____)_| |_| - * (C)2013-2017 Semtech - * - * ___ _____ _ ___ _ _____ ___ ___ ___ ___ - * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| - * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| - * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| - * embedded.connectivity.solutions=============== - * - * \endcode - * - * \author Miguel Luis ( Semtech ) - * - * \author Gregory Cristian ( Semtech ) - * - * \author Daniel Jaeckle ( STACKFORCE ) - * - * \defgroup REGIONRU864 Region RU864 - * Implementation according to LoRaWAN Specification v1.0.2. - * \{ - */ -#ifndef __REGION_RU864_H__ -#define __REGION_RU864_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "LoRaMac.h" - -/*! - * LoRaMac maximum number of channels - */ -#define RU864_MAX_NB_CHANNELS 8 - -/*! - * Number of default channels - */ -#define RU864_NUMB_DEFAULT_CHANNELS 2 - -/*! - * Number of channels to apply for the CF list - */ -#define RU864_NUMB_CHANNELS_CF_LIST 5 - -/*! - * Minimal datarate that can be used by the node - */ -#define RU864_TX_MIN_DATARATE DR_0 - -/*! - * Maximal datarate that can be used by the node - */ -#define RU864_TX_MAX_DATARATE DR_7 - -/*! - * Minimal datarate that can be used by the node - */ -#define RU864_RX_MIN_DATARATE DR_0 - -/*! - * Maximal datarate that can be used by the node - */ -#define RU864_RX_MAX_DATARATE DR_7 - -/*! - * Default datarate used by the node - */ -#define RU864_DEFAULT_DATARATE DR_0 - -/*! - * Minimal Rx1 receive datarate offset - */ -#define RU864_MIN_RX1_DR_OFFSET 0 - -/*! - * Maximal Rx1 receive datarate offset - */ -#define RU864_MAX_RX1_DR_OFFSET 5 - -/*! - * Minimal Tx output power that can be used by the node - */ -#define RU864_MIN_TX_POWER TX_POWER_7 - -/*! - * Maximal Tx output power that can be used by the node - */ -#define RU864_MAX_TX_POWER TX_POWER_0 - -/*! - * Default Tx output power used by the node - */ -#define RU864_DEFAULT_TX_POWER TX_POWER_0 - -/*! - * Default Max EIRP - */ -#define RU864_DEFAULT_MAX_EIRP 16.0f - -/*! - * Default antenna gain - */ -#define RU864_DEFAULT_ANTENNA_GAIN 2.15f - -/*! - * Enabled or disabled the duty cycle - */ -#define RU864_DUTY_CYCLE_ENABLED 1 - -/*! - * Maximum RX window duration - */ -#define RU864_MAX_RX_WINDOW 3000 //TODO - -#if ( RU864_DEFAULT_DATARATE > DR_5 ) -#error "A default DR higher than DR_5 may lead to connectivity loss." -#endif - -/*! - * Second reception window channel frequency definition. - */ -#define RU864_RX_WND_2_FREQ 869100000 - -/*! - * Second reception window channel datarate definition. - */ -#define RU864_RX_WND_2_DR DR_0 - -/*! - * Default uplink dwell time configuration - */ -#define RU864_DEFAULT_UPLINK_DWELL_TIME 0 - -/* - * CLASS B - */ -/*! - * Beacon frequency - */ -#define RU864_BEACON_CHANNEL_FREQ 869100000 - -/*! - * Ping slot channel frequency - */ -#define RU864_PING_SLOT_CHANNEL_FREQ 868900000 - -/*! - * Payload size of a beacon frame - */ -#define RU864_BEACON_SIZE 17 - -/*! - * Size of RFU 1 field - */ -#define RU864_RFU1_SIZE 2 - -/*! - * Size of RFU 2 field - */ -#define RU864_RFU2_SIZE 0 - -/*! - * Datarate of the beacon channel - */ -#define RU864_BEACON_CHANNEL_DR DR_3 - -/*! - * Bandwith of the beacon channel (Index of BandwidthsRU864[]) - */ -#define RU864_BEACON_CHANNEL_BW 0 - -/*! - * Datarate of the ping slot channel - */ -#define RU864_PING_SLOT_CHANNEL_DR DR_3 - -/*! - * Maximum number of bands - */ -#define RU864_MAX_NB_BANDS 1 - -/*! - * Band 0 definition - * Band = { DutyCycle, TxMaxPower, LastBandUpdateTime, LastMaxCreditAssignTime, TimeCredits, MaxTimeCredits, ReadyForTransmission } - */ -#define RU864_BAND0 { 100 , RU864_MAX_TX_POWER, 0, 0, 0, 0, 0 } // 1.0 % - -/*! - * LoRaMac default channel 1 - * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } - */ -#define RU864_LC1 { 868900000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } - -/*! - * LoRaMac default channel 2 - * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } - */ -#define RU864_LC2 { 869100000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } - - -/*! - * LoRaMac channels which are allowed for the join procedure - */ -#define RU864_JOIN_CHANNELS ( uint16_t )( LC( 1 ) | LC( 2 ) ) - -/*! - * Data rates table definition - */ -static const uint8_t DataratesRU864[] = { 12, 11, 10, 9, 8, 7, 7, 50 }; - -/*! - * Bandwidths table definition in Hz - */ -static const uint32_t BandwidthsRU864[] = { 125000, 125000, 125000, 125000, 125000, 125000, 250000, 0 }; - -/*! - * Maximum payload with respect to the datarate index. - */ -static const uint8_t MaxPayloadOfDatarateRU864[] = { 51, 51, 51, 115, 242, 242, 242, 242 }; - -/*! - * \brief The function gets a value of a specific phy attribute. - * - * \param [IN] getPhy Pointer to the function parameters. - * - * \retval Returns a structure containing the PHY parameter. - */ -PhyParam_t RegionRU864GetPhyParam( GetPhyParams_t* getPhy ); - -/*! - * \brief Updates the last TX done parameters of the current channel. - * - * \param [IN] txDone Pointer to the function parameters. - */ -void RegionRU864SetBandTxDone( SetBandTxDoneParams_t* txDone ); - -/*! - * \brief Initializes the channels masks and the channels. - * - * \param [IN] type Sets the initialization type. - */ -void RegionRU864InitDefaults( InitDefaultsParams_t* params ); - -/*! - * \brief Verifies a parameter. - * - * \param [IN] verify Pointer to the function parameters. - * - * \param [IN] type Sets the initialization type. - * - * \retval Returns true, if the parameter is valid. - */ -bool RegionRU864Verify( VerifyParams_t* verify, PhyAttribute_t phyAttribute ); - -/*! - * \brief The function parses the input buffer and sets up the channels of the - * CF list. - * - * \param [IN] applyCFList Pointer to the function parameters. - */ -void RegionRU864ApplyCFList( ApplyCFListParams_t* applyCFList ); - -/*! - * \brief Sets a channels mask. - * - * \param [IN] chanMaskSet Pointer to the function parameters. - * - * \retval Returns true, if the channels mask could be set. - */ -bool RegionRU864ChanMaskSet( ChanMaskSetParams_t* chanMaskSet ); - -/*! - * Computes the Rx window timeout and offset. - * - * \param [IN] datarate Rx window datarate index to be used - * - * \param [IN] minRxSymbols Minimum required number of symbols to detect an Rx frame. - * - * \param [IN] rxError System maximum timing error of the receiver. In milliseconds - * The receiver will turn on in a [-rxError : +rxError] ms - * interval around RxOffset - * - * \param [OUT]rxConfigParams Returns updated WindowTimeout and WindowOffset fields. - */ -void RegionRU864ComputeRxWindowParameters( int8_t datarate, uint8_t minRxSymbols, uint32_t rxError, RxConfigParams_t *rxConfigParams ); - -/*! - * \brief Configuration of the RX windows. - * - * \param [IN] rxConfig Pointer to the function parameters. - * - * \param [OUT] datarate The datarate index which was set. - * - * \retval Returns true, if the configuration was applied successfully. - */ -bool RegionRU864RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ); - -/*! - * \brief TX configuration. - * - * \param [IN] txConfig Pointer to the function parameters. - * - * \param [OUT] txPower The tx power index which was set. - * - * \param [OUT] txTimeOnAir The time-on-air of the frame. - * - * \retval Returns true, if the configuration was applied successfully. - */ -bool RegionRU864TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime_t* txTimeOnAir ); - -/*! - * \brief The function processes a Link ADR Request. - * - * \param [IN] linkAdrReq Pointer to the function parameters. - * - * \retval Returns the status of the operation, according to the LoRaMAC specification. - */ -uint8_t RegionRU864LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed ); - -/*! - * \brief The function processes a RX Parameter Setup Request. - * - * \param [IN] rxParamSetupReq Pointer to the function parameters. - * - * \retval Returns the status of the operation, according to the LoRaMAC specification. - */ -uint8_t RegionRU864RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq ); - -/*! - * \brief The function processes a Channel Request. - * - * \param [IN] newChannelReq Pointer to the function parameters. - * - * \retval Returns the status of the operation, according to the LoRaMAC specification. - */ -int8_t RegionRU864NewChannelReq( NewChannelReqParams_t* newChannelReq ); - -/*! - * \brief The function processes a TX ParamSetup Request. - * - * \param [IN] txParamSetupReq Pointer to the function parameters. - * - * \retval Returns the status of the operation, according to the LoRaMAC specification. - * Returns -1, if the functionality is not implemented. In this case, the end node - * shall not process the command. - */ -int8_t RegionRU864TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq ); - -/*! - * \brief The function processes a DlChannel Request. - * - * \param [IN] dlChannelReq Pointer to the function parameters. - * - * \retval Returns the status of the operation, according to the LoRaMAC specification. - */ -int8_t RegionRU864DlChannelReq( DlChannelReqParams_t* dlChannelReq ); - -/*! - * \brief Alternates the datarate of the channel for the join request. - * - * \param [IN] currentDr Current datarate. - * - * \retval Datarate to apply. - */ -int8_t RegionRU864AlternateDr( int8_t currentDr, AlternateDrType_t type ); - -/*! - * \brief Searches and set the next random available channel - * - * \param [OUT] channel Next channel to use for TX. - * - * \param [OUT] time Time to wait for the next transmission according to the duty - * cycle. - * - * \param [OUT] aggregatedTimeOff Updates the aggregated time off. - * - * \retval Function status [1: OK, 0: Unable to find a channel on the current datarate] - */ -LoRaMacStatus_t RegionRU864NextChannel( NextChanParams_t* nextChanParams, uint8_t* channel, TimerTime_t* time, TimerTime_t* aggregatedTimeOff ); - -/*! - * \brief Adds a channel. - * - * \param [IN] channelAdd Pointer to the function parameters. - * - * \retval Status of the operation. - */ -LoRaMacStatus_t RegionRU864ChannelAdd( ChannelAddParams_t* channelAdd ); - -/*! - * \brief Removes a channel. - * - * \param [IN] channelRemove Pointer to the function parameters. - * - * \retval Returns true, if the channel was removed successfully. - */ -bool RegionRU864ChannelsRemove( ChannelRemoveParams_t* channelRemove ); - -/*! - * \brief Sets the radio into continuous wave mode. - * - * \param [IN] continuousWave Pointer to the function parameters. - */ -void RegionRU864SetContinuousWave( ContinuousWaveParams_t* continuousWave ); - -/*! - * \brief Computes new datarate according to the given offset - * - * \param [IN] downlinkDwellTime Downlink dwell time configuration. 0: No limit, 1: 400ms - * - * \param [IN] dr Current datarate - * - * \param [IN] drOffset Offset to be applied - * - * \retval newDr Computed datarate. - */ -uint8_t RegionRU864ApplyDrOffset( uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset ); - -/*! - * \brief Sets the radio into beacon reception mode - * - * \param [IN] rxBeaconSetup Pointer to the function parameters - */ -void RegionRU864RxBeaconSetup( RxBeaconSetup_t* rxBeaconSetup, uint8_t* outDr ); - -/*! \} defgroup REGIONRU864 */ - -#ifdef __cplusplus -} -#endif - -#endif // __REGION_RU864_H__ +/*! + * \file RegionRU864.h + * + * \brief Region definition for RU864 + * + * \copyright Revised BSD License, see section \ref LICENSE. + * + * \code + * ______ _ + * / _____) _ | | + * ( (____ _____ ____ _| |_ _____ ____| |__ + * \____ \| ___ | (_ _) ___ |/ ___) _ \ + * _____) ) ____| | | || |_| ____( (___| | | | + * (______/|_____)_|_|_| \__)_____)\____)_| |_| + * (C)2013-2017 Semtech + * + * ___ _____ _ ___ _ _____ ___ ___ ___ ___ + * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| + * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| + * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| + * embedded.connectivity.solutions=============== + * + * \endcode + * + * \author Miguel Luis ( Semtech ) + * + * \author Gregory Cristian ( Semtech ) + * + * \author Daniel Jaeckle ( STACKFORCE ) + * + * \defgroup REGIONRU864 Region RU864 + * Implementation according to LoRaWAN Specification v1.0.2. + * \{ + */ +#ifndef __REGION_RU864_H__ +#define __REGION_RU864_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "region/Region.h" + +/*! + * LoRaMac maximum number of channels + */ +#define RU864_MAX_NB_CHANNELS 8 + +/*! + * Number of default channels + */ +#define RU864_NUMB_DEFAULT_CHANNELS 2 + +/*! + * Number of channels to apply for the CF list + */ +#define RU864_NUMB_CHANNELS_CF_LIST 5 + +/*! + * Minimal datarate that can be used by the node + */ +#define RU864_TX_MIN_DATARATE DR_0 + +/*! + * Maximal datarate that can be used by the node + */ +#define RU864_TX_MAX_DATARATE DR_7 + +/*! + * Minimal datarate that can be used by the node + */ +#define RU864_RX_MIN_DATARATE DR_0 + +/*! + * Maximal datarate that can be used by the node + */ +#define RU864_RX_MAX_DATARATE DR_7 + +/*! + * Default datarate used by the node + */ +#define RU864_DEFAULT_DATARATE DR_0 + +/*! + * Minimal Rx1 receive datarate offset + */ +#define RU864_MIN_RX1_DR_OFFSET 0 + +/*! + * Maximal Rx1 receive datarate offset + */ +#define RU864_MAX_RX1_DR_OFFSET 5 + +/*! + * Minimal Tx output power that can be used by the node + */ +#define RU864_MIN_TX_POWER TX_POWER_7 + +/*! + * Maximal Tx output power that can be used by the node + */ +#define RU864_MAX_TX_POWER TX_POWER_0 + +/*! + * Default Tx output power used by the node + */ +#define RU864_DEFAULT_TX_POWER TX_POWER_0 + +/*! + * Default Max EIRP + */ +#define RU864_DEFAULT_MAX_EIRP 16.0f + +/*! + * Default antenna gain + */ +#define RU864_DEFAULT_ANTENNA_GAIN 2.15f + +/*! + * Enabled or disabled the duty cycle + */ +#define RU864_DUTY_CYCLE_ENABLED 1 + +/*! + * Maximum RX window duration + */ +#define RU864_MAX_RX_WINDOW 3000 //TODO + +#if ( RU864_DEFAULT_DATARATE > DR_5 ) +#error "A default DR higher than DR_5 may lead to connectivity loss." +#endif + +/*! + * Second reception window channel frequency definition. + */ +#define RU864_RX_WND_2_FREQ 869100000 + +/*! + * Second reception window channel datarate definition. + */ +#define RU864_RX_WND_2_DR DR_0 + +/*! + * Default uplink dwell time configuration + */ +#define RU864_DEFAULT_UPLINK_DWELL_TIME 0 + +/* + * CLASS B + */ +/*! + * Beacon frequency + */ +#define RU864_BEACON_CHANNEL_FREQ 869100000 + +/*! + * Ping slot channel frequency + */ +#define RU864_PING_SLOT_CHANNEL_FREQ 868900000 + +/*! + * Payload size of a beacon frame + */ +#define RU864_BEACON_SIZE 17 + +/*! + * Size of RFU 1 field + */ +#define RU864_RFU1_SIZE 2 + +/*! + * Size of RFU 2 field + */ +#define RU864_RFU2_SIZE 0 + +/*! + * Datarate of the beacon channel + */ +#define RU864_BEACON_CHANNEL_DR DR_3 + +/*! + * Bandwith of the beacon channel (Index of BandwidthsRU864[]) + */ +#define RU864_BEACON_CHANNEL_BW 0 + +/*! + * Datarate of the ping slot channel + */ +#define RU864_PING_SLOT_CHANNEL_DR DR_3 + +/*! + * Maximum number of bands + */ +#define RU864_MAX_NB_BANDS 1 + +/*! + * Band 0 definition + * Band = { DutyCycle, TxMaxPower, LastBandUpdateTime, LastMaxCreditAssignTime, TimeCredits, MaxTimeCredits, ReadyForTransmission } + */ +#define RU864_BAND0 { 100 , RU864_MAX_TX_POWER, 0, 0, 0, 0, 0 } // 1.0 % + +/*! + * LoRaMac default channel 1 + * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } + */ +#define RU864_LC1 { 868900000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } + +/*! + * LoRaMac default channel 2 + * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } + */ +#define RU864_LC2 { 869100000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } + + +/*! + * LoRaMac channels which are allowed for the join procedure + */ +#define RU864_JOIN_CHANNELS ( uint16_t )( LC( 1 ) | LC( 2 ) ) + +/*! + * Data rates table definition + */ +static const uint8_t DataratesRU864[] = { 12, 11, 10, 9, 8, 7, 7, 50 }; + +/*! + * Bandwidths table definition in Hz + */ +static const uint32_t BandwidthsRU864[] = { 125000, 125000, 125000, 125000, 125000, 125000, 250000, 0 }; + +/*! + * Maximum payload with respect to the datarate index. + */ +static const uint8_t MaxPayloadOfDatarateRU864[] = { 51, 51, 51, 115, 242, 242, 242, 242 }; + +/*! + * \brief The function gets a value of a specific phy attribute. + * + * \param [IN] getPhy Pointer to the function parameters. + * + * \retval Returns a structure containing the PHY parameter. + */ +PhyParam_t RegionRU864GetPhyParam( GetPhyParams_t* getPhy ); + +/*! + * \brief Updates the last TX done parameters of the current channel. + * + * \param [IN] txDone Pointer to the function parameters. + */ +void RegionRU864SetBandTxDone( SetBandTxDoneParams_t* txDone ); + +/*! + * \brief Initializes the channels masks and the channels. + * + * \param [IN] type Sets the initialization type. + */ +void RegionRU864InitDefaults( InitDefaultsParams_t* params ); + +/*! + * \brief Verifies a parameter. + * + * \param [IN] verify Pointer to the function parameters. + * + * \param [IN] type Sets the initialization type. + * + * \retval Returns true, if the parameter is valid. + */ +bool RegionRU864Verify( VerifyParams_t* verify, PhyAttribute_t phyAttribute ); + +/*! + * \brief The function parses the input buffer and sets up the channels of the + * CF list. + * + * \param [IN] applyCFList Pointer to the function parameters. + */ +void RegionRU864ApplyCFList( ApplyCFListParams_t* applyCFList ); + +/*! + * \brief Sets a channels mask. + * + * \param [IN] chanMaskSet Pointer to the function parameters. + * + * \retval Returns true, if the channels mask could be set. + */ +bool RegionRU864ChanMaskSet( ChanMaskSetParams_t* chanMaskSet ); + +/*! + * Computes the Rx window timeout and offset. + * + * \param [IN] datarate Rx window datarate index to be used + * + * \param [IN] minRxSymbols Minimum required number of symbols to detect an Rx frame. + * + * \param [IN] rxError System maximum timing error of the receiver. In milliseconds + * The receiver will turn on in a [-rxError : +rxError] ms + * interval around RxOffset + * + * \param [OUT]rxConfigParams Returns updated WindowTimeout and WindowOffset fields. + */ +void RegionRU864ComputeRxWindowParameters( int8_t datarate, uint8_t minRxSymbols, uint32_t rxError, RxConfigParams_t *rxConfigParams ); + +/*! + * \brief Configuration of the RX windows. + * + * \param [IN] rxConfig Pointer to the function parameters. + * + * \param [OUT] datarate The datarate index which was set. + * + * \retval Returns true, if the configuration was applied successfully. + */ +bool RegionRU864RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ); + +/*! + * \brief TX configuration. + * + * \param [IN] txConfig Pointer to the function parameters. + * + * \param [OUT] txPower The tx power index which was set. + * + * \param [OUT] txTimeOnAir The time-on-air of the frame. + * + * \retval Returns true, if the configuration was applied successfully. + */ +bool RegionRU864TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime_t* txTimeOnAir ); + +/*! + * \brief The function processes a Link ADR Request. + * + * \param [IN] linkAdrReq Pointer to the function parameters. + * + * \retval Returns the status of the operation, according to the LoRaMAC specification. + */ +uint8_t RegionRU864LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed ); + +/*! + * \brief The function processes a RX Parameter Setup Request. + * + * \param [IN] rxParamSetupReq Pointer to the function parameters. + * + * \retval Returns the status of the operation, according to the LoRaMAC specification. + */ +uint8_t RegionRU864RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq ); + +/*! + * \brief The function processes a Channel Request. + * + * \param [IN] newChannelReq Pointer to the function parameters. + * + * \retval Returns the status of the operation, according to the LoRaMAC specification. + */ +int8_t RegionRU864NewChannelReq( NewChannelReqParams_t* newChannelReq ); + +/*! + * \brief The function processes a TX ParamSetup Request. + * + * \param [IN] txParamSetupReq Pointer to the function parameters. + * + * \retval Returns the status of the operation, according to the LoRaMAC specification. + * Returns -1, if the functionality is not implemented. In this case, the end node + * shall not process the command. + */ +int8_t RegionRU864TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq ); + +/*! + * \brief The function processes a DlChannel Request. + * + * \param [IN] dlChannelReq Pointer to the function parameters. + * + * \retval Returns the status of the operation, according to the LoRaMAC specification. + */ +int8_t RegionRU864DlChannelReq( DlChannelReqParams_t* dlChannelReq ); + +/*! + * \brief Alternates the datarate of the channel for the join request. + * + * \param [IN] currentDr Current datarate. + * + * \retval Datarate to apply. + */ +int8_t RegionRU864AlternateDr( int8_t currentDr, AlternateDrType_t type ); + +/*! + * \brief Searches and set the next random available channel + * + * \param [OUT] channel Next channel to use for TX. + * + * \param [OUT] time Time to wait for the next transmission according to the duty + * cycle. + * + * \param [OUT] aggregatedTimeOff Updates the aggregated time off. + * + * \retval Function status [1: OK, 0: Unable to find a channel on the current datarate] + */ +LoRaMacStatus_t RegionRU864NextChannel( NextChanParams_t* nextChanParams, uint8_t* channel, TimerTime_t* time, TimerTime_t* aggregatedTimeOff ); + +/*! + * \brief Adds a channel. + * + * \param [IN] channelAdd Pointer to the function parameters. + * + * \retval Status of the operation. + */ +LoRaMacStatus_t RegionRU864ChannelAdd( ChannelAddParams_t* channelAdd ); + +/*! + * \brief Removes a channel. + * + * \param [IN] channelRemove Pointer to the function parameters. + * + * \retval Returns true, if the channel was removed successfully. + */ +bool RegionRU864ChannelsRemove( ChannelRemoveParams_t* channelRemove ); + +/*! + * \brief Sets the radio into continuous wave mode. + * + * \param [IN] continuousWave Pointer to the function parameters. + */ +void RegionRU864SetContinuousWave( ContinuousWaveParams_t* continuousWave ); + +/*! + * \brief Computes new datarate according to the given offset + * + * \param [IN] downlinkDwellTime Downlink dwell time configuration. 0: No limit, 1: 400ms + * + * \param [IN] dr Current datarate + * + * \param [IN] drOffset Offset to be applied + * + * \retval newDr Computed datarate. + */ +uint8_t RegionRU864ApplyDrOffset( uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset ); + +/*! + * \brief Sets the radio into beacon reception mode + * + * \param [IN] rxBeaconSetup Pointer to the function parameters + */ +void RegionRU864RxBeaconSetup( RxBeaconSetup_t* rxBeaconSetup, uint8_t* outDr ); + +/*! \} defgroup REGIONRU864 */ + +#ifdef __cplusplus +} +#endif + +#endif // __REGION_RU864_H__