nRF51 SDK
|
This library is used for initializing and disabling the SoftDevice and also propagating SoftDevice events to the application.
This library module contains the following functionalities.
Depending on the type of SoftDevice, the APIs used to fetch events from it will vary. For example, the S110 SoftDevice exposes 2 APIs - sd_ble_evt_get for fetching BLE events and sd_evt_get for fetching System (SOC) events. But the S210 SoftDevice does not have an API named sd_ble_evt_get. Instead it exposes sd_ant_event_get for fetching ANT events and sd_evt_get for fetching System (SOC) events. Depending on the type of SoftDevice, SoftDevice Handler Library helps the application use the correct APIs for fetching SoftDevice events.
The API exposed by this module is present in softdevice_handler.h, ant_stack_handler_types.h, and ble_stack_handler_types.h.
This module has the following expectations from the application.
This module uses conditional compilation. It expects certain preprocessor macros to be defined as follows.
The application should subscribe for events using the function softdevice_xxx_evt_handler_set, where xxx can be ble (for BLE events), ant (for ANT events), or sys (for system (SOC) events).
When the application needs to disable the SoftDevice, it must use the function softdevice_handler_sd_disable and not directly call the function sd_softdevice_disable that is provided by the SoftDevice. If this is not done, this module will not be aware that the SoftDevice was disabled. This will result in the SoftDevice returning the error code NRF_ERROR_SOFTDEVICE_NOT_ENABLED when this module tries to fetch BLE or ANT events. This in turn will result in a call to app_error_handler function defined by the application.
Similarly, if the application needs to enable the SoftDevice, it must do so using the function softdevice_handler_init function. If this is not done, this module will never fetch the BLE or ANT events.