-
Notifications
You must be signed in to change notification settings - Fork 8.3k
bluetooth: ANS: Add Alert Notification Service #95578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
108bcfa to
7a19efc
Compare
There was a problem hiding this 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.
Thalley
left a comment
There was a problem hiding this 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
7a19efc to
57067c7
Compare
ff12748 to
47ddfac
Compare
|
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. |
47ddfac to
4c0db0f
Compare
kartben
left a comment
There was a problem hiding this 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!
|
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? |
|
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. |
|
I suppose in the meantime I am just waiting until the new release notes doc gets created. Which is after 4.3 release? |
|
Rebased and moved docs to 4.4. Thanks. |
Thalley
left a comment
There was a problem hiding this 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. */ |
There was a problem hiding this comment.
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
| BT_ANS_CAT_NUM, /**< Marker for the number of categories. */ | |
| /** @cond INTERNAL_HIDDEN */ | |
| BT_ANS_CAT_NUM, /**< Marker for the number of categories. */ | |
| /** @endcond */ |
Thanks, applied changes for those two notes |
| @@ -0,0 +1,26 @@ | |||
| .. zephyr:code-sample:: ble_peripheral_ans | |||
| :name: Peripheral ANS | |||
| :relevant-api: bluetooth | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| :relevant-api: bluetooth | |
| :relevant-api: bluetooth bt_ans |
There was a problem hiding this comment.
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
d6c428d to
bd032b7
Compare
Add alert notification service (ANS) to Bluetooth subsystem and accompanying sample. Signed-off-by: Sean Kyer <sean.actor@gmail.com>
bd032b7 to
7268240
Compare
Add Alert Notification Service (ANS) and enabling Kconfig to 4.4 release notes. Signed-off-by: Sean Kyer <sean.actor@gmail.com>
7268240 to
8f7fd60
Compare
|



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.