|
| 1 | +/* |
| 2 | + * Copyright (c) 2026 Nordic Semiconductor ASA |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause |
| 5 | + */ |
| 6 | + |
| 7 | +/** |
| 8 | + * @file |
| 9 | + * @brief Test utility for dispatching SoftDevice events to registered observers. |
| 10 | + * |
| 11 | + * Allows unit tests to send BLE, SoC, and state events to all observers |
| 12 | + * registered via NRF_SDH_BLE_OBSERVER, NRF_SDH_SOC_OBSERVER, and |
| 13 | + * NRF_SDH_STATE_EVT_OBSERVER without needing to make handler functions |
| 14 | + * non-static or extern. |
| 15 | + */ |
| 16 | + |
| 17 | +#ifndef SDH_EVT_DISPATCH_H__ |
| 18 | +#define SDH_EVT_DISPATCH_H__ |
| 19 | + |
| 20 | +#include <ble.h> |
| 21 | +#include <bm/softdevice_handler/nrf_sdh.h> |
| 22 | + |
| 23 | +#ifdef __cplusplus |
| 24 | +extern "C" { |
| 25 | +#endif |
| 26 | + |
| 27 | +/** |
| 28 | + * @brief Dispatch a BLE event to all registered BLE observers. |
| 29 | + * |
| 30 | + * Iterates the nrf_sdh_ble_evt_observers iterable section and invokes |
| 31 | + * each observer's handler in priority order. |
| 32 | + * |
| 33 | + * @param evt BLE event to dispatch. |
| 34 | + */ |
| 35 | +void sdh_evt_dispatch_ble(const ble_evt_t *evt); |
| 36 | + |
| 37 | +/** |
| 38 | + * @brief Dispatch a SoC event to all registered SoC observers. |
| 39 | + * |
| 40 | + * Iterates the nrf_sdh_soc_evt_observers iterable section and invokes |
| 41 | + * each observer's handler in priority order. |
| 42 | + * |
| 43 | + * @param evt_id SoC event ID to dispatch. |
| 44 | + */ |
| 45 | +void sdh_evt_dispatch_soc(uint32_t evt_id); |
| 46 | + |
| 47 | +/** |
| 48 | + * @brief Dispatch a state event to all registered state observers. |
| 49 | + * |
| 50 | + * Iterates the nrf_sdh_state_evt_observers iterable section and invokes |
| 51 | + * each observer's handler in priority order. |
| 52 | + * |
| 53 | + * @param state State event to dispatch. |
| 54 | + */ |
| 55 | +void sdh_evt_dispatch_state(enum nrf_sdh_state_evt state); |
| 56 | + |
| 57 | +#ifdef __cplusplus |
| 58 | +} |
| 59 | +#endif |
| 60 | + |
| 61 | +#endif /* SDH_EVT_DISPATCH_H__ */ |
0 commit comments