Skip to content

Commit c938c81

Browse files
Thalleycfriedt
authored andcommitted
Bluetooth: Audio: VCS client use auto CCC discovery
Update the VCS client to use the auto CCC discovery feature instead of expecting it to be a specific place in the remote server's GATT database. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 03bcf82 commit c938c81

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

subsys/bluetooth/audio/Kconfig.vcs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ endif # BT_VCS
6363
config BT_VCS_CLIENT
6464
bool "Volume Control Profile Support"
6565
select BT_GATT_CLIENT
66+
select BT_GATT_AUTO_DISCOVER_CCC
6667
default n
6768
help
6869
This option enables support for Volume Control Profile.

subsys/bluetooth/audio/vcs_client.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,25 +476,24 @@ static uint8_t vcs_discover_func(struct bt_conn *conn,
476476
BT_DBG("Volume state");
477477
vcs_inst->cli.state_handle = chrc->value_handle;
478478
sub_params = &vcs_inst->cli.state_sub_params;
479+
sub_params->disc_params = &vcs_inst->cli.state_sub_disc_params;
479480
} else if (bt_uuid_cmp(chrc->uuid, BT_UUID_VCS_CONTROL) == 0) {
480481
BT_DBG("Control Point");
481482
vcs_inst->cli.control_handle = chrc->value_handle;
482483
} else if (bt_uuid_cmp(chrc->uuid, BT_UUID_VCS_FLAGS) == 0) {
483484
BT_DBG("Flags");
484485
vcs_inst->cli.flag_handle = chrc->value_handle;
485486
sub_params = &vcs_inst->cli.flag_sub_params;
487+
sub_params->disc_params = &vcs_inst->cli.flag_sub_disc_params;
486488
}
487489

488490
if (sub_params != NULL) {
489491
int err;
490492

491493
sub_params->value = BT_GATT_CCC_NOTIFY;
492494
sub_params->value_handle = chrc->value_handle;
493-
/*
494-
* TODO: Don't assume that CCC is at handle + 2;
495-
* do proper discovery;
496-
*/
497-
sub_params->ccc_handle = attr->handle + 2;
495+
sub_params->ccc_handle = 0;
496+
sub_params->end_handle = vcs_inst->cli.end_handle;
498497
sub_params->notify = vcs_client_notify_handler;
499498
err = bt_gatt_subscribe(conn, sub_params);
500499
if (err == 0) {

subsys/bluetooth/audio/vcs_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ struct bt_vcs_client {
4747
uint16_t control_handle;
4848
uint16_t flag_handle;
4949
struct bt_gatt_subscribe_params state_sub_params;
50+
struct bt_gatt_discover_params state_sub_disc_params;
5051
struct bt_gatt_subscribe_params flag_sub_params;
52+
struct bt_gatt_discover_params flag_sub_disc_params;
5153
bool cp_retried;
5254

5355
bool busy;

0 commit comments

Comments
 (0)