Commit 5b0ff0b3 authored by Jonathan Rico's avatar Jonathan Rico Committed by Carles Cufi
Browse files

Bluetooth: gatt: support having the CCCD in any location



Per spec, the CCCD doesn't necessarily have to be located immediately after
the characteristic value. This commit fixes that assumption when checking
for subscriptions.

Fixes #48880.

Signed-off-by: default avatarJonathan Rico <jonathan.rico@nordicsemi.no>
parent 96f077f8
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -3145,7 +3145,18 @@ bool bt_gatt_is_subscribed(struct bt_conn *conn,
		__ASSERT(attr, "No more attributes\n");
	}

	/* Check if the attribute is the CCC Descriptor */
	/* Find the CCC Descriptor */
	while (bt_uuid_cmp(attr->uuid, BT_UUID_GATT_CCC) &&
	       /* Also stop if we leave the current characteristic definition */
	       bt_uuid_cmp(attr->uuid, BT_UUID_GATT_CHRC) &&
	       bt_uuid_cmp(attr->uuid, BT_UUID_GATT_PRIMARY) &&
	       bt_uuid_cmp(attr->uuid, BT_UUID_GATT_SECONDARY)) {
		attr = bt_gatt_attr_next(attr);
		if (!attr) {
			return false;
		}
	}

	if (bt_uuid_cmp(attr->uuid, BT_UUID_GATT_CCC) != 0) {
		return false;
	}