Does the Event Trigger API always require CONFIG_BT_CENTRAL? Significantly increases peripheral image size.

Hi,

I'm using the new Event Trigger API in a BLE peripheral to set up a connection event trigger as demonstrated in this official sample. The trigger seems to work fine, but I've noticed that CONFIG_BT_CENTRAL=y is required, even though my device is a BLE peripheral. Otherwise, I'm getting this error

[00:00:06.745,758] <wrn> bt_hci_core: opcode 0xfd13 status 0x01
[00:00:06.745,788] <err> my_app: Error for command SDC_HCI_OPCODE_CMD_VS_SET_CONN_EVENT_TRIGGER (-5)

The problem is that setting CONFIG_BT_CENTRAL=y seems to increase the image size in an optimized build by about 60 kbytes, which is not ideal. Am I missing something here, or is CONFIG_BT_CENTRAL indeed required to set up a connection event trigger in a BLE peripheral using the Event Trigger API? If so, is there any way I can reduce the impact it has on the image size?

I'm using the the nRF52840 DK and nRF Connect SDK v2.6.0.

Thanks

  • Hello,

    Well the sample itself is made to be able to support both a scanner and a peripheral, so removing the scanner functionality would of course not work on the default sample. But I believe that you can have this working on a peripheral device if you modify the sample to allow it to. 

    I assume that what you are running is something modified in order to remove the central feature from the sample? Could you describe what you've changed?

    -5 is EIO,  an I/O error, so there could be a wrong argument or something.

    Regards,

    Elfving

  • Hi, thanks for your reply.

    Here is slightly modified version of the official sample linked in my question. I've tried to comment out everything related to the central role in an effort to make the sample peripheral only. CONFIG_BT_CENTRAL=y is commented out, so if you build and run this modified sample you'll likely see the issue described above. Uncommenting that line in prj.conf should make the sample work as expected.

    I've also attached a diff showing the changes I've made.

    connection_event_trigger_peripheral_only.zip

    diff --git a/prj.conf b/prj.conf
    index 1147534..7b2ac6a 100644
    --- a/prj.conf
    +++ b/prj.conf
    @@ -15,17 +15,23 @@ CONFIG_LOG_MODE_IMMEDIATE=y
     
     CONFIG_BT_LL_SOFTDEVICE=y
     
    -CONFIG_BT_DEVICE_NAME="Nordic Event Trigger Sample"
    +CONFIG_BT_DEVICE_NAME="Peripheral only evt trig sample"
     CONFIG_BT=y
     CONFIG_BT_PERIPHERAL=y
    -CONFIG_BT_CENTRAL=y
    -CONFIG_BT_MAX_CONN=2
    -CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT=1
    -CONFIG_BT_BONDABLE=n
    -
    -CONFIG_BT_SCAN=y
    -CONFIG_BT_SCAN_FILTER_ENABLE=y
    -CONFIG_BT_SCAN_UUID_CNT=1
    +
    +# Without this line, I get the error
    +# [00:00:17.473,297] <wrn> bt_hci_core: opcode 0xfd13 status 0x01
    +# Error for command SDC_HCI_OPCODE_CMD_VS_SET_CONN_EVENT_TRIGGER (-5).
    +# If I uncomment this line, everything works as expected in the peripheral role.
    +# CONFIG_BT_CENTRAL=y
    +
    +# CONFIG_BT_MAX_CONN=2
    +# CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT=1
    +# CONFIG_BT_BONDABLE=n
    +
    +# CONFIG_BT_SCAN=y
    +# CONFIG_BT_SCAN_FILTER_ENABLE=y
    +# CONFIG_BT_SCAN_UUID_CNT=1
     
     CONFIG_BT_CTLR_SDC_EVENT_TRIGGER=y
     
    diff --git a/src/main.c b/src/main.c
    index d4933da..e14e3b9 100644
    --- a/src/main.c
    +++ b/src/main.c
    @@ -15,7 +15,7 @@
     #include <zephyr/bluetooth/conn.h>
     #include <zephyr/bluetooth/hci.h>
     #include <zephyr/bluetooth/uuid.h>
    -#include <bluetooth/scan.h>
    +// #include <bluetooth/scan.h>
     
     #include <hal/nrf_egu.h>
     #include <sdc_hci_vs.h>
    @@ -239,6 +239,7 @@ static void adv_start(void)
     	printk("Advertising successfully started\n");
     }
     
    +/* 
     static void scan_filter_match(struct bt_scan_device_info *device_info,
     			      struct bt_scan_filter_match *filter_match, bool connectable)
     {
    @@ -299,7 +300,7 @@ static void scan_start(void)
     	}
     
     	printk("Scanning successfully started\n");
    -}
    +} */
     
     int main(void)
     {
    @@ -308,6 +309,7 @@ int main(void)
     	k_work_init(&work, work_handler);
     	console_init();
     	printk("Starting Connection Event Trigger Example.\n");
    +	printk("Code has been modified to only support the peripheral role.\n");
     
     	err = bt_enable(NULL);
     	if (err) {
    @@ -316,17 +318,18 @@ int main(void)
     	}
     
     	while (true) {
    -		printk("Choose device role - type c (central) or p (peripheral): ");
    +		// printk("Choose device role - type c (central) or p (peripheral): ");
    +		printk("Choose device role - p (peripheral):");
     
     		char input_char = console_getchar();
     
     		printk("\n");
     
    -		if (input_char == 'c') {
    +		/* if (input_char == 'c') {
     			printk("Central. Starting scanning\n");
     			scan_start();
     			break;
    -		} else if (input_char == 'p') {
    +		} else */ if (input_char == 'p') {
     			printk("Peripheral. Starting advertising\n");
     			adv_start();
     			break;
    

  • Hello again,

    I had a talk with the team responsible. And you are right in that you unfortunately won't be able to use the Event Trigger API without a larger version of the SDC.

    Needing CONFIG_BT_CENTRAL was a bit confusing to me, but you do not need that per se, you just need a configuration that selects the larger multi-role version of the SDC, which also has the features one would need for the Event Trigger API. 

    So using something like CONFIG_BT_CTLR_ADV_EXT could work as well, though you would either way end up with a larger controller, which was what you were trying to avoid.

    Sorry about this.

    Regards,

    Elfving

  • I guess enabling CONFIG_BT_LL_SOFTDEVICE_MULTIROLE would be better than enabling some other unused feature.

    I have to say that your request this has sparked some conversation about this internally, and it might be that a future NCS version would get support for the Event Trigger API in the peripheral SDC. Though for details regarding this you would have to talk to your local Regional Sales Manager, as I can't comment on what is going to get released in the future.

    Regards,

    Elfving

Related