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

Infinite, slow adversiting?

I am trying to make my NRF 51 advertise forever till someone connects. I have based myself on the ble_uart example where it uses fast advertising with 40 ms intervals for 180 seconds.

Now, I changed to slow advertising with 2000 ms intervals, but BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED (0) seems to have no effect. Then it simply doesn't advertise.

And what kind of advertising would be the most low power one? What is the max interval I can advertise on etc? And I guess you have to advertise in order to even connect to it? Is what I am doing a good practice at all? Or are most cases based on the fact that you have to push reset / reactivate advertisement before connecting?

Thanks :-)

Code:

  uint32_t      err_code;
   ble_advdata_t advdata;
   ble_advdata_t scanrsp;

   // Build advertising data struct to pass into @ref ble_advertising_init.
   memset(&advdata, 0, sizeof(advdata));
   advdata.name_type          = BLE_ADVDATA_FULL_NAME;
   advdata.include_appearance = false;
   advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
  
   memset(&scanrsp, 0, sizeof(scanrsp));
   scanrsp.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
   scanrsp.uuids_complete.p_uuids  = m_adv_uuids;
  
   ble_adv_modes_config_t options = {0};
   /*options.ble_adv_fast_enabled  = BLE_ADV_FAST_ENABLED;
   options.ble_adv_fast_interval = APP_ADV_INTERVAL;
   options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;*/
        
  options.ble_adv_slow_enabled = BLE_ADV_SLOW_ENABLED;
  options.ble_adv_slow_interval = 3200;
  options.ble_adv_slow_timeout = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED;
  
   err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
   APP_ERROR_CHECK(err_code);
Parents Reply
  • No the constant is correct - it's what you put in the ble_gap_adv_params_t structure you pass to advertising start, zero means forever and it's documented there somewhere. The wrapper library just copies whatever is in the fast_timeout or slow_timeout to the structure when it starts advertising so you'd expect that constant to work the same way with the library. However zero is disallowed and turns advertising off completely for that mode.

Children
No Data
Related