Skip to content

Conversation

@seankyer
Copy link
Member

@seankyer seankyer commented Sep 6, 2025

Add alert notification service (ANS) to Bluetooth subsystem and accompanying sample.

Based on spec described in https://www.bluetooth.com/specifications/specs/alert-notification-service-1-0/ with bitfields taken from https://btprodspecificationrefs.blob.core.windows.net/gatt-specification-supplement/GATT_Specification_Supplement.pdf.

To interact with this sample, download a BLE app like ADI Attach or nRF connect. Once you subscribe to the unread alert and new alert notification characteristics, you need to send a "write" to the Alert Notification Control Point characteristic to enable the categories you would like to be notified on.

In the basic example you would send: [0,0] and [1,0] to the control point and once you have subscribed to notifications you will then start receiving the messages. Further commands are explained in https://btprodspecificationrefs.blob.core.windows.net/gatt-specification-supplement/GATT_Specification_Supplement.pdf section 3.12.

It is the responsibility of the app to interpret whatever a 'new notification' or 'unread notification' is and use the APIs to update them accordingly. The service must save the most recent value for each enabled category in case the control point sends the 'immediate' request, which relays the most up to date values for the specified category.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the Alert Notification Service (ANS) for Bluetooth subsystem, enabling devices to send alert notifications to connected BLE clients. The implementation follows the Bluetooth ANS 1.0 specification and includes support for both new alert and unread alert notifications across multiple categories.

  • Implements complete ANS service with support for 10 alert categories (simple alert, email, news, call, etc.)
  • Adds configurable category support through Kconfig options for both new and unread alert types
  • Includes a sample application demonstrating ANS usage with periodic alert notifications

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
subsys/bluetooth/services/ans.c Core ANS service implementation with GATT characteristics and API functions
subsys/bluetooth/services/Kconfig.ans Configuration options for enabling specific alert categories
subsys/bluetooth/services/Kconfig Integration of ANS Kconfig into main services menu
subsys/bluetooth/services/CMakeLists.txt Build system integration for ANS service
samples/bluetooth/peripheral_ans/src/main.c Sample application demonstrating ANS usage
samples/bluetooth/peripheral_ans/sample.yaml Test configuration for sample application
samples/bluetooth/peripheral_ans/prj.conf Project configuration for sample
samples/bluetooth/peripheral_ans/README.rst Documentation for sample usage
samples/bluetooth/peripheral_ans/CMakeLists.txt Build configuration for sample
include/zephyr/bluetooth/services/ans.h Public API header for ANS service
include/zephyr/bluetooth/att.h Addition of BT_ATT_ERR_CMD_NOT_SUP error code

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@Thalley Thalley left a comment

Choose a reason for hiding this comment

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

Thanks for your PR - It's overall good quality, and most of my comments are related some potential missing features or Zephyr specific formatting or coding guidelines

@zephyrbot zephyrbot added the Release Notes To be mentioned in the release notes label Sep 6, 2025
@zephyrbot zephyrbot requested a review from cfriedt September 6, 2025 20:16
@seankyer seankyer force-pushed the feat/bt-ans branch 2 times, most recently from ff12748 to 47ddfac Compare September 6, 2025 20:58
@seankyer
Copy link
Member Author

seankyer commented Sep 6, 2025

Thanks for the review. I replied to a few comments and applied your suggestions.

I also refactored the transmit functions since they got too nested.

kartben
kartben previously approved these changes Oct 21, 2025
Copy link
Contributor

@kartben kartben left a comment

Choose a reason for hiding this comment

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

+1 for docs / sample, thanks!

jhedberg
jhedberg previously approved these changes Oct 22, 2025
@seankyer
Copy link
Member Author

It looks like this didn't make it in for 4.3. @kartben Should I switch the release notes to be in release-notes-4-4?

@jhedberg
Copy link
Member

jhedberg commented Oct 27, 2025

@seankyer yes, that's unfortunately the case. It still needs a (re-)review from @Thalley.

@jhedberg jhedberg added this to the v4.4.0 milestone Oct 27, 2025
@jhedberg
Copy link
Member

We still don't have a draft release notes file for 4.4, however, since it's the very last item on #96992. @kartben any thoughts on this process - would it make sense to create such a file as soon as the feature freeze happens, since that's when feature PRs (that may need to modify the release notes) will start "spilling over" into the next release.

@seankyer
Copy link
Member Author

I suppose in the meantime I am just waiting until the new release notes doc gets created. Which is after 4.3 release?

@kartben
Copy link
Contributor

kartben commented Oct 29, 2025

sorry @jhedberg @seankyer - I didn't see the mention! Yeah, I typically add the "future" docs around that time. Guess it would make sense to make it part of the check list for release managers so that we don't forget in the future :)
Anyway: #98537

@seankyer seankyer dismissed stale reviews from jhedberg and kartben via 76ef59f October 31, 2025 19:07
@seankyer
Copy link
Member Author

Rebased and moved docs to 4.4. Thanks.
fyi @Thalley

@zephyrbot zephyrbot requested review from jhedberg and kartben October 31, 2025 19:09
Copy link
Contributor

@Thalley Thalley left a comment

Choose a reason for hiding this comment

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

Two minor comments, otherwise LGTM

BT_ANS_CAT_HIGH_PRI_ALERT, /**< High-priority alerts. */
BT_ANS_CAT_INSTANT_MESSAGE, /**< Instant messaging alerts. */

BT_ANS_CAT_NUM, /**< Marker for the number of categories. */
Copy link
Contributor

Choose a reason for hiding this comment

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

We should consider omitting this particular value from the documentation

Suggested change
BT_ANS_CAT_NUM, /**< Marker for the number of categories. */
/** @cond INTERNAL_HIDDEN */
BT_ANS_CAT_NUM, /**< Marker for the number of categories. */
/** @endcond */

@seankyer
Copy link
Member Author

seankyer commented Nov 4, 2025

Two minor comments, otherwise LGTM

Thanks, applied changes for those two notes

Thalley
Thalley previously approved these changes Nov 5, 2025
@@ -0,0 +1,26 @@
.. zephyr:code-sample:: ble_peripheral_ans
:name: Peripheral ANS
:relevant-api: bluetooth
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
:relevant-api: bluetooth
:relevant-api: bluetooth bt_ans

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried it but then got an HTML build error

Add alert notification service (ANS) to Bluetooth
subsystem and accompanying sample.

Signed-off-by: Sean Kyer <sean.actor@gmail.com>
Add Alert Notification Service (ANS) and enabling Kconfig
to 4.4 release notes.

Signed-off-by: Sean Kyer <sean.actor@gmail.com>
@sonarqubecloud
Copy link

@nashif nashif merged commit 830bc4f into zephyrproject-rtos:main Nov 17, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth area: Samples Samples Release Notes To be mentioned in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants