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

how to Restart advertising after timeout?

Could you give me an example how to restart advertising after timeout.

thank.

sorry, i need on the button event to restart advertising.

Parents
  • Hi,

    just start advertising again upon BLE_ADV_EVT_IDLE in advertising event handler.

    static void on_adv_evt(ble_adv_evt_t ble_adv_evt) {
      ret_code_t err_code;
      switch (ble_adv_evt) {
        case BLE_ADV_EVT_IDLE:
          err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
          APP_ERROR_CHECK(err_code);
          break;
      }
    }
    

    Yurii

  • This worked for me !!! But there was slight change in this 

    static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
    {
    uint32_t err_code;

    switch (ble_adv_evt)
    {

    case BLE_ADV_EVT_IDLE:
    err_code = ble_advertising_start(&m_advertising,BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    break;

    case BLE_ADV_EVT_FAST:
    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
    APP_ERROR_CHECK(err_code);
    break;

    default:
    break;
    }
    }

    Thank you so much!!!!!

Reply
  • This worked for me !!! But there was slight change in this 

    static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
    {
    uint32_t err_code;

    switch (ble_adv_evt)
    {

    case BLE_ADV_EVT_IDLE:
    err_code = ble_advertising_start(&m_advertising,BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    break;

    case BLE_ADV_EVT_FAST:
    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
    APP_ERROR_CHECK(err_code);
    break;

    default:
    break;
    }
    }

    Thank you so much!!!!!

Children
No Data
Related