I have developed an application for the nodes in a BT Mesh network. Each node in this network should now have the same code. The only difference for each code is the CONFIG_BT_DEVICE_NAME
symbol, which is different for each node in the network. If this symbol is the same everywhere, the nodes can no longer be distinguished later in the provisioning menu. Each node therefore requires a unique name when flashing with the developed code.
A unique name can be specified in the commen prj.conf within the symbol CONFIG_BT_DEVICE_NAME
(which needs a string). However, this means that the code must be completely recompiled one by one for each node and then flashed to the corresponding node.
The following would be simpler:
- For example, four nodes (
A, B, C, D
) are to be flashed and tested. To do this, four builds: (build_A, build_B, build_C, build_D
) are created. - In each build configuration, the ‘add argument’ command is used to specify the ‘Extra CMaker argument’ =>
-DMY_SERIAL_NUMBER="A"
, next build:-DMY_SERIAL_NUMBER="B"
, … and so on. - The composition of the
BT_DEVICE_NAME
is defined as a concat pre-processor statement somewhere, for example:#define NODE_NAME(NAME) { #NAME, node_ ## NAME }
. - At the end the prj.conf then contains, for example:
CONFIG_BT_DEVICE_NAME=NODE_NAME(MY_SERIAL_NUMBER)
(that won’t work because the symbol really requires a string). - And the result would be: after, for example, further changes have been made to the code, one click on build all configurations is enough and there is a corresponding new HEX to flash for all individually named nodes.
The CMake argument can be added to the build configuration. That is not the problem. The problem is rather to pack this argument into some (zephyr config) file or to another place that can be read by the pre-processor, saved somewhere as a variable and then used by zephyr’s prj.conf. Or is my thought going completely in the wrong direction and you solve this in Zephyr with a completely different approach?
Can something like this be realised via nRF Connect in VS Code using the zephyr framework and CMake?
And if you think it is possible to solve this workaround in the Kconfig file of the project, could you please give me an example of how to start. I couldn’t find an approach in the Zephyrs documentation.
In a similar enquiry there was a suggestion, but it does not really contribute to the solution.
thx for reading and helping in every way
best uli
P.S.: The environment used is VS Code with nrf connect installed. The builds are executed on several nRF52DK boards.
1