You can create your own examples and add them to the compilation for both SEGGER Embedded Studio and CMake. Do this only when you are familiar with the toolchain and how to build the stack and the examples.
The process of adding new examples is composed of the following stages:
my_app
on this page. Replace this name with the name of your application each time it is mentioned.To add folders and the CMakeLists.txt
file for your custom example:
examples
folder of your nRF5 SDK for Mesh installation path, add a new my_app
folder.examples/beaconing
.examples/CMakeLists.txt
file, depending on your platform (see Compatibility):add_subdirectory
command entry. For example: set(WEAK_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/common/src/nrf_mesh_weak.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/src/app_error_weak.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/src/assertion_handler_weak.c" CACHE INTERNAL "") add_subdirectory("common") add_subdirectory("beaconing") add_subdirectory("pb_remote") add_subdirectory("provisioner") add_subdirectory("my_app")
add_subdirectory
command entry in the platform-related if
section. For example: if ((NOT PLATFORM MATCHES "nrf52810") AND (NOT PLATFORM MATCHES "nrf52820")) add_subdirectory("my_app") add_subdirectory("sensor") add_subdirectory("scene") add_subdirectory("light_lightness") add_subdirectory("light_lc") add_subdirectory("light_ctl") add_subdirectory("enocean_switch") add_subdirectory("dimming") add_subdirectory("lpn") add_subdirectory("dfu") add_subdirectory("serial") add_subdirectory("light_switch") endif()
examples/my_app/CMakeLists.txt
file to set(target "my_app")
.When you created custom example folder and CMakeLists.txt file, you also copied the following files used for configuring the application:
nrf_mesh_config_app.h
app_config.h
To define the example configuration:
examples/my_app/CMakeLists.txt
file, add or remove the application support modules based on your needs.include/app_config.h
file to match your application configuration and override the configuration of the nRF5 SDK (see SDK configuration header file).nrf_mesh_config_app.h
file to modify:After defining the configuration, build the example with the following procedure.
The building procedure for custom examples is similar to the standard building procedure, with the following differences:
build $ ninja
build $ ninja my_app
When running the example in CMake-based environment, flash your example with the following command:
build $ ninja flash_my_app