Maximum length of manufacturer specific data

Hello,

I am using a nrf5340 together with nrf Connect SDK v2.4.2. 

I use extended advertising to be able to send manufacturer specific data.

For now I am able to send 184 bytes of data including my company id.

According to Bluetooth specification it is possible to send more manufacturer specific data in one advertising packet. It should be 252 bytes: (How many bytes can you include in a BLE advertising packet? | Novel Bits)

In my application the data of the advertising packet also includes the device name which is 30 bytes long and the 128-Bit UUID. 

So I calculated the size of the extended advertising packet as follows:

# Access Address: 4 bytes
# Packet Header:  2 bytes
# Extended Advertising Header: 10 bytes
# Advertising Data:
#   Flags: 3 bytes
#   128 Bit UUID: 18 bytes
#   Manufacturer Specific: 254 bytes(252 bytes data inkl. 2 bytes Company ID)
#   Device Name: 30 bytes
# Sum: 321 bytes

In prj.conf I set CONFIG_BT_EXT_ADV to yes and CONFIG_BT_DEVICE_NAME_MAX to 30 bytes.

In hci_rpmsg.conf I set CONFIG_BT_EXT_ADV to yes and CONFIG_BT_CTLR_ADV_DATA_LEN_MAX to 400 bytes which should be big enough.
Here is a screenshot from Wireshark with 184 bytes manufacturer specific data:

It seems the size is limited to CONFIG_BT_CTLR_DATA_LENGTH_MAX which I can set maximum to 251 bytes ?!

What must I change / add to to use 252 bytes of manufacturer specific data?

Regards

Jan

  • Hello,

    Please see discussion here: Chaining - current status 

    tldr; You can't send it in one advertisment, but need to split it in two (chained advertisment).

    Kenneth

  • Hello,

    I tried the following example which Hung Bui provided in your linked discussion:

    5305.peripheral_hr_chained.zip

    I built it with SDK 2.6.1. But I got an error during Debugging when the advertising information is created. (

    (main.c, line 110: err = bt_le_ext_adv_create(&param, NULL, &adv); => function returns with err = -5)


    static int create_advertising_chained(void)
    {
    	int err;
    	struct bt_le_adv_param param =
    		BT_LE_ADV_PARAM_INIT(BT_LE_ADV_OPT_USE_NAME | BT_LE_ADV_OPT_USE_IDENTITY |
    				     BT_LE_ADV_OPT_EXT_ADV 
    				     ,
    				     BT_GAP_ADV_FAST_INT_MIN_2,
    				     BT_GAP_ADV_FAST_INT_MAX_2,
    				     NULL);
    
    	err = bt_le_ext_adv_create(&param, NULL, &adv);
    	if (err) {
    		printk("Failed to create advertiser set (err %d)\n", err);
    		return err;
    	}

    Could you clarify if this example runs on the nrf5340 DK?

    Regards

    Jan

  • The `bt_le_ext_adv_create()` function can return error code -5 (EIO) when there's an issue with the Bluetooth controller. This can happen when the controller doesn't recognize the opcode for setting extended advertising parameters. This suggests that support for the extended advertising feature has not been enabled in the Bluetooth controller running on the network core (see following case for details:Identical code to Peripheral HR Coded sample not working in my own project ).

    In another case, the error was resolved by using the "Erase and Flash" action, suggesting that there might have been some old data in the network core or elsewhere that was causing the issue (see following case for details:  Error when trying to enable extended advertising on code based on NUS example ).

    Therefore, if you're encountering error -5 with `bt_le_ext_adv_create()`, you should check that extended advertising is indeed enabled, that there's no old data causing issues.

    Kenneth

  • I checked it again:

    • did a pristine build in VS Code 
    • I used Erase and Flash and after that Debug.
    • (Also Debugging with Ozone showed the same error.)

    After that I had a deeper look in the prj.conf-File:

    CONFIG_BT_CTLR_ADV_EXT=y and CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=1650 were marked with a warning.

    I removed CONFIG_BT_CTLR_ADV_EXT=y and copied CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=1650 to the child image config file hci_rpmsg.conf

    I had to change the file name hci_rpmsg.conf to hci_ipc.conf.

    After that the example worked as intended and helped me to answer my question.

    Regards

    Jan

Related