Why does advertising stop when a device connects successfully?


I am comparing an old implemtation based on Zephyr 2.7.1 for nRF52832 with examples for nRF5340. On both devices there are more than 1 connection allowed.

On the older Zephyr 2.7.1 based implentation I see the device is advertising even when someone connects to the device. I use two phones with nRF connect App. One is for showing the RSSI graph and the other one connects to the BLE device. When the one phone connects to the device, I see RSSI updates on the other phone.

I am trying different samples for the nRF5340 DK board. For example multiple_adv_set sample. There is 'Nordic Beacon' (non-connectable) and 'Nordic multi-adv-sets' (connectable) advertised. When the one phone connects to the 'Nordic multi adv sets', the other phone stops updating RSSI values - as long as the connections stays active. When I disconnect, the RSSI values show up again. So I asssume that advertising is stopped while a device is connected - but I do not know why. And why does it work on older Zephyr 2.7.1 implementation. Can someone help me on this?

  • Hi Lexologe, 

    Please correct me if I'm wrong. In your test with two phones and multi-adv-sets sample, you still can see Nordic Beacon advertising on the other phone after you connect to Nordic Multi Adv Set on the first phone, correct ? 

    I assume you are asking about if you should still see Nordic Multi Adv Set after you connect to the same advertiser. I think the logic  has been changed. That you need to manually restart the advertising after it get connected on the same adv set. 
    I don't know when the behavior changed, but now you need to restart the advertising manually in the code to be able to advertise after the device is connected.  

  • Hi  ,

    yes, I can still see the Nordic Beacon - but I am not really interested in the Beacon. You're right, I expect to still see the Nordic Multi Adv Set that advertises. I tried to restart the advertising in the connected handler. But that returns error -12 (ENOMEM). The same call k_work_submit(&advertising_work) does work in the disconnected handler. Can you point me to some example code where I can see how the advertising can be restarted manually?

  • Hi again, 
    Please take a look at this course: 


    At section 3.5 I have an explanation for that: 

    We submit a work item here because if we call bt_le_adv_start() directly in callback we will receive an -ENOMEM error (-12). This is because in the disconnected() callback, the connection object is still reserved for the connection that was just terminated. If we start advertising here, we will need to increase the maximum number of connections (CONFIG_BT_MAX_CONN) by one., in our case, it would need to be two. In order to save on RAM, we submit a work item using k_work_submit that will delay starting advertising until after the callback has returned.

Reply Children
  • Thanks for your hint to that course. I increased the CONFIG_BT_MAX_CONN but the -ENOMEM (-12) does not disappear. I assume that it is not allowed somehow to start the advertising when a connection is active.

    Later in the course there is a part about filter lists. In this part the advertising is started again to allow another device to bond - but only if the first bonded device is not connected anymore. It seems to be like you are allowed to be connected with more than one device at the same time - but these devices need to be bonded one after another before.

  • Hi, 

    It's in the documentation for CONFIG_BT_MAX_CONN : 

    Maximum number of simultaneous connections

    Type: int

    Value: 2

    When using the SoftDevice controller, the application needs to configure the number of peripheral and central links explicity. See BT_CTLR_SDC_PERIPHERAL_COUNT

    Maximum number of simultaneous Bluetooth connections supported.

  • Thank you. That was the hint I've been searching for. Found it in Kconfig help of CONFIG_BT_MAX_CONN

    I set the value in hci_rpmsg.conf to be the same as CONFIG_BT_MAX_CONN and it works. The device advertises after I connect to the device.

    Thanks for your help