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

How to change advertising interval run time with SDK 15.2.0

Hi, I am using nrf52832 with SDK 15.2.0 and nrf 52 dev board. I  want change advertising interval in run time so I call a function with the interval as the parameter change_adv_interval (interval ) every time that I will change.

Thanks in Advance.

Parents
  • Hi Prashant

    You need to stop and start the advertising when you do your updates. It should be possible with something similar to this:

    sd_ble_gap_adv_stop();
    
    ble_gap_adv_params_t adv_params;
    memset(&adv_params, 0, sizeof(adv_params));
    adv_params.interval = interval;
    adv_params.timeout = 0;
    
    err_code = sd_ble_gap_adv_start(&adv_params);
    APP_ERROR_CHECK(err_code);

    Best regards,

    Simon

  • Hi Simon,

    I am using SDK16 and NRF52 DK. My goal is to update advertising interval in non-connectable mode dynamically. I don't use advertising module and I am following code from pwr_profiling example to setup advertisement parameters.

    In order to update the advertising interval, I wrote a function which stops advertising and then updates the interval and calls the function sd_ble_gap_adv_set_configure. I have thought of another approach too and it's commented down there.

    However, the function sd_ble_gap_adv_stop fails without any return code. I tried to set a breakpoint and debug, but in vain. Let me know if it is necessary to stop advertisement for this use-case in SDK16 and how to update update advertising interval dynamically. And as well as a technique to debug and find error code.

    void non_conn_adv_interval_update(int8_t m_adv_interval)
    {
          ret_code_t      err_code;
          err_code = sd_ble_gap_adv_stop(m_adv_handle);
          APP_ERROR_CHECK(err_code);
    
          // Approach 1 : 
          NRF_LOG_INFO("Adv interval : %d", m_adv_interval);
          m_adv_params.interval        = m_adv_interval;
          err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
          APP_ERROR_CHECK(err_code);
    
          // Approach 2:
          //non_connectable_adv_init(m_adv_interval);
          //advertising_start(true);
    
    }

    Regards,

    Dino

Reply
  • Hi Simon,

    I am using SDK16 and NRF52 DK. My goal is to update advertising interval in non-connectable mode dynamically. I don't use advertising module and I am following code from pwr_profiling example to setup advertisement parameters.

    In order to update the advertising interval, I wrote a function which stops advertising and then updates the interval and calls the function sd_ble_gap_adv_set_configure. I have thought of another approach too and it's commented down there.

    However, the function sd_ble_gap_adv_stop fails without any return code. I tried to set a breakpoint and debug, but in vain. Let me know if it is necessary to stop advertisement for this use-case in SDK16 and how to update update advertising interval dynamically. And as well as a technique to debug and find error code.

    void non_conn_adv_interval_update(int8_t m_adv_interval)
    {
          ret_code_t      err_code;
          err_code = sd_ble_gap_adv_stop(m_adv_handle);
          APP_ERROR_CHECK(err_code);
    
          // Approach 1 : 
          NRF_LOG_INFO("Adv interval : %d", m_adv_interval);
          m_adv_params.interval        = m_adv_interval;
          err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
          APP_ERROR_CHECK(err_code);
    
          // Approach 2:
          //non_connectable_adv_init(m_adv_interval);
          //advertising_start(true);
    
    }

    Regards,

    Dino

Children
No Data
Related