This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new b5d3d3ce3 services/ans: Fix category 0 skipped by immediate-notify-all 
command
b5d3d3ce3 is described below

commit b5d3d3ce3bffe375138ae9d42da8a7071a48f4b1
Author: 94xhn <[email protected]>
AuthorDate: Sun Jul 12 22:07:17 2026 +0800

    services/ans: Fix category 0 skipped by immediate-notify-all command
    
    The Alert Notification Service control point handler for
    BLE_SVC_ANS_CMD_NOT_NEW_ALERT_IMMEDIATE and
    BLE_SVC_ANS_CMD_NOT_UNR_ALERT_IMMEDIATE loops over all supported
    categories when the peer writes cat_id == 0xff ("all categories"):
    
        for (i = BLE_SVC_ANS_CAT_NUM - 1; i > 0; --i) {
            if ((ble_svc_ans_new_alert_cat >> i) & 0x01) {
                ble_svc_ans_new_alert_notify(i, NULL);
            }
        }
    
    The loop condition `i > 0` stops before `i` reaches 0, so category ID
    0 (BLE_SVC_ANS_CAT_ID_SIMPLE_ALERT, "Simple Alert") is never notified
    by this path, even when it is enabled and has a pending alert. If
    Simple Alert is the only category the peer has enabled, a 0xff
    immediate-notify request results in zero notifications being sent.
    
    Change the bound to `i >= 0` so category 0 is included, matching the
    same fix in both the new-alert and unread-alert-status branches.
    
    Signed-off-by: 94xhn <[email protected]>
---
 nimble/host/services/ans/src/ble_svc_ans.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nimble/host/services/ans/src/ble_svc_ans.c 
b/nimble/host/services/ans/src/ble_svc_ans.c
index edaf7f3c1..eb6e26099 100644
--- a/nimble/host/services/ans/src/ble_svc_ans.c
+++ b/nimble/host/services/ans/src/ble_svc_ans.c
@@ -247,7 +247,7 @@ ble_svc_ans_access(uint16_t conn_handle, uint16_t 
attr_handle,
             case BLE_SVC_ANS_CMD_NOT_NEW_ALERT_IMMEDIATE:
                 if (cat_id == 0xff) {
                     /* If cat_id is 0xff, notify on all enabled categories */
-                    for (i = BLE_SVC_ANS_CAT_NUM - 1; i > 0; --i) {
+                    for (i = BLE_SVC_ANS_CAT_NUM - 1; i >= 0; --i) {
                         if ((ble_svc_ans_new_alert_cat >> i) & 0x01) {
                             ble_svc_ans_new_alert_notify(i, NULL);
                         }
@@ -259,7 +259,7 @@ ble_svc_ans_access(uint16_t conn_handle, uint16_t 
attr_handle,
             case BLE_SVC_ANS_CMD_NOT_UNR_ALERT_IMMEDIATE:
                 if (cat_id == 0xff) {
                     /* If cat_id is 0xff, notify on all enabled categories */
-                    for (i = BLE_SVC_ANS_CAT_NUM - 1; i > 0; --i) {
+                    for (i = BLE_SVC_ANS_CAT_NUM - 1; i >= 0; --i) {
                         if ((ble_svc_ans_unr_alert_cat >> i) & 0x01) {
                             ble_svc_ans_unr_alert_notify(i);
                         }

Reply via email to