Adding BLE multiprotocol to my OT coProcessor NCP app

I'm using nRF Connect SDK v2.1.2 with Visual Studio Code and a nrf52840DK.

I have implemented this app (OpenThread CoProcessor NCP from Zephyr) and it is working correctly. Now I need to add BLE protocol so I checked that the multiprotocol was activated:

I activated the BLE protocol broadcaster:

My problem is when I flash into de board and I cant see the device advertising.

I checked the main.c and this file didnt changed, is the same file as it was before adding BLE.

Should I add the initialization manually? How? 

On the other hand, is this BLE multiprotocol acting like NCP or RCP? Should I communicate with the coProcessor from my host via HCI (If it is RCP) or UART (If it is NCP)? How can I configure it as NCP/RCP?

Parents
  • Hello,

    The Thread: CoAP Client sample demonstrates how you can enable multiprotocol support with Thread and BLE so it should be a good starting point. 

    Building sample with BLE in VS code: 

    Should I add the initialization manually? How? 

    Yes, the BLE stack needs to be enabled from the application. It also needs to configure and start the advertiser like how it's done in the sample here: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/openthread/coap_client/src/ble_utils.c#L136 

    Note: while building the sample here I noticed that the project is referencing a file in the nRF repo using an absolute path, which will cause the build to fail if you change the project path. To fix this, you can replace this line in /coap_client/CMakelist.txt:

    target_include_directories(app PUBLIC ../coap_server/interface)
    with this:
    target_include_directories(app PUBLIC $ENV{ZEPHYR_BASE}/../nrf/samples/openthread/coap_server/interface)
    On the other hand, is this BLE multiprotocol acting like NCP or RCP? Should I communicate with the coProcessor from my host via HCI (If it is RCP) or UART (If it is NCP)? How can I configure it as NCP/RCP?

    Can you say something about your setup and what you want to achieve? E.g. is the NCP part going to be connected to a boarder router, etc? Depending on your requirements, it might be easiest to run Thread/BLE on the nRF as a standalone application and expose a more simplified control interface to the host. 

    Best regards,

    Vidar

  • Hello Vidar,

    I have added the next kconfig fragment in my project:

    And checked every options in "nRF KConfig (build)" that are checked in the coap example about BLE.

    But when I try to compile It shows that the define "CONFIG_BT_NUS" is not defined:

    I see it is defined in the kconfig fragment added:

    ¿Why is it not being defined?

  • [643/839] Building C object CMakeFiles/app.dir/src/ble_utils.c.obj
    FAILED: CMakeFiles/app.dir/src/ble_utils.c.obj 
    C:\ncs\toolchains\v2.1.2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DMBEDTLS_USER_CONFIG_FILE=\"nrf-config-user.h\" -DNRF52840_XXAA -DNRF_802154_ACK_TIMEOUT_ENABLED=1 -DNRF_802154_CCA_CORR_LIMIT_DEFAULT=2 -DNRF_802154_CCA_CORR_THRESHOLD_DEFAULT=45 -DNRF_802154_CCA_ED_THRESHOLD_DEFAULT=45 -DNRF_802154_CCA_MODE_DEFAULT=NRF_RADIO_CCA_MODE_ED -DNRF_802154_ECB_PRIORITY=-1 -DNRF_802154_ENCRYPTION_ENABLED=1 -DNRF_802154_IE_WRITER_ENABLED=1 -DNRF_802154_INTERNAL_RADIO_IRQ_HANDLING=0 -DNRF_802154_PENDING_EXTENDED_ADDRESSES=16 -DNRF_802154_PENDING_SHORT_ADDRESSES=16 -DNRF_802154_RX_BUFFERS=16 -DNRF_802154_SECURITY_WRITER_ENABLED=1 -DNRF_802154_SWI_PRIORITY=1 -DNRF_802154_TX_STARTED_NOTIFY_ENABLED=1 -DNRF_802154_USE_RAW_API=1 -DUSE_PARTITION_MANAGER=0 -D_FORTIFY_SOURCE=2 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/ncs/v2.1.2/nrf/drivers/mpsl/clock_control -IC:/ncs/v2.1.2/zephyr/include/zephyr -IC:/ncs/v2.1.2/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.1.2/zephyr/soc/arm/nordic_nrf/nrf52 -IC:/ncs/v2.1.2/zephyr/lib/libc/newlib/include -IC:/ncs/v2.1.2/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.1.2/zephyr/subsys/bluetooth -IC:/ncs/v2.1.2/zephyr/subsys/settings/include -IC:/ncs/v2.1.2/nrf/include -IC:/ncs/v2.1.2/nrf/lib/multithreading_lock/. -IC:/ncs/v2.1.2/nrf/subsys/bluetooth/controller/. -IC:/ncs/v2.1.2/zephyr/drivers/flash -IC:/ncs/v2.1.2/zephyr/modules/openthread/platform/. -IC:/ncs/v2.1.2/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.1.2/modules/hal/nordic/nrfx -IC:/ncs/v2.1.2/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.1.2/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.1.2/zephyr/modules/hal_nordic/nrfx/. -IC:/ncs/v2.1.2/modules/debug/segger/SEGGER -IC:/ncs/v2.1.2/modules/debug/segger/Config -IC:/ncs/v2.1.2/zephyr/modules/segger/. -IC:/ncs/v2.1.2/modules/crypto/tinycrypt/lib/include -IC:/ncs/v2.1.2/nrfxlib/mpsl/include -IC:/ncs/v2.1.2/nrfxlib/mpsl/include/protocol -IC:/ncs/v2.1.2/nrfxlib/softdevice_controller/include -Imodules/openthread/build/etc/cmake -IC:/ncs/v2.1.2/modules/lib/openthread/etc/cmake -IC:/ncs/v2.1.2/nrfxlib/nrf_802154/driver/include -IC:/ncs/v2.1.2/nrfxlib/nrf_802154/sl/include -Imodules/nrfxlib/nrfxlib/nrf_security/src/include/generated -IC:/ncs/v2.1.2/nrfxlib/nrf_security/include -IC:/ncs/v2.1.2/nrfxlib/nrf_security/include/mbedtls -IC:/ncs/v2.1.2/nrfxlib/nrf_security/include/psa -IC:/ncs/v2.1.2/mbedtls/include -IC:/ncs/v2.1.2/mbedtls/include/mbedtls -IC:/ncs/v2.1.2/mbedtls/include/psa -IC:/ncs/v2.1.2/mbedtls/library -IC:/ncs/v2.1.2/nrfxlib/nrf_security/../crypto/nrf_oberon/include -IC:/ncs/v2.1.2/nrfxlib/nrf_security/../crypto/nrf_oberon/include/mbedtls -IC:/ncs/v2.1.2/nrfxlib/nrf_security/../crypto/nrf_oberon/include/psa -IC:/ncs/v2.1.2/nrfxlib/crypto/nrf_oberon/include/mbedtls -IC:/ncs/v2.1.2/nrfxlib/crypto/nrf_oberon/include -isystem C:/ncs/v2.1.2/zephyr/subsys/cpp/include -isystem C:/ncs/v2.1.2/modules/lib/openthread/include -isystem C:/ncs/v2.1.2/modules/lib/openthread/examples/platforms -isystem C:/ncs/v2.1.2/nrfxlib/crypto/nrf_cc310_platform/include -Os -imacros D:/nRF52_ot_ble/coprocessor/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=C:/ncs/toolchains/v2.1.2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.1.2/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=D:/nRF52_ot_ble/coprocessor=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.1.2/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.1.2=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -MD -MT CMakeFiles/app.dir/src/ble_utils.c.obj -MF CMakeFiles\app.dir\src\ble_utils.c.obj.d -o CMakeFiles/app.dir/src/ble_utils.c.obj -c ../src/ble_utils.c
    In file included from C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:11,
                     from d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:11:
    ../src/ble_utils.c: In function 'connected':
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:152:13: error: '__log_level' undeclared (first use in this function)
      152 |  (_level <= __log_level) &&         \
          |             ^~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:216:7: note: in expansion of macro 'Z_LOG_CONST_LEVEL_CHECK'
      216 |  if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \
          |       ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:2: note: in expansion of macro 'Z_LOG2'
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |  ^~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:40:25: note: in expansion of macro 'Z_LOG'
       40 | #define LOG_ERR(...)    Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
          |                         ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:62:3: note: in expansion of macro 'LOG_ERR'
       62 |   LOG_ERR("Connection failed (err %u)", err);
          |   ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:152:13: note: each undeclared identifier is reported only once for each function it appears in
      152 |  (_level <= __log_level) &&         \
          |             ^~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:216:7: note: in expansion of macro 'Z_LOG_CONST_LEVEL_CHECK'
      216 |  if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \
          |       ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:2: note: in expansion of macro 'Z_LOG2'
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |  ^~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:40:25: note: in expansion of macro 'Z_LOG'
       40 | #define LOG_ERR(...)    Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
          |                         ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:62:3: note: in expansion of macro 'LOG_ERR'
       62 |   LOG_ERR("Connection failed (err %u)", err);
          |   ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:20: error: '__log_current_const_data' undeclared (first use in this function); did you mean 'log_source_const_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:225:49: note: in definition of macro 'Z_LOG2'
      225 |   if (_level > ((struct log_source_const_data *)_source)->level) { \
          |                                                 ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:40:25: note: in expansion of macro 'Z_LOG'
       40 | #define LOG_ERR(...)    Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
          |                         ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:62:3: note: in expansion of macro 'LOG_ERR'
       62 |   LOG_ERR("Connection failed (err %u)", err);
          |   ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:46: error: '__log_current_dynamic_data' undeclared (first use in this function); did you mean 'log_source_dynamic_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:232:8: note: in definition of macro 'Z_LOG2'
      232 |       (_dsource)->filters : 0;\
          |        ^~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:40:25: note: in expansion of macro 'Z_LOG'
       40 | #define LOG_ERR(...)    Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
          |                         ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:62:3: note: in expansion of macro 'LOG_ERR'
       62 |   LOG_ERR("Connection failed (err %u)", err);
          |   ^~~~~~~
    ../src/ble_utils.c: In function 'disconnected':
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:152:13: error: '__log_level' undeclared (first use in this function)
      152 |  (_level <= __log_level) &&         \
          |             ^~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:216:7: note: in expansion of macro 'Z_LOG_CONST_LEVEL_CHECK'
      216 |  if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \
          |       ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:2: note: in expansion of macro 'Z_LOG2'
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |  ^~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:74:2: note: in expansion of macro 'LOG_INF'
       74 |  LOG_INF("Disconnected (reason %u)", reason);
          |  ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:20: error: '__log_current_const_data' undeclared (first use in this function); did you mean 'log_source_const_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:225:49: note: in definition of macro 'Z_LOG2'
      225 |   if (_level > ((struct log_source_const_data *)_source)->level) { \
          |                                                 ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:74:2: note: in expansion of macro 'LOG_INF'
       74 |  LOG_INF("Disconnected (reason %u)", reason);
          |  ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:46: error: '__log_current_dynamic_data' undeclared (first use in this function); did you mean 'log_source_dynamic_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:232:8: note: in definition of macro 'Z_LOG2'
      232 |       (_dsource)->filters : 0;\
          |        ^~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:74:2: note: in expansion of macro 'LOG_INF'
       74 |  LOG_INF("Disconnected (reason %u)", reason);
          |  ^~~~~~~
    ../src/ble_utils.c: In function 'security_changed':
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:152:13: error: '__log_level' undeclared (first use in this function)
      152 |  (_level <= __log_level) &&         \
          |             ^~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:216:7: note: in expansion of macro 'Z_LOG_CONST_LEVEL_CHECK'
      216 |  if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \
          |       ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:2: note: in expansion of macro 'Z_LOG2'
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |  ^~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:100:3: note: in expansion of macro 'LOG_INF'
      100 |   LOG_INF("Security changed: %s level %u", addr, level);
          |   ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:20: error: '__log_current_const_data' undeclared (first use in this function); did you mean 'log_source_const_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:225:49: note: in definition of macro 'Z_LOG2'
      225 |   if (_level > ((struct log_source_const_data *)_source)->level) { \
          |                                                 ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:100:3: note: in expansion of macro 'LOG_INF'
      100 |   LOG_INF("Security changed: %s level %u", addr, level);
          |   ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:46: error: '__log_current_dynamic_data' undeclared (first use in this function); did you mean 'log_source_dynamic_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:232:8: note: in definition of macro 'Z_LOG2'
      232 |       (_dsource)->filters : 0;\
          |        ^~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:100:3: note: in expansion of macro 'LOG_INF'
      100 |   LOG_INF("Security changed: %s level %u", addr, level);
          |   ^~~~~~~
    ../src/ble_utils.c: In function 'auth_passkey_display':
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:152:13: error: '__log_level' undeclared (first use in this function)
      152 |  (_level <= __log_level) &&         \
          |             ^~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:216:7: note: in expansion of macro 'Z_LOG_CONST_LEVEL_CHECK'
      216 |  if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \
          |       ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:2: note: in expansion of macro 'Z_LOG2'
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |  ^~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:110:2: note: in expansion of macro 'LOG_INF'
      110 |  LOG_INF("Passkey for %s: %06u", addr, passkey);
          |  ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:20: error: '__log_current_const_data' undeclared (first use in this function); did you mean 'log_source_const_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:225:49: note: in definition of macro 'Z_LOG2'
      225 |   if (_level > ((struct log_source_const_data *)_source)->level) { \
          |                                                 ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:110:2: note: in expansion of macro 'LOG_INF'
      110 |  LOG_INF("Passkey for %s: %06u", addr, passkey);
          |  ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:46: error: '__log_current_dynamic_data' undeclared (first use in this function); did you mean 'log_source_dynamic_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:232:8: note: in definition of macro 'Z_LOG2'
      232 |       (_dsource)->filters : 0;\
          |        ^~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:110:2: note: in expansion of macro 'LOG_INF'
      110 |  LOG_INF("Passkey for %s: %06u", addr, passkey);
          |  ^~~~~~~
    ../src/ble_utils.c: In function 'auth_cancel':
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:152:13: error: '__log_level' undeclared (first use in this function)
      152 |  (_level <= __log_level) &&         \
          |             ^~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:216:7: note: in expansion of macro 'Z_LOG_CONST_LEVEL_CHECK'
      216 |  if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \
          |       ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:2: note: in expansion of macro 'Z_LOG2'
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |  ^~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:117:2: note: in expansion of macro 'LOG_INF'
      117 |  LOG_INF("Pairing cancelled: %s", addr);
          |  ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:20: error: '__log_current_const_data' undeclared (first use in this function); did you mean 'log_source_const_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:225:49: note: in definition of macro 'Z_LOG2'
      225 |   if (_level > ((struct log_source_const_data *)_source)->level) { \
          |                                                 ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:117:2: note: in expansion of macro 'LOG_INF'
      117 |  LOG_INF("Pairing cancelled: %s", addr);
          |  ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:46: error: '__log_current_dynamic_data' undeclared (first use in this function); did you mean 'log_source_dynamic_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:232:8: note: in definition of macro 'Z_LOG2'
      232 |       (_dsource)->filters : 0;\
          |        ^~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:117:2: note: in expansion of macro 'LOG_INF'
      117 |  LOG_INF("Pairing cancelled: %s", addr);
          |  ^~~~~~~
    ../src/ble_utils.c: In function 'pairing_complete':
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:152:13: error: '__log_level' undeclared (first use in this function)
      152 |  (_level <= __log_level) &&         \
          |             ^~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:216:7: note: in expansion of macro 'Z_LOG_CONST_LEVEL_CHECK'
      216 |  if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \
          |       ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:2: note: in expansion of macro 'Z_LOG2'
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |  ^~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:124:2: note: in expansion of macro 'LOG_INF'
      124 |  LOG_INF("Pairing completed: %s, bonded: %d", addr, bonded);
          |  ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:20: error: '__log_current_const_data' undeclared (first use in this function); did you mean 'log_source_const_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:225:49: note: in definition of macro 'Z_LOG2'
      225 |   if (_level > ((struct log_source_const_data *)_source)->level) { \
          |                                                 ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:124:2: note: in expansion of macro 'LOG_INF'
      124 |  LOG_INF("Pairing completed: %s, bonded: %d", addr, bonded);
          |  ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:46: error: '__log_current_dynamic_data' undeclared (first use in this function); did you mean 'log_source_dynamic_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:232:8: note: in definition of macro 'Z_LOG2'
      232 |       (_dsource)->filters : 0;\
          |        ^~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:124:2: note: in expansion of macro 'LOG_INF'
      124 |  LOG_INF("Pairing completed: %s, bonded: %d", addr, bonded);
          |  ^~~~~~~
    ../src/ble_utils.c: In function 'pairing_failed':
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:152:13: error: '__log_level' undeclared (first use in this function)
      152 |  (_level <= __log_level) &&         \
          |             ^~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:216:7: note: in expansion of macro 'Z_LOG_CONST_LEVEL_CHECK'
      216 |  if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \
          |       ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:2: note: in expansion of macro 'Z_LOG2'
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |  ^~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:131:2: note: in expansion of macro 'LOG_INF'
      131 |  LOG_INF("Pairing failed conn: %s, reason %d", addr, reason);
          |  ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:20: error: '__log_current_const_data' undeclared (first use in this function); did you mean 'log_source_const_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:225:49: note: in definition of macro 'Z_LOG2'
      225 |   if (_level > ((struct log_source_const_data *)_source)->level) { \
          |                                                 ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:131:2: note: in expansion of macro 'LOG_INF'
      131 |  LOG_INF("Pairing failed conn: %s, reason %d", addr, reason);
          |  ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:46: error: '__log_current_dynamic_data' undeclared (first use in this function); did you mean 'log_source_dynamic_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:232:8: note: in definition of macro 'Z_LOG2'
      232 |       (_dsource)->filters : 0;\
          |        ^~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:61:24: note: in expansion of macro 'Z_LOG'
       61 | #define LOG_INF(...)   Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
          |                        ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:131:2: note: in expansion of macro 'LOG_INF'
      131 |  LOG_INF("Pairing failed conn: %s, reason %d", addr, reason);
          |  ^~~~~~~
    ../src/ble_utils.c: In function 'ble_utils_init':
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:152:13: error: '__log_level' undeclared (first use in this function)
      152 |  (_level <= __log_level) &&         \
          |             ^~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:216:7: note: in expansion of macro 'Z_LOG_CONST_LEVEL_CHECK'
      216 |  if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \
          |       ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:2: note: in expansion of macro 'Z_LOG2'
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |  ^~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:40:25: note: in expansion of macro 'Z_LOG'
       40 | #define LOG_ERR(...)    Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
          |                         ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:147:4: note: in expansion of macro 'LOG_ERR'
      147 |    LOG_ERR("Failed to register authorization callbacks.");
          |    ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:20: error: '__log_current_const_data' undeclared (first use in this function); did you mean 'log_source_const_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:225:49: note: in definition of macro 'Z_LOG2'
      225 |   if (_level > ((struct log_source_const_data *)_source)->level) { \
          |                                                 ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:40:25: note: in expansion of macro 'Z_LOG'
       40 | #define LOG_ERR(...)    Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
          |                         ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:147:4: note: in expansion of macro 'LOG_ERR'
      147 |    LOG_ERR("Failed to register authorization callbacks.");
          |    ^~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:252:46: error: '__log_current_dynamic_data' undeclared (first use in this function); did you mean 'log_source_dynamic_data'?
      252 |  Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
          |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log_core.h:232:8: note: in definition of macro 'Z_LOG2'
      232 |       (_dsource)->filters : 0;\
          |        ^~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\logging\log.h:40:25: note: in expansion of macro 'Z_LOG'
       40 | #define LOG_ERR(...)    Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
          |                         ^~~~~
    d:\nRF52_ot_ble\coprocessor\src\ble_utils.c:147:4: note: in expansion of macro 'LOG_ERR'
      147 |    LOG_ERR("Failed to register authorization callbacks.");
          |    ^~~~~~~

    I can see "CONFIG_BLE_UTILS_LOG_LEVEL" is not defined in my project.

    Why? I observe in the original project it is defined here:

    And here:

    And here:

    What is the relation between these files? Could you explain it to me?

    On the other hand, I can see in the original project nRF KConfig this option:

    But I cant see it in my personal project:

    Why? 

  • Do I understand it correctly that you are able to build original sample, but not the custom project you have made? 

  • Exactly. My main question is why I cant find this settings "CONFIG_BLE_UTILS_LOG_LEVEL" or "CONFIG_BLE_UTILS_LOG_LEVEL_DBG" in my kconfig build but it is in the kconfig build from the original project. It is due to the zephyr version? Both projects are using the same zephyr versions because I selected the ncs directory when I configured VS code at the beginning.

  • First you need to make sure you have added the same Kconfig configurations in your prj.conf file as in the reference sample.

  • Exactly, I added the next kconfig fragment to my personal project as the original project does:

    This file include the define i want:

    But when I try to compile, the next error appear:

Reply Children
Related