BLE Advertising Sets (which requires Extended Advertising) limits connections to 1 per service

Hi,

I am migrating to use Advertising Sets, which require Extended Advertising, and I am seeing that the number of connections per-connectable-service is seemingly reduced to 1.

Meaning, when a single connection to an connectable-service occurs, advertising for that service is automatically shut off.  You can only subsequently re-enable advertising, manually, by waiting for that connection to disconnect.

Am I understanding that correctly?  This would be a change in behavior from the traditional Advertising (which allows many per-connectable service, globally bounded by CONFIG_BT_MAX_CONN).  The change in behavior is not desirable.

The other DevZone post here: Extended advertising stops after connection gets established in nRF Connect SDK  seems to indicate yes.

I want more than one connection per-connectable-service (without resorting to entering multiple entries into the advertising set, 1 for each connection).

How can that be done?

Or alternatively, how can I use multiple advertising sets without enabling Extended Advertising?

Or anything else you can suggest?

Thanks.

  • Hi,

    Advertising will have to be re-started manually on connect/disconnect when using the bt_le_ext_adv_start() as noted in the comment here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.0/zephyr/connectivity/bluetooth/api/gap.html?highlight=bt_le_adv_opt_one_time#[email protected]_LE_ADV_OPT_ONE_TIME.

    Please have a look at our peripheral_hr_code sample for an example of how you handle this in your code. I assume the only difference in your case will be that you also will want to start the advertising from the connected callback in the cases were you have not reached the CONFIG_BT_MAX_CONN number of connections.

  • Hi,

    you also will want to start the advertising from the connected callback

    This does not work.  Are you saying it should work?  How can I get this to work?

    Separately, I'm seeing that I cannot create more than one "connectable" advertising set.  Is that correct?

    If I should be able to create more than one connectable advertising set, can you point me to a working example?

    Thanks.

  • douglas.malnati said:
    This does not work.  Are you saying it should work?  How can I get this to work?

    Yes, it should work, but you might need to call bt_le_ext_adv_start() from the workqueue like how it's done in the peripheral_hr_coded sample I mentioned earlier.

    douglas.malnati said:
    Separately, I'm seeing that I cannot create more than one "connectable" advertising set.  Is that correct?

    No, you should be able have multiple connectable advertising sets. What error were you getting? Could it be that you are exceeding your CONFIG_BT_EXT_ADV_MAX_ADV_SET setting?

    douglas.malnati said:
    If I should be able to create more than one connectable advertising set, can you point me to a working example?

    I'm not aware of any peripheral multilink samples in the SDK, but I can try to put together one if needed.

  • Hi,

    Yes, it should work, but you might need to call bt_le_ext_adv_start() from the workqueue like how it's done in the peripheral_hr_coded sample I mentioned earlier.

    When I call bt_le_ext_adv_start, after the "connected" callback fully completes, I get an error -111, which appears to be ECONNREFUSED.

    The error text is this:

    [00:00:08.524,230] <wrn> bt_hci_core: bt_hci_cmd_send_sync: opcode 0x2039 status 0x09
    [00:00:08.652,282] <err> bt_adv: bt_le_ext_adv_start: Failed to start advertiser

    The <err> is generated in adv.c, in bt_le_ext_adv_start()

    	err = bt_le_adv_set_enable_ext(adv, true, param);
    	if (err) {
    		BT_ERR("Failed to start advertiser");
    		if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && conn) {
    			bt_conn_set_state(conn, BT_CONN_DISCONNECTED);
    			bt_conn_unref(conn);
    		}
    
    		return err;
    	}

    The <wrn> is generated in hci_core.c, in bt_hci_cmd_send_sync()

    	if (status) {
    		BT_WARN("opcode 0x%04x status 0x%02x", opcode, status);
    		net_buf_unref(buf);
    
    		switch (status) {
    		case BT_HCI_ERR_CONN_LIMIT_EXCEEDED:
    			return -ECONNREFUSED;
    		default:
    			return -EIO;
    		}
    	}

    So it seems that BT_HCI_ERR_CONN_LIMIT_EXCEEDED is being returned.  Why would that be?

    in my prj.conf file I have:

    CONFIG_BT_EXT_ADV_MAX_ADV_SET=4

    CONFIG_BT_MAX_CONN=20

    I'm using only a single advertising set.

    What do I need to do to get this to work?

    you should be able have multiple connectable advertising sets. What error were you getting? Could it be that you are exceeding your CONFIG_BT_EXT_ADV_MAX_ADV_SET setting?

    Actually the error is the exact same as above.

    [00:00:01.953,521] <wrn> bt_hci_core: bt_hci_cmd_send_sync: opcode 0x2039 status 0x09
    [00:00:02.081,695] <err> bt_adv: bt_le_ext_adv_start: Failed to start advertiser

    To do this, I added an additional connectable service to the code, and this error is generated when I try to start that advertising set.

    It's not an issue with starting advertising sets, though, as I've been able to start multiple non-connectable sets in addition to a single connectable set.

    It seems the above error is generated when:

    • I try to re-enable advertising for a connectable advertising set while there is a single connection in progress
    • I try to start 2 connectable advertising sets (failure on attempting to start the second).

    Can you please let me know what I need to do to resolve this?

    If you're able to get a working example that would be helpful.

    Thanks.

  • Hi,

    Attached below is an example I put together based on the peripheral_hr_coded and multiple_adv_sets sample. Please consider this as a proof-of-concept.

    The BT_HCI_ERR_CONN_LIMIT_EXCEEDED indicates that controller has not been configured to support multiple connections. But this is strange considering you have set CONFIG_BT_MAX_CONN to 20 already. Can you double check that this is config is applied correctly in your build? I.e. check if CONFIG_BT_MAX_CONN==20 in the .config output in build/zephyr/.config

    peripheral_hr_multilink.zip

Related