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
2 changes: 2 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
/lib/ble_gq/ @nrfconnect/ncs-bm
/lib/ble_qwr/ @nrfconnect/ncs-bm
/lib/ble_racp/ @nrfconnect/ncs-bm
/lib/ble_radio_notification/ @nrfconnect/ncs-bm
/lib/bm_buttons/ @nrfconnect/ncs-bm
/lib/bm_storage/ @nrfconnect/ncs-bm
/lib/bm_timer/ @nrfconnect/ncs-bm
Expand Down Expand Up @@ -89,6 +90,7 @@
/tests/lib/bm_zms/ @nrfconnect/ncs-bm @rghaddab
/tests/lib/ble_qwr/ @nrfconnect/ncs-bm
/tests/lib/ble_racp/ @nrfconnect/ncs-bm
/tests/lib/ble_radio_notif/ @nrfconnect/ncs-bm
/tests/lib/ble_adv/ @nrfconnect/ncs-bm-test
/tests/lib/bm_storage/ @nrfconnect/ncs-bm

Expand Down
6 changes: 6 additions & 0 deletions doc/nrf-bm/api/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ Advertising and Scan Response Data Encoder
.. doxygengroup:: ble_sdk_lib_advdata
:inner:

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

.. doxygengroup:: ble_radio_notification
:inner:

Bare Metal Zephyr Memory Storage (ZMS)
======================================

Expand Down
52 changes: 52 additions & 0 deletions doc/nrf-bm/libraries/ble_radio_notification.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.. _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 notification prior to and after radio events.

Overview
********

The library allows the user to register a handler to receive the 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.
Copy link

Choose a reason for hiding this comment

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

I'm not sure this is the correct place to mention it, but some priority levels shall not be used.
This used to be documented in the SDS: https://docs.nordicsemi.com/bundle/sds_s140/page/SDS/s1xx/processor_avail_interrupt_latency/exception_mgmt_sd.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I think it can be documented in the Kconfig option at least.


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.
This 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/ble_radio_notification.h`
| Source files: :file:`lib/ble_radio_notification/`
.. doxygengroup:: ble_radio_notification
4 changes: 2 additions & 2 deletions doc/nrf-bm/release_notes/release_notes_changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ No changes since the latest nRF Connect SDK Bare Metal release.
Libraries
=========

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

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
46 changes: 46 additions & 0 deletions include/ble_radio_notification.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2018-2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/** @file
*
* @defgroup ble_radio_notification Radio Notification Event Handler
*
* @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>
#include <nrf_soc.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.
*
* @param[in] distance Distance between the ACTIVE notification signal and start of radio event.
* @param[in] evt_handler Handler to be executed when a radio notification event has been received.
*
* @return NRF_SUCCESS on successful initialization, otherwise an error code.
*/
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/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ add_subdirectory_ifdef(CONFIG_BLE_ADV ble_adv)
add_subdirectory_ifdef(CONFIG_BLE_CONN_PARAMS ble_conn_params)
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_EVENT_SCHEDULER event_scheduler)
add_subdirectory_ifdef(CONFIG_BM_BUTTONS bm_buttons)
add_subdirectory_ifdef(CONFIG_BM_STORAGE bm_storage)
Expand Down
1 change: 1 addition & 0 deletions lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rsource "ble_adv/Kconfig"
rsource "ble_conn_params/Kconfig"
rsource "ble_gq/Kconfig"
rsource "ble_racp/Kconfig"
rsource "ble_radio_notification/Kconfig"
rsource "event_scheduler/Kconfig"
rsource "bm_buttons/Kconfig"
rsource "bm_storage/Kconfig"
Expand Down
7 changes: 7 additions & 0 deletions lib/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)
38 changes: 38 additions & 0 deletions lib/ble_radio_notification/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Copyright (c) 2025 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
menuconfig BLE_RADIO_NOTIFICATION
bool "BLE Radio Notification"

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
Copy link

Choose a reason for hiding this comment

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

Perhaps add a range that disallows 0?

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 a help text that level 0 and 4 is reserved by the SoftDevice.

int "Radio Notification IRQ priority"
default 3
help
IRQ Priority level 0 and 4 are reserved by the SoftDevice.


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

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

#include <errno.h>
#include <stdlib.h>

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

#if CONFIG_UNITY
#include <cmsis.h>
#define STATIC
#else
#define STATIC static
#endif

LOG_MODULE_REGISTER(ble_radio_ntf, CONFIG_BLE_RADIO_NTF_LOG_LEVEL);

/* Current radio state. */
#if CONFIG_BLE_RADIO_NOTIFICATION_ON_ACTIVE
static bool radio_active = true;
#else
static bool radio_active;
#endif

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

STATIC void radio_notification_isr(const void *arg)
{
ARG_UNUSED(arg);

#if defined CONFIG_BLE_RADIO_NOTIFICATION_ON_BOTH
radio_active = !radio_active;
#endif

if (evt_handler != NULL) {
evt_handler(radio_active);
}
}

uint32_t ble_radio_notification_init(uint32_t distance,
ble_radio_notification_evt_handler_t _evt_handler)
{
uint8_t type = NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH;

#if defined(CONFIG_BLE_RADIO_NOTIFICATION_ON_ACTIVE)
type = NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE;
#elif defined(CONFIG_BLE_RADIO_NOTIFICATION_ON_INACTIVE)
type = NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE;
#endif

evt_handler = _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(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_ntf)

target_sources(app PRIVATE src/main.c)
21 changes: 21 additions & 0 deletions samples/bluetooth/ble_radio_notification/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# 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_NTF_SAMPLE
module-dep=LOG
module-str=BLE Radio Notification Sample
source "$(ZEPHYR_BASE)/subsys/logging/Kconfig.template.log_config"

endmenu # "BLE Radio Notification sample"

source "Kconfig.zephyr"
Loading