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,

    Yes I am using this in the net core file (custom_nrf5340_cpunet_defconfig file.)

    CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT=5000.
    I have tried removing this config, but still getting the same error. 
  • Hi,

    Any updates?

    If you can provide an example code or implementation, that would be great.

  • Hi,

    Can you provide more information about your application? Is it based on any of our Bluetooth samples?

    Edit:  You can look at the scanning while connecting sample. It shows how to set event_length_us parameter.

    Best regards,
    Dejan

  • Hi,

    I have developed a custom BLE application code by using this custom_ncs_ble_service_sample tutorial. Its working fine.

    We are developing a mesh network. Our requirement is the one device can connect to three other devices. Using one connection as a peripheral and up to two connections as a central for mesh connections.

    We are using nRF5340 and the nRF Connect SDK Version 2.6.1.

    I have attached our code in this private ticket. If needed you can refer this.  

    Private ticket of other issue

  • Hi,

    Thank you for additional information.

    AKV said:
    I have attached our code in this private ticket. If needed you can refer this.  

    There are many files (including several zip files) in your previous ticket. Which file contains your code?

    dejans said:
    Edit:  You can look at the scanning while connecting sample. It shows how to set event_length_us parameter.

    Can you look at the sample which I linked in my previous edited reply?

    Best regards,
    Dejan

Reply Children
  • Hi,

    There are many files (including several zip files) in your previous ticket. Which file contains your code?

    You can download any code, If you need latest one you download "ridegrid_06_28012025".

    Can you look at the sample which I linked in my previous edited reply?

    Yes, I have tried as given below. But the error is 

    main.c:30:10: fatal error: bluetooth/hci_vs_sdc.h: No such file or directory
    30 | #include <bluetooth/hci_vs_sdc.h> 

    #include <bluetooth/hci_vs_sdc.h>
    #include <zephyr/bluetooth/bluetooth.h>
    #include <zephyr/bluetooth/addr.h>
    #include <zephyr/bluetooth/conn.h>
    #include <zephyr/bluetooth/hci.h>
    
    
    
    sdc_hci_cmd_vs_event_length_set_t event_length_params = {
    		.event_length_us = 2000,
    	};
    
    hci_vs_sdc_event_length_set(&event_length_params);

Related