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

Difficulties with BLE_ADV_EVT_SLOW occurring.

I am not seeing a transition to BLE_ADV_EVT_SLOW.  The transition I see goes from FAST to idle, without a transition to slow, from the configuration I don't expect to be in IDLE.

init.config.ble_adv_fast_enabled = true;
init.config.ble_adv_fast_interval = app_data.advfast_interval;
init.config.ble_adv_fast_timeout = app_data.advfast_timeout;

init.config.ble_adv_slow_enabled = true;
init.config.ble_adv_slow_interval = app_data.advslow_interval;
init.config.ble_adv_slow_timeout = 0;

err_code = ble_advertising_init(&m_advertising, &init);
APP_ERROR_CHECK(err_code);

Have placed some debug logs to see the transitions:


static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
  switch (ble_adv_evt)
  { 
    case BLE_ADV_EVT_FAST:
    NRF_LOG_INFO( "BLE_ADV_EVT_FAST:" );
    LEDS( if( m_led_on ) bsp_board_led_on(ADVERTISING_LED) );
    break;

    case BLE_ADV_EVT_SLOW:
      NRF_LOG_INFO( "BLE_ADV_EVT_SLOW:" );
      break;

    case BLE_ADV_EVT_IDLE:
      NRF_LOG_INFO( "BLE_ADV_EVT_IDLE:" );
      advertising_start( false );
      break;

    default:
    break;
  }

}

The log output I receive show:

<info> app: BLE_ADV_EVT_FAST:
<info> app: BLE_ADV_EVT_IDLE:
<info> app: BLE_ADV_EVT_FAST:
<info> app: BLE_ADV_EVT_IDLE:
<info> app: BLE_ADV_EVT_FAST:
<info> app: BLE_ADV_EVT_IDLE:
<info> app: BLE_ADV_EVT_FAST:
<info> app: BLE_ADV_EVT_IDLE:
<info> app: BLE_ADV_EVT_FAST:
<info> app: BLE_ADV_EVT_IDLE:
<info> app: BLE_ADV_EVT_FAST:

This is with a S140 release of the SDK.

