This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF_ERROR_BUSY returned, re-starting BLE beacon advertising

Hey guys,

Working with the simple be_app_beacon example on nRF51. I’d like to be able to stop and start advertising. But after stopping advertising, I’m unable to start it again. On the call to start advertising I’m getting an err_code of NRF_ERROR_BUSY.

I’m guessing the structure of the code here isn’t allowing the BLE stack to process the previous call to stop the advertising, before I try to start it again. Is there a really simple, nice way to fix this? It's just a basic NON connectable beacon. See simplified code below in my main loop.

Sorry for the newb question. Hoping to keep the code really clean. Much appreciated.

Thanks, Brian

main() {

ble_stack_init();

adv_beacon_init();

advertising_start();

delay_flag = FALSE;

app_timer_start(…); // sets delay_flag to FALSE after 1 second

while(delay_flag) power_manage();

sd_ble_gap_adv_stop();

//do stuff here… not BLE related

err_code = sd_ble_gap_adv_start(); //!!! here’s where err_code == NRF_ERROR_BUSY

//do more stuff, then call sd_power_system_off();

}

Parents
  • Hi Petter,

    Thanks for the response. I figured something out:

    The settings causing this behavior are:

    #define APP_CFG_NON_CONN_ADV_TIMEOUT  1
    #define NON_CONNECTABLE_ADV_INTERVAL    MSEC_TO_UNITS(1000, UNIT_0_625_MS) 
    

    If I change to:

    #define APP_CFG_NON_CONN_ADV_TIMEOUT  0
    #define NON_CONNECTABLE_ADV_INTERVAL    MSEC_TO_UNITS(1000, UNIT_0_625_MS) 
    

    Then no problem. Why is this? I'm trying to just send one advertisement per second, but be able to start and stop. Should these settings also send just one advertisement per sec?

    Thanks, Brian

Reply
  • Hi Petter,

    Thanks for the response. I figured something out:

    The settings causing this behavior are:

    #define APP_CFG_NON_CONN_ADV_TIMEOUT  1
    #define NON_CONNECTABLE_ADV_INTERVAL    MSEC_TO_UNITS(1000, UNIT_0_625_MS) 
    

    If I change to:

    #define APP_CFG_NON_CONN_ADV_TIMEOUT  0
    #define NON_CONNECTABLE_ADV_INTERVAL    MSEC_TO_UNITS(1000, UNIT_0_625_MS) 
    

    Then no problem. Why is this? I'm trying to just send one advertisement per second, but be able to start and stop. Should these settings also send just one advertisement per sec?

    Thanks, Brian

Children
No Data
Related