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

Advertising forever

I want my client to advertise forever so I added the following code:

static void ble_evt_dispatch(ble_evt_t * p_ble_evt)
{
    ble_conn_params_on_ble_evt(p_ble_evt);
    ble_nus_on_ble_evt(&m_nus, p_ble_evt);
	  // Advertise forever
	  if (p_ble_evt->header.evt_id == BLE_GAP_EVT_TIMEOUT) {
          APP_ERROR_CHECK(ble_advertising_start(BLE_ADV_MODE_FAST));
      }
      else {
			on_ble_evt(p_ble_evt);
      }
    ble_advertising_on_ble_evt(p_ble_evt);
    // bsp_btn_ble_on_ble_evt(p_ble_evt);
    
}

When the initial fast-mode advertising finishes, this code calls ble_advertising_start but then hangs. Is there another method to do this?

Parents
  • Are you saying that there is a setting of advertising parameters that will cause the logic in ble_advertising_on_ble_evt to advertise forever? I took a look at the code in that function. There's a case BLE_GAP_EVT_TIMEOUT where I believe the advertising should restart. But it looks like that logic does FAST, then SLOW, then IDLE and there's no way to set parameters to keep advertising either fast or slow without changing the function. I'm not very excited about the prospect of changing code that's outside my application and part of the API. How would I merge my changes to ble_advertising.c if Nordic releases a new version of that file?

Reply
  • Are you saying that there is a setting of advertising parameters that will cause the logic in ble_advertising_on_ble_evt to advertise forever? I took a look at the code in that function. There's a case BLE_GAP_EVT_TIMEOUT where I believe the advertising should restart. But it looks like that logic does FAST, then SLOW, then IDLE and there's no way to set parameters to keep advertising either fast or slow without changing the function. I'm not very excited about the prospect of changing code that's outside my application and part of the API. How would I merge my changes to ble_advertising.c if Nordic releases a new version of that file?

Children
No Data
Related