Not possible to re-start advertising

With the latest SDK 2.6.0, I am developing from the existing NRF5340 audio application for a receiver, to allow an ACL connection from a mobile app. Advertising starts fine, connection gets established from the central app without issues. 

The problem I am having is that when the app manually disconnects itself from the receiver, advertising tries to start again, but can not with the following issue : 

<err> bt_mgmt_adv: Failed to start advertising set. Err: -12

This means not enough core. 

I have tried to resolve this by calling bt_le_ext_adv_stop() and even bt_le_ext_adv_delete() in bt_mgmt_adv_start() before bt_le_ext_adv_create() gets called. This didn't solve it.

I have also tried to solve it by calling bt_le_ext_adv_stop() right before bt_le_ext_adv_start() inside advertising_process().

The same -12 error occurs no matter what. Everything else inside advertising_process() executes without an error , and only bt_le_ext_adv_start() fails. 

At this stage i'm not sure if it's an issue with the SDK or I am doing something wrong. Thanks in advance for any support. 

Parents Reply Children
  • Hi Paul,

    We're currently short on staff due to the Easter Holiday,

    You can expect an answer sometime next week,

    Thank you for your patience,

    regards

    Jared 

  • Hi Paul

    Sorry for the slow response. Are you still having issues with this? 

    muli said:
    If you look at disconnected_cb() in bt_mgmt.c, it is already implemented there from Nordic, to start advertising by calling bt_mgmt_adv_start() 

    You are correct of course. 

    bt_mgmt_adv_start(..) will only start advertising indirectly, by submitting to the adv_work work item which in turn will call the advertising_process(..) function from the system workqueue. 

    As such you should be able to call this function either from interrupt or thread context. 

    Do you know what the BT_MAX_CONN configuration is set to in your application? 

    Could you try to add a breakpoint on this line and see if this is where the -12 (ENOMEM) error originates? 

    If that is the case I am wondering if the issue is that the connection is not yet freed up, and as such you get a ENOMEM error when trying to restart the advertising. 

    Best regards
    Torbjørn

  • Hi  

    This is very interesting actually:) 

    I set the BT_MAX_CONN to 4 in my proj.conf file. 

    Now I can disconnect and reconnect 4 times until I get an ENOMEM on that line you mentioned. 

    So clearly the connection isn't getting cleared up as expected each time. 

    Update : I wasn't un-referencing the connection in the disconnected callback.

    Problem solved. Thank you.  

  • Hi Paul 

    Very good to hear that you found the issue. I will close the ticket then Slight smile

    Best regards
    Torbjørn

Related