Parents
  • Hi Robert,

    Some questions:

    • You have tagged this case with nRF52832, but you use s140 ? (that does not compatible -> s140 is for nRF52840 and s132 is for nRF52832)
    • What SDK version are you using and what example are you basing your application on?

    what is inside your advertising_start() function?

    What are you trying to achieve? 

     

  • Sorry, it is S132 what I had downloaded was a 14.0 SDK.  What I have was originally based on the NUS example for a peripheral.  

    static void advertising_init(void)
    {
      uint32_t err_code;
      ble_advertising_init_t init;
      memset( &init, 0, sizeof(init) );

      init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
      init.advdata.include_appearance = false;
      init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;

      init.srdata.uuids_complete.uuid_cnt = NUM_ELEMENTS( m_adv_uuids );
      init.srdata.uuids_complete.p_uuids = m_adv_uuids;
      init.evt_handler = on_adv_evt;

      init.config.ble_adv_fast_enabled = true;
      Init.config.ble_adv_fast_interval = app_data.advfast_interval;
      init.config.ble_adv_fast_timeout = app_data.advfast_timeout;

      init.config.ble_adv_slow_enabled = true;
      init.config.ble_adv_slow_interval = app_data.advslow_interval;
      init.config.ble_adv_slow_timeout = 0;

      err_code = ble_advertising_init(&m_advertising, &init);
      APP_ERROR_CHECK(err_code);

      ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

    The desired outcome was to be allow the fast period to be able to run for a limited amount of time followed by the slow which would advertise at a lower rate until connected.  When advertising in FAST, a higher tx power is used to allow for a longer range for reconnection, when transitioning to SLOW a lower tx power will be set forcing the central to be closer to establish an initial connection.  Upon connection the tx power is increased allowing the range to extend again.

Reply
  • Sorry, it is S132 what I had downloaded was a 14.0 SDK.  What I have was originally based on the NUS example for a peripheral.  

    static void advertising_init(void)
    {
      uint32_t err_code;
      ble_advertising_init_t init;
      memset( &init, 0, sizeof(init) );

      init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
      init.advdata.include_appearance = false;
      init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;

      init.srdata.uuids_complete.uuid_cnt = NUM_ELEMENTS( m_adv_uuids );
      init.srdata.uuids_complete.p_uuids = m_adv_uuids;
      init.evt_handler = on_adv_evt;

      init.config.ble_adv_fast_enabled = true;
      Init.config.ble_adv_fast_interval = app_data.advfast_interval;
      init.config.ble_adv_fast_timeout = app_data.advfast_timeout;

      init.config.ble_adv_slow_enabled = true;
      init.config.ble_adv_slow_interval = app_data.advslow_interval;
      init.config.ble_adv_slow_timeout = 0;

      err_code = ble_advertising_init(&m_advertising, &init);
      APP_ERROR_CHECK(err_code);

      ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

    The desired outcome was to be allow the fast period to be able to run for a limited amount of time followed by the slow which would advertise at a lower rate until connected.  When advertising in FAST, a higher tx power is used to allow for a longer range for reconnection, when transitioning to SLOW a lower tx power will be set forcing the central to be closer to establish an initial connection.  Upon connection the tx power is increased allowing the range to extend again.

Children
  • By changing advdata.flags to BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE, I now see the device transitioning from FAST to SLOW, however with a slow timeout of 0 I still see a transition to IDLE which is unexpected.  I believe a timeout of 0 should not timeout.

  • Correct, having the timeout set to zero will not make it timeout. The reason why you transition to IDLE must come from something else. 
    I just tested this with the standard "ble_app_uart" example and added the following to the advertising_init():

    and transitioned to BLE_ADV_EVT_SLOW after my desired "APP_ADV_TIMEOUT_IN_SECONDS". (and it did not go into IDLE)

    please take an extra look in the Advertising Module documentation

  • This is the same, advertising slow interval is 3200, should be 2s.  I don't do anything with the events in on_adv_evt, the device appears to still advertise in slow until connected.  I just don't understand why I see a transition through IDLE.

    static void advertising_init(void)
    {
      uint32_t err_code;
      ble_advertising_init_t init;
      memset( &init, 0, sizeof(init) );

      init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
      init.advdata.include_appearance = false;
      init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

      init.srdata.uuids_complete.uuid_cnt = NUM_ELEMENTS( m_adv_uuids );
      init.srdata.uuids_complete.p_uuids = m_adv_uuids;
      init.evt_handler = on_adv_evt;

    #ifdef _NOTIFY_
      ble_advdata_manuf_data_t manuf_data;
      manuf_data.company_identifier = 0xFFFF; // ID not obtained yet
      manuf_data.data.p_data = (uint8_t *)&m_notification_info;
      manuf_data.data.size = sizeof( m_notification_info );
      Init.advdata.p_manuf_specific_data = &manuf_data;
    #endif

      init.config.ble_adv_fast_enabled = true;
      init.config.ble_adv_fast_interval = app_data.advfast_interval;
      init.config.ble_adv_fast_timeout = app_data.advfast_timeout;

      init.config.ble_adv_slow_enabled = true;
      init.config.ble_adv_slow_interval = app_data.advslow_interval;
      init.config.ble_adv_slow_timeout = 0;

      err_code = ble_advertising_init(&m_advertising, &init);
      APP_ERROR_CHECK(err_code);

      ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

  • Hello Robert,

    Have you tested out what I did in the last post I made?

    Because I did not get the issue you describe. 

  • I have...the actual code I was using at the time is posted above, it already had a change similar to yours.  I still see a transition to the IDLE event however advertising does not stop.  Changing to general discovery corrected the issue where advertising was stopping.

Related