Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
/lib/bluetooth/ble_gq/ @nrfconnect/ncs-bm
/lib/bluetooth/ble_qwr/ @nrfconnect/ncs-bm
/lib/bluetooth/ble_racp/ @nrfconnect/ncs-bm
/lib/bluetooth/ble_radio_notification/ @nrfconnect/ncs-bm
/lib/bluetooth/peer_manager/ @nrfconnect/ncs-bm
/lib/bm_buttons/ @nrfconnect/ncs-bm
/lib/bm_timer/ @nrfconnect/ncs-bm
Expand Down Expand Up @@ -89,10 +90,11 @@
/sysbuild/ @nrfconnect/ncs-co-build-system

# Tests
/tests/lib/bluetooth/ble_adv/ @nrfconnect/ncs-bm-test
/tests/lib/bluetooth/ble_conn_state/ @nrfconnect/ncs-bm
/tests/lib/bluetooth/ble_qwr/ @nrfconnect/ncs-bm
/tests/lib/bluetooth/ble_racp/ @nrfconnect/ncs-bm
/tests/lib/bluetooth/ble_adv/ @nrfconnect/ncs-bm-test
/tests/lib/bluetooth/ble_radio_notif/ @nrfconnect/ncs-bm
/tests/subsys/bluetooth/services/ @nrfconnect/ncs-bm @nrfconnect/ncs-bm-test
/tests/subsys/fs/bm_zms/ @nrfconnect/ncs-bm @rghaddab
/tests/subsys/storage/bm_storage/ @nrfconnect/ncs-bm
Expand Down
9 changes: 9 additions & 0 deletions doc/nrf-bm/api/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ Bluetooth LE Connection State library
:inner:
:members:

.. _api_ble_radio_notif:

Bluetooth LE Radio Notification library
=======================================

.. doxygengroup:: ble_radio_notification
:inner:
:members:

Bare Metal Buttons library
==========================

Expand Down
55 changes: 55 additions & 0 deletions doc/nrf-bm/libraries/ble_radio_notification.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.. _lib_ble_radio_notification:

Bluetooth: Radio Notification
#############################

.. contents::
:local:
:depth: 2

The Bluetooth Low Energy® Radio Notification library allows the user to subscribe to the Radio Notification signal to receive notifications before and after radio events.

Overview
********

The library allows the user to register a handler to receive radio notifications and configure the distance in microseconds between the active Radio Notification signal and the radio event.

Configuration
*************

The library is enabled and configured entirely using the Kconfig system.
Set the :kconfig:option:`CONFIG_BLE_RADIO_NOTIFICATION` Kconfig option to enable the library.

The library uses the ``SWI02`` IRQ.
Use the :kconfig:option:`CONFIG_BLE_RADIO_NOTIFICATION_IRQ_PRIO` Kconfig option to set the IRQ priority.
The library can be configured to receive notifications before the radio is active, after the radio is active, or both before and after.
This can be chosen by setting the :kconfig:option:`CONFIG_BLE_RADIO_NOTIFICATION_ON_ACTIVE`, the :kconfig:option:`CONFIG_BLE_RADIO_NOTIFICATION_ON_INACTIVE`, or the :kconfig:option:`CONFIG_BLE_RADIO_NOTIFICATION_ON_BOTH` Kconfig option, respectively.

Initialization
==============

The library is initialized by calling the :c:func:`ble_radio_notification_init` function.

Usage
*****

Initialize the library by calling the :c:func:`ble_radio_notification_init` function, specifying the event handler to receive the Radio Notification signal.
You can specify the distance in microseconds between the Radio Notification signal and the start of the radio event.
The signal raised at the start of the radio event has ``active_state`` set to ``true``.
A new Radio Notification signal will be raised when the radio event completes with ``active_state`` set to ``false``.

Dependencies
************

This library uses the following |BMshort| libraries:

* SoftDevice - :kconfig:option:`CONFIG_SOFTDEVICE`
* SoftDevice handler - :kconfig:option:`CONFIG_NRF_SDH`

API documentation
*****************

