Skip to content

Commit

Permalink
Bluetooth: Host: Bitwise OR CCC attribute values
Browse files Browse the repository at this point in the history
Summarize the value of the CCC using bitwise OR instead of max. This
is more natural and affords distinguishing between when only indications
are enabled and when both notifications and indications are enabled.

It is not expected that this change will affect any applications. It
will not affect attributes that allow only one of notifications and
indications. It will also not affect applications that only compare this
value to zero.

This change simplifies the interface of `_bt_gatt_ccc.value` and
`_bt_gatt_ccc.cfg_changed`.

Signed-off-by: Håvard Reierstad <[email protected]>
  • Loading branch information
HaavardRei committed Nov 6, 2024
1 parent cc21478 commit 7306202
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 3 additions & 0 deletions doc/releases/release-notes-4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ Bluetooth
:c:func:`bt_conn_le_create` and :c:func:`bt_conn_le_create_synced` return an error if the
connection pointer passed as an argument is not NULL.

* :c:member:`_bt_gatt_ccc.value` is now a bitwise OR-reduction of the
individual CCC values of connected clients instead of the maximum.

* Controller

* Added Periodic Advertising Sync Transfer (PAST) support with support for both sending and receiving roles.
Expand Down
2 changes: 1 addition & 1 deletion include/zephyr/bluetooth/gatt.h
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ struct _bt_gatt_ccc {
/** Configuration for each connection */
struct bt_gatt_ccc_cfg cfg[BT_GATT_CCC_MAX];

/** Highest value of all connected peer's subscriptions */
/** Bitwise OR of all connected peers' CCC values */
uint16_t value;

/** @brief CCC attribute changed callback
Expand Down
4 changes: 1 addition & 3 deletions subsys/bluetooth/host/gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2201,9 +2201,7 @@ static void gatt_ccc_changed(const struct bt_gatt_attr *attr,
struct bt_conn *conn = bt_conn_lookup_addr_le(ccc->cfg[i].id, &ccc->cfg[i].peer);

if (conn) {
if (ccc->cfg[i].value > value) {
value = ccc->cfg[i].value;
}
value |= ccc->cfg[i].value;

bt_conn_unref(conn);
}
Expand Down

0 comments on commit 7306202

Please sign in to comment.