API for initializing and disabling the SoftDevice.
More...
API for initializing and disabling the SoftDevice.
#define NRF_SDH_DISPATCH_MODEL_APPSH 1 |
SoftDevice events are passed to the application using Scheduler.
- Note
- Scheduler must be initialized before enabling the SoftDevice handler.
#define NRF_SDH_DISPATCH_MODEL_POLLING 2 |
SoftDevice events are polled manually using nrf_sdh_evts_poll().
- Note
- In this mode, a user application can also implement SD_EVT_IRQHandler() to receive a notification about incoming events.
#define NRF_SDH_REQUEST_OBSERVER |
( |
|
_observer, |
|
|
|
_prio |
|
) |
| |
Macro for registering a SoftDevice state change request observer.
An observer of SoftDevice state change requests receives requests to change the state of the SoftDevice from enabled to disabled and vice versa. These requests may or may not be acknowledged by the observer, depending on the value returned by its request handler function. Thus, a request observer has the capability to defer the change of state of the SoftDevice. If it does so, it has the responsibility to call nrf_sdh_request_continue when it is ready to let the SoftDevice change its state. If such capability is not necessary and you only need to be informed about changes of the SoftDevice state, use the NRF_SDH_STATE_OBSERVER macro instead.
- Note
- This macro places the observer in a section named "sdh_req_observers".
- Parameters
-
[in] | _observer | Name of the observer. |
[in] | _prio | Priority of the observer's event handler. The smaller the number, the higher the priority. |
#define NRF_SDH_STACK_OBSERVER |
( |
|
_observer, |
|
|
|
_prio |
|
) |
| |
Macro for registering a SoftDevice stack events observer.
A SoftDevice stack event observer receives all events from the SoftDevice. These events can be either BLE, ANT, or SoC events. If you need to receive BLE, ANT, or SoC events separately, use the NRF_SDH_BLE_OBSERVER, NRF_SDH_ANT_OBSERVER, or NRF_SDH_SOC_OBSERVER macros respectively.
- Note
- This macro places the observer in a section named "sdh_stack_observers".
- Parameters
-
[in] | _observer | Name of the observer. |
[in] | _prio | Priority of the observer's event handler. The smaller the number, the higher the priority. |
#define NRF_SDH_STATE_OBSERVER |
( |
|
_observer, |
|
|
|
_prio |
|
) |
| |
Macro for registering a SoftDevice state observer.
A SoftDevice state observer receives events when the SoftDevice state has changed or is about to change. These events are only meant to inform the state observer, which, contrary to a state change request observer, does not have the capability to defer the change of state. If such capability is required, use the NRF_SDH_REQUEST_OBSERVER macro instead.
This macro places the observer in a section named "sdh_state_observers".
- Parameters
-
[in] | _observer | Name of the observer. |
[in] | _prio | Priority of the observer's event handler. The smaller the number, the higher the priority. |
typedef bool(* nrf_sdh_req_evt_handler_t)(nrf_sdh_req_evt_t request, void *p_context) |
SoftDevice Handler state request handler.
- Return values
-
true | If ready for the SoftDevice to change state. |
false | If not ready for the SoftDevice to change state. If false is returned, the state change is aborted. |
SoftDevice Handler state requests.
Enumerator |
---|
NRF_SDH_EVT_ENABLE_REQUEST |
Request to enable the SoftDevice.
|
NRF_SDH_EVT_DISABLE_REQUEST |
Request to disable the SoftDevice.
|
SoftDevice Handler state events.
Enumerator |
---|
NRF_SDH_EVT_STATE_ENABLE_PREPARE |
SoftDevice is going to be enabled.
|
NRF_SDH_EVT_STATE_ENABLED |
SoftDevice is enabled.
|
NRF_SDH_EVT_STATE_DISABLE_PREPARE |
SoftDevice is going to be disabled.
|
NRF_SDH_EVT_STATE_DISABLED |
SoftDevice is disabled.
|
Function for requesting to disable the SoftDevice.
This function issues a NRF_SDH_EVT_DISABLE_REQUEST request to all observers that were registered using the NRF_SDH_REQUEST_OBSERVER macro. The observers may or may not acknowledge the request. If all observers acknowledge the request, the SoftDevice will be disabled. Otherwise, the process will be stopped and the observers that did not acknowledge have the responsibility to restart it by calling nrf_sdh_request_continue when they are ready for the SoftDevice to change state.
- Return values
-
NRF_SUCCESS | The process is started. |
NRF_ERROR_INVALID_STATE | The SoftDevice is already disabled. |
Function for requesting to enable the SoftDevice.
This function issues a NRF_SDH_EVT_ENABLE_REQUEST request to all observers that were registered using the NRF_SDH_REQUEST_OBSERVER macro. The observers may or may not acknowledge the request. If all observers acknowledge the request, the SoftDevice will be enabled. Otherwise, the process will be stopped and the observers that did not acknowledge have the responsibility to restart it by calling nrf_sdh_request_continue when they are ready for the SoftDevice to change state.
- Return values
-
NRF_SUCCESS | The process is started. |
NRF_ERROR_INVALID_STATE | The SoftDevice is already enabled. |
void nrf_sdh_evts_poll |
( |
void |
| ) |
|
Function for polling stack events from the SoftDevice.
The events are passed to the application using the registered event handlers.
- Note
- NRF_SDH_DISPATCH_MODEL_POLLING must be selected to use this function.
bool nrf_sdh_is_enabled |
( |
void |
| ) |
|
Function for retrieving the SoftDevice state.
- Return values
-
true | If the SoftDevice is enabled. |
false | If the SoftDevice is disabled. |
bool nrf_sdh_is_suspended |
( |
void |
| ) |
|
Function for retrieving the information about the module state.
- Return values
-
true | The SoftDevice handler is paused, and it will not fetch events from the stack. |
false | The SoftDevice handler is running, and it will fetch and dispatch events from the stack to the registered stack observers. |
Function for restarting the SoftDevice Enable/Disable process.
Modules which did not acknowledge a NRF_SDH_EVT_ENABLE_REQUEST or NRF_SDH_EVT_DISABLE_REQUEST request must call this function to restart the SoftDevice state change process.
- Return values
-
NRF_SUCCESS | The process is restarted. |
NRF_ERROR_INVALID_STATE | No state change request was pending. |
void nrf_sdh_suspend |
( |
void |
| ) |
|
Function for stopping the incoming stack events.
This function disables the SoftDevice interrupt. To resume polling for events, call nrf_sdh_resume.