| Header file: :file:`include/bm/bluetooth/ble_radio_notification.h`
| Source files: :file:`lib/bluetooth/ble_radio_notification/`

:ref:`Bluetooth LE Radio Notification library API reference <api_ble_radio_notif>`
4 changes: 3 additions & 1 deletion doc/nrf-bm/release_notes/release_notes_changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ No changes since the latest nRF Connect SDK Bare Metal release.
Libraries
=========

* Added the :ref:`lib_ble_radio_notification` library.

* :ref:`lib_ble_conn_params` library:

* Added missing Kconfig dependencies.
Expand All @@ -88,7 +90,7 @@ Samples
Bluetooth samples
-----------------

No changes since the latest nRF Connect SDK Bare Metal release.
Added the :ref:`ble_radio_ntf_sample` sample.

Peripheral samples
------------------
Expand Down
55 changes: 55 additions & 0 deletions include/bm/bluetooth/ble_radio_notification.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2018-2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/** @file
*
* @defgroup ble_radio_notification Radio Notification
* @{
*
* @brief Module for propagating Radio Notification events to the application.
*/

#ifndef BLE_RADIO_NOTIFICATION_H__
#define BLE_RADIO_NOTIFICATION_H__

#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

/** @brief Application radio notification event handler type. */
typedef void (*ble_radio_notification_evt_handler_t)(bool radio_active);

/**
* @brief Function for initializing the Radio Notification module.
*
* To ensure that the radio notification signal behaves in a consistent way, the radio
* notifications must be configured when there is no protocol stack or other SoftDevice
* activity in progress. It is recommended that the radio notification signal is
* configured directly after the SoftDevice has been enabled.
*
* @param[in] distance Distance between the ACTIVE notification signal and start of radio event.
* @param[in] evt_handler Handler to be called when a radio notification event has been received.
*
* @retval NRF_SUCCESS on successful initialization.
* @retval NRF_ERROR_NULL if @c evt_handler is NULL.
* @retval NRF_ERROR_INVALID_PARAM if the distance is invalid or radio notification type is not
* properly configured.
* @retval NRF_ERROR_INVALID_STATE if the protocol stack or other SoftDevice is running. Stop all
* running activities and retry.
*/
uint32_t ble_radio_notification_init(uint32_t distance,
ble_radio_notification_evt_handler_t evt_handler);

#ifdef __cplusplus
}
#endif

#endif /* BLE_RADIO_NOTIFICATION_H__ */

/** @} */
1 change: 1 addition & 0 deletions lib/bluetooth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ add_subdirectory_ifdef(CONFIG_BLE_CONN_PARAMS ble_conn_params)
add_subdirectory_ifdef(CONFIG_BLE_CONN_STATE ble_conn_state)
add_subdirectory_ifdef(CONFIG_BLE_GATT_QUEUE ble_gq)
add_subdirectory_ifdef(CONFIG_BLE_RACP ble_racp)
add_subdirectory_ifdef(CONFIG_BLE_RADIO_NOTIFICATION ble_radio_notification)
add_subdirectory_ifdef(CONFIG_BLE_QWR ble_qwr)
add_subdirectory_ifdef(CONFIG_PEER_MANAGER peer_manager)
1 change: 1 addition & 0 deletions lib/bluetooth/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rsource "ble_conn_params/Kconfig"
rsource "ble_conn_state/Kconfig"
rsource "ble_gq/Kconfig"
rsource "ble_racp/Kconfig"
rsource "ble_radio_notification/Kconfig"
rsource "ble_qwr/Kconfig"
rsource "peer_manager/Kconfig"

Expand Down
7 changes: 7 additions & 0 deletions lib/bluetooth/ble_radio_notification/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
zephyr_library()
zephyr_library_sources(ble_radio_notification.c)
35 changes: 35 additions & 0 deletions lib/bluetooth/ble_radio_notification/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Copyright (c) 2025 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
menuconfig BLE_RADIO_NOTIFICATION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that this is not expressing the dependency on SoftDevice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. Note that this applies for most of the bluetooth libraries. So we should clean it up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eivindj-nordic What do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not have this dependency for many of the other ble libraries. See connection parameters etc.

