nRF5 SDK v17.0.2
Modules | Data Structures | Functions
SoftDevice Handler

API for initializing and disabling the SoftDevice. More...

Modules

 SoftDevice handler configuration
 
 ANT support in SoftDevice Handler
 This file contains the declarations of types and functions required for ANT stack support.
 
 BLE support in SoftDevice Handler
 This file contains the declarations of types and functions required for BLE stack support.
 
 SoC support in SoftDevice Handler
 This file contains the declarations of types and functions required for SoftDevice Handler SoC support.
 

Data Structures

struct  nrf_sdh_req_observer_t
 SoftDevice Handler state request observer. More...
 
struct  nrf_sdh_state_observer_t
 SoftDevice Handler state observer. More...
 
struct  nrf_sdh_stack_observer_t
 SoftDevice stack event observer. More...
 

Functions

ret_code_t nrf_sdh_enable_request (void)
 Function for requesting to enable the SoftDevice. More...
 
ret_code_t nrf_sdh_disable_request (void)
 Function for requesting to disable the SoftDevice. More...
 
ret_code_t nrf_sdh_request_continue (void)
 Function for restarting the SoftDevice Enable/Disable process. More...
 
bool nrf_sdh_is_enabled (void)
 Function for retrieving the SoftDevice state. More...
 
void nrf_sdh_suspend (void)
 Function for stopping the incoming stack events. More...
 
void nrf_sdh_resume (void)
 Function for resuming polling incoming events from the SoftDevice.
 
bool nrf_sdh_is_suspended (void)
 Function for retrieving the information about the module state. More...
 
void nrf_sdh_evts_poll (void)
 Function for polling stack events from the SoftDevice. More...
 

Softdevice Handler dispatch models

#define NRF_SDH_DISPATCH_MODEL_INTERRUPT   0
 SoftDevice events are passed to the application from the interrupt context.
 
#define NRF_SDH_DISPATCH_MODEL_APPSH   1
 SoftDevice events are passed to the application using Scheduler. More...
 
#define NRF_SDH_DISPATCH_MODEL_POLLING   2
 SoftDevice events are polled manually using nrf_sdh_evts_poll(). More...
 

SoftDevice Handler state change requests

enum  nrf_sdh_req_evt_t {
  NRF_SDH_EVT_ENABLE_REQUEST,
  NRF_SDH_EVT_DISABLE_REQUEST
}
 SoftDevice Handler state requests. More...
 
typedef bool(* nrf_sdh_req_evt_handler_t )(nrf_sdh_req_evt_t request, void *p_context)
 SoftDevice Handler state request handler. More...
 
#define NRF_SDH_REQUEST_OBSERVER(_observer, _prio)
 Macro for registering a SoftDevice state change request observer. More...
 

SoftDevice Handler state events

enum  nrf_sdh_state_evt_t {
  NRF_SDH_EVT_STATE_ENABLE_PREPARE,
  NRF_SDH_EVT_STATE_ENABLED,
  NRF_SDH_EVT_STATE_DISABLE_PREPARE,
  NRF_SDH_EVT_STATE_DISABLED
}
 SoftDevice Handler state events. More...
 
typedef void(* nrf_sdh_state_evt_handler_t )(nrf_sdh_state_evt_t state, void *p_context)
 SoftDevice Handler state event handler.
 
#define NRF_SDH_STATE_OBSERVER(_observer, _prio)
 Macro for registering a SoftDevice state observer. More...
 

SoftDevice stack events

typedef void(* nrf_sdh_stack_evt_handler_t )(void *p_evt)
 SoftDevice stack event handler.
 
#define NRF_SDH_STACK_OBSERVER(_observer, _prio)
 Macro for registering a SoftDevice stack events observer. More...
 

Detailed Description

API for initializing and disabling the SoftDevice.

Macro Definition Documentation

#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]_observerName of the observer.
[in]_prioPriority 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]_observerName of the observer.
[in]_prioPriority 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]_observerName of the observer.
[in]_prioPriority of the observer's event handler. The smaller the number, the higher the priority.

Typedef Documentation

typedef bool(* nrf_sdh_req_evt_handler_t)(nrf_sdh_req_evt_t request, void *p_context)

SoftDevice Handler state request handler.

Return values
trueIf ready for the SoftDevice to change state.
falseIf not ready for the SoftDevice to change state. If false is returned, the state change is aborted.

Enumeration Type Documentation

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 Documentation

ret_code_t nrf_sdh_disable_request ( void  )

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_SUCCESSThe process is started.
NRF_ERROR_INVALID_STATEThe SoftDevice is already disabled.
ret_code_t nrf_sdh_enable_request ( void  )

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_SUCCESSThe process is started.
NRF_ERROR_INVALID_STATEThe 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
trueIf the SoftDevice is enabled.
falseIf the SoftDevice is disabled.
bool nrf_sdh_is_suspended ( void  )

Function for retrieving the information about the module state.

Return values
trueThe SoftDevice handler is paused, and it will not fetch events from the stack.
falseThe SoftDevice handler is running, and it will fetch and dispatch events from the stack to the registered stack observers.
ret_code_t nrf_sdh_request_continue ( void  )

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_SUCCESSThe process is restarted.
NRF_ERROR_INVALID_STATENo 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.


Documentation feedback | Developer Zone | Subscribe | Updated