nRF5340 Dynamic Connection Event Length

Hi,

I need to use two or more different event lengths for different modes. The event length should be set based on the mode before establishing a connection. I found that sdc_hci_cmd_vs_event_length_set() can be used for this purpose.

To implement this, I added the header:

#include <sdc_hci_vs.h>

Then, I tried to use the function with the following code:

uint8_t err;
static sdc_hci_cmd_vs_event_length_set_t event_length_param;
event_length_param.event_length_us = 5000;

err = sdc_hci_cmd_vs_event_length_set(&event_length_param);
if (err)
    printk("Failed to set event length (err %d)\n", err);
else
    printk("Event length set to %u units\n", event_length_param.event_length_us);

However, I am unable to compile the project due to the following error:
"Undefined reference to sdc_hci_cmd_vs_event_length_set."

Could you help me understand why this error occurs? Are there additional header files or configurations required?

Can you please provide an example implementation to make integration easier?

Parents
  • Hi,

    Is your application based on any of our samples?

    Which NCS version do you use?

    Can you provide complete error log?

    Best regards,
    Dejan

  • Hi,

    Which NCS version do you use?

    NCS version 2.6.1.

    Is your application based on any of our samples?

    No, Our custom board code. 

    Please check the complete log.

     *  Executing task: nRF Connect: Build: C50T1_RideGrid_nRF5340/build (active) 
    
    Building C50T1_RideGrid_nRF5340
    C:\WINDOWS\system32\cmd.exe /d /s /c "west build --build-dir d:/NORDIC/Projects/C50T1_RideGrid_nRF5340/build d:/NORDIC/Projects/C50T1_RideGrid_nRF5340"
    
    [0/26] Performing build step for 'mcuboot_subimage'
    ninja: no work to do.
    [0/5] Performing build step for 'b0n_subimage'
    ninja: no work to do.
    [3/18] Building C object CMakeFiles/app.dir/src/main.c.obj
    In file included from D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/src/custom_module/MeshConnection.h:2,
                     from D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/src/main.c:19:
    D:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/include/zephyr/random/rand32.h:13:2: warning: #warning "<zephyr/random/rand32.h> is deprecated, include <zephyr/random/random.h> instead" [-Wcpp]
       13 | #warning "<zephyr/random/rand32.h> is deprecated, include <zephyr/random/random.h> instead"
          |  ^~~~~~~
    In file included from D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/src/main.c:26:
    D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/src/legacy_module/inc/fm_config.h:25:1: warning: multi-line comment [-Wcomment]
       25 | // #define FM_UUID_SERV_VAL \
          | ^
    D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/src/legacy_module/inc/fm_config.h:27:1: warning: multi-line comment [-Wcomment]
       27 | // #define FM_MESH_SERVICE_CHAR_UUID_VAL \
          | ^
    D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/src/main.c:86:6: warning: return type of 'main' is not 'int' [-Wmain]
       86 | void main(void)
          |      ^~~~
    D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/src/main.c: In function 'main':
    D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/src/main.c:96:9: warning: implicit declaration of function 'buffer_init' [-Wimplicit-function-declaration]
       96 |         buffer_init();
          |         ^~~~~~~~~~~
    D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/src/main.c:99:9: warning: implicit declaration of function 'ridegrid_device_info_send' [-Wimplicit-function-declaration]
       99 |         ridegrid_device_info_send();
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~
    [5/18] Linking C executable zephyr\zephyr_pre0.elf
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/build/zephyr/zephyr_pre0.map 
    cmd.exe /C "cd . && D:\NORDIC\nRFConnectSDK\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe  -gdwarf-4 @CMakeFiles\zephyr_pre0.rsp -o zephyr\zephyr_pre0.elf  && cmd.exe /C "cd /D D:\NORDIC\Projects\C50T1_RideGrid_nRF5340\build\zephyr && D:\NORDIC\nRFConnectSDK\toolchains\cf2149caf2\opt\bin\cmake.exe -E true""
    d:/nordic/nrfconnectsdk/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj): in function `main':
    D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/src/main.c:106: undefined reference to `sdc_hci_cmd_vs_event_length_set'
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'D:\NORDIC\nRFConnectSDK\toolchains\cf2149caf2\opt\bin\cmake.EXE' --build 'd:\NORDIC\Projects\C50T1_RideGrid_nRF5340\build'
    
     *  The terminal process terminated with exit code: 1. 
     *  Terminal will be reused by tasks, press any key to close it. 

  • Hi,

    The issue you observed might be related to APIs inability to access controller which is on the network core.
    You could try to use hci_vs_sdc which is currently recommended API for sending VS commands to the controller. This API will build and send HCI command to the controller and works even if the controller is on another CPU compared to the host/application. You can look at this commit.

    Best regards,
    Dejan

  • Hi,

    1. I have added the hci_vs_sdc.h file to the NCS library path:

    nRFConnectSDK\v2.6.1\zephyr\include\zephyr\bluetooth\hci_vs_sdc.h

    2. I have added the hci_vs_sdc.c file to the NCS library path:

    nRFConnectSDK\v2.6.1\zephyr\subsys\bluetooth\hci_vs_sdc.c

    3. I have modified the CMakeLists.txt file in the NCS library path:

    nRFConnectSDK\v2.6.1\zephyr\subsys\bluetooth\CMakeLists.txt

    Added the following line:

    zephyr_sources_ifdef(CONFIG_BT_LL_SOFTDEVICE hci_vs_sdc.c)

    # SPDX-License-Identifier: Apache-2.0
    
    add_library(subsys__bluetooth INTERFACE)
    
    target_include_directories(subsys__bluetooth INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
    
    add_subdirectory(common)
    add_subdirectory_ifdef(CONFIG_BT_HCI host)
    add_subdirectory_ifdef(CONFIG_BT_SHELL shell)
    add_subdirectory_ifdef(CONFIG_BT_CONN services)
    add_subdirectory_ifdef(CONFIG_BT_MESH mesh)
    add_subdirectory_ifdef(CONFIG_BT_AUDIO audio)
    add_subdirectory_ifdef(CONFIG_BT_CRYPTO crypto)
    
    zephyr_sources_ifdef(CONFIG_BT_LL_SOFTDEVICE hci_vs_sdc.c)
    
    if(CONFIG_BT_CTLR AND CONFIG_BT_LL_SW_SPLIT)
      add_subdirectory(controller)
    endif()
    
    zephyr_include_directories(${ZEPHYR_BASE}/subsys/bluetooth)
    
    add_subdirectory(lib)
    

    4. I have enabled the CONFIG_BT_LL_SOFTDEVICE option by adding CONFIG_BT_LL_SOFTDEVICE=y in both the app core and net core config files.

    But still I am getting the error 

    main.c:118: undefined reference to `hci_vs_sdc_event_length_set'

     *  Executing task: nRF Connect: Build: C50T1_RideGrid_nRF5340/build (active) 
    
    Building C50T1_RideGrid_nRF5340
    C:\WINDOWS\system32\cmd.exe /d /s /c "west build --build-dir d:/NORDIC/Projects/C50T1_RideGrid_nRF5340/build d:/NORDIC/Projects/C50T1_RideGrid_nRF5340"
    
    [0/25] Performing build step for 'mcuboot_subimage'
    ninja: no work to do.
    [26/26] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       22332 B      34176 B     65.34%
                 RAM:        3456 B        64 KB      5.27%
               SRAM1:          0 GB        64 KB      0.00%
            IDT_LIST:          0 GB        32 KB      0.00%
    [57/202] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/bluetooth/hci_vs_sdc.c.obj
    FAILED: zephyr/CMakeFiles/zephyr.dir/subsys/bluetooth/hci_vs_sdc.c.obj 
    D:\NORDIC\nRFConnectSDK\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DEXT_API_MAGIC=0x281ee6de,0xb845acea,13570 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,13570 -DKERNEL -DNRF5340_XXAA_NETWORK -DPICOLIBC_LONG_LONG_PRINTF_SCANF -DUSE_PARTITION_MANAGER=1 -DVALIDATION_INFO_MAGIC=0x281ee6de,0x86518483,79106 -DVALIDATION_POINTER_MAGIC=0x281ee6de,0x6919b47e,79106 -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -ID:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/kernel/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/arch/arm/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrf/drivers/mpsl/clock_control -ID:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/include -ID:/NORDIC/Projects/C50T1_RideGrid_nRF5340/build/hci_ipc/zephyr/include/generated -ID:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/soc/arm/nordic_nrf/nrf53 -ID:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/soc/common/nordic_nrf/. -ID:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/soc/arm/nordic_nrf/common/. -ID:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/subsys/bluetooth -ID:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/subsys/settings/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrf/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrf/lib/multithreading_lock/. -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrf/subsys/bluetooth/controller/. -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrf/tests/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/modules/hal/cmsis/CMSIS/Core/Include -ID:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/modules/cmsis/. -ID:/NORDIC/nRFConnectSDK/v2.6.1/modules/hal/nordic/nrfx -ID:/NORDIC/nRFConnectSDK/v2.6.1/modules/hal/nordic/nrfx/drivers/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/modules/hal/nordic/nrfx/mdk -ID:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/modules/hal_nordic/nrfx/. -ID:/NORDIC/Projects/C50T1_RideGrid_nRF5340/build/hci_ipc/modules/libmetal/libmetal/lib/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/modules/lib/open-amp/open-amp/lib/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/modules/crypto/tinycrypt/lib/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrfxlib/mpsl/fem/common/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrfxlib/mpsl/fem/nrf21540_gpio/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrfxlib/mpsl/fem/nrf21540_gpio_spi/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrfxlib/mpsl/fem/simple_gpio/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrfxlib/mpsl/fem/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrfxlib/mpsl/fem/include/protocol -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrfxlib/mpsl/include -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrfxlib/mpsl/include/protocol -ID:/NORDIC/nRFConnectSDK/v2.6.1/nrfxlib/softdevice_controller/include -isystem D:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/lib/libc/common/include -fno-strict-aliasing -O2 -imacros D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/build/hci_ipc/zephyr/include/generated/autoconf.h -fno-printf-return-value -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33+nodsp -mthumb -mabi=aapcs -mfp16-format=ieee -mtp=soft --sysroot=D:/NORDIC/nRFConnectSDK/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros D:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=D:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/samples/bluetooth/hci_ipc=CMAKE_SOURCE_DIR -fmacro-prefix-map=D:/NORDIC/nRFConnectSDK/v2.6.1/zephyr=ZEPHYR_BASE -fmacro-prefix-map=D:/NORDIC/nRFConnectSDK/v2.6.1=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -std=c99 -MD -MT zephyr/CMakeFiles/zephyr.dir/subsys/bluetooth/hci_vs_sdc.c.obj -MF zephyr\CMakeFiles\zephyr.dir\subsys\bluetooth\hci_vs_sdc.c.obj.d -o zephyr/CMakeFiles/zephyr.dir/subsys/bluetooth/hci_vs_sdc.c.obj -c D:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/subsys/bluetooth/hci_vs_sdc.c
    D:/NORDIC/nRFConnectSDK/v2.6.1/zephyr/subsys/bluetooth/hci_vs_sdc.c:8:10: fatal error: bluetooth/hci_vs_sdc.h: No such file or directory
        8 | #include <bluetooth/hci_vs_sdc.h>
          |          ^~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    
    [65/202] Building C object modules/nrf/subsys/bluetooth/controller/CMakeFiles/..__nrf__subsys__bluetooth__controller.dir/hci_driver.c.obj
    ninja: build stopped: subcommand failed.
    [4/25] Linking C executable zephyr\zephyr_pre0.elf
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/build/zephyr/zephyr_pre0.map 
    cmd.exe /C "cd . && D:\NORDIC\nRFConnectSDK\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe  -gdwarf-4 @CMakeFiles\zephyr_pre0.rsp -o zephyr\zephyr_pre0.elf  && cmd.exe /C "cd /D D:\NORDIC\Projects\C50T1_RideGrid_nRF5340\build\zephyr && D:\NORDIC\nRFConnectSDK\toolchains\cf2149caf2\opt\bin\cmake.exe -E true""
    d:/nordic/nrfconnectsdk/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj): in function `main':
    
    D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/src/main.c:118: undefined reference to `hci_vs_sdc_event_length_set'
    
    collect2.exe: error: ld returned 1 exit status
    FAILED: modules/nrf/samples/hci_ipc_subimage-prefix/src/hci_ipc_subimage-stamp/hci_ipc_subimage-build hci_ipc/zephyr/zephyr.hex hci_ipc/zephyr/zephyr.elf hci_ipc/zephyr/merged_CPUNET.hex D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/build/modules/nrf/samples/hci_ipc_subimage-prefix/src/hci_ipc_subimage-stamp/hci_ipc_subimage-build D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/build/hci_ipc/zephyr/zephyr.hex D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/build/hci_ipc/zephyr/zephyr.elf D:/NORDIC/Projects/C50T1_RideGrid_nRF5340/build/hci_ipc/zephyr/merged_CPUNET.hex 
    cmd.exe /C "cd /D D:\NORDIC\Projects\C50T1_RideGrid_nRF5340\build\hci_ipc && D:\NORDIC\nRFConnectSDK\toolchains\cf2149caf2\opt\bin\cmake.exe --build . --"
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'D:\NORDIC\nRFConnectSDK\toolchains\cf2149caf2\opt\bin\cmake.EXE' --build 'd:\NORDIC\Projects\C50T1_RideGrid_nRF5340\build'
    
     *  The terminal process terminated with exit code: 1. 
     *  Terminal will be reused by tasks, press any key to close it. 

    Can you please confirm if the above steps are correct or if I am missing anything?

  • Hi,

    There is a sample that demonstrates how to use hci_vs_sdc_event_length_set() - scanning while connecting. This sample builds for nrf53. In this sample, SoftDevice controller is on the network core while Zephyr host and application reside on the application core, and no cmake changes are needed.

    Best regards,
    Dejan

  • Hi

    The file hci_vs_sdc.h is not there in my NCS 2.6.1 folder.

    Is this file available only in a higher version?

Reply Children
No Data
Related