bool "BLE Radio Notification"
depends on SOFTDEVICE

if BLE_RADIO_NOTIFICATION

choice BLE_RADIO_NOTIFICATION_TYPE
prompt "Radio notification type"
default BLE_RADIO_NOTIFICATION_ON_BOTH

config BLE_RADIO_NOTIFICATION_ON_ACTIVE
bool "On active"

config BLE_RADIO_NOTIFICATION_ON_INACTIVE
bool "On inactive"

config BLE_RADIO_NOTIFICATION_ON_BOTH
bool "On both active and inactive"

endchoice # BLE_RADIO_NOTIFICATION_TYPE

config BLE_RADIO_NOTIFICATION_IRQ_PRIO
int "BLE Radio Notification IRQ priority"
default 3

module=BLE_RADIO_NOTIFICATION
module-str=BLE Radio Notification
source "$(ZEPHYR_BASE)/subsys/logging/Kconfig.template.log_config"

endif # BLE_RADIO_NOTIFICATION
64 changes: 64 additions & 0 deletions lib/bluetooth/ble_radio_notification/ble_radio_notification.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2018-2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <nrf_error.h>
#include <nrf_soc.h>
#include <stdlib.h>

#include <bm/bluetooth/ble_radio_notification.h>
#include <zephyr/logging/log.h>

#if CONFIG_UNITY
#include <cmsis.h>
#endif

LOG_MODULE_REGISTER(ble_radio_ntf, CONFIG_BLE_RADIO_NOTIFICATION_LOG_LEVEL);

/* Radio notification type. */
#if defined(CONFIG_BLE_RADIO_NOTIFICATION_ON_ACTIVE)
#define NOTIFICATION_TYPE NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE
#elif defined(CONFIG_BLE_RADIO_NOTIFICATION_ON_INACTIVE)
#define NOTIFICATION_TYPE NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE
#else
#define NOTIFICATION_TYPE NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH
#endif

/* Application event handler for handling Radio Notification events. */
static ble_radio_notification_evt_handler_t evt_handler;

void radio_notification_isr(const void *arg)
{
static bool radio_active = IS_ENABLED(CONFIG_BLE_RADIO_NOTIFICATION_ON_ACTIVE);

ARG_UNUSED(arg);

#if defined(CONFIG_BLE_RADIO_NOTIFICATION_ON_BOTH)
radio_active = !radio_active;
#endif

if (evt_handler) {
evt_handler(radio_active);
}
}

uint32_t ble_radio_notification_init(uint32_t distance,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not when we are returning nrf_error.

ble_radio_notification_evt_handler_t notif_evt_handler)
{
if (!notif_evt_handler) {
return NRF_ERROR_NULL;
}

evt_handler = notif_evt_handler;

/* Initialize Radio Notification software interrupt */
IRQ_DIRECT_CONNECT(RADIO_NOTIFICATION_IRQn, CONFIG_BLE_RADIO_NOTIFICATION_IRQ_PRIO,
radio_notification_isr, 0);

NVIC_ClearPendingIRQ(RADIO_NOTIFICATION_IRQn);
NVIC_EnableIRQ(RADIO_NOTIFICATION_IRQn);

return sd_radio_notification_cfg_set(NOTIFICATION_TYPE, distance);
}
12 changes: 12 additions & 0 deletions samples/bluetooth/ble_radio_notification/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(ble_radio_notification)

target_sources(app PRIVATE src/main.c)
20 changes: 20 additions & 0 deletions samples/bluetooth/ble_radio_notification/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

menu "BLE Radio Notification sample"

config BLE_RADIO_NOTIFICATION_DISTANCE_US
int "Distance between the active notification signal and start of radio event preparation"
range 50 5500
default 800

module=BLE_RADIO_NOTIFICATION_SAMPLE
module-str=BLE Radio Notification Sample
source "$(ZEPHYR_BASE)/subsys/logging/Kconfig.template.log_config"

endmenu # "BLE Radio Notification sample"

source "Kconfig.zephyr"
Loading