I tried code like
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
....
case BLE_GAP_EVT_TIMEOUT:
if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT)
{
err_code = sd_ble_gap_adv_stop(); // Stop advertising if not connected in limited time
APP_ERROR_CHECK(err_code);
}
break;
....
}
However, it returned error NRF_ERROR_INVALID_STATE
.
Is there any other way to stop advertising just after timeout? Thanks.