Bluetooth: Audio: MCC - refactor subscription
Move subscription to characteristics to separate function. Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit is contained in:
parent
542e99b859
commit
6c2b8e6e65
1 changed files with 15 additions and 8 deletions
|
@ -1215,6 +1215,20 @@ static void discover_included(struct bt_conn *conn)
|
|||
}
|
||||
#endif /* CONFIG_BT_MCC_OTS */
|
||||
|
||||
/* Subscribe to a characteristic - helper function */
|
||||
static void do_subscribe(struct bt_conn *conn, uint16_t handle,
|
||||
struct bt_gatt_subscribe_params *sub_params)
|
||||
{
|
||||
/* With ccc_handle == 0 it will use auto discovery */
|
||||
sub_params->ccc_handle = 0;
|
||||
sub_params->end_handle = cur_mcs_inst->end_handle;
|
||||
sub_params->value = BT_GATT_CCC_NOTIFY;
|
||||
sub_params->value_handle = handle;
|
||||
sub_params->notify = mcs_notify_handler;
|
||||
|
||||
bt_gatt_subscribe(conn, sub_params);
|
||||
}
|
||||
|
||||
/* This function is called when characteristics are found.
|
||||
* The function will store handles, and optionally subscribe to, GMCS
|
||||
* characteristics.
|
||||
|
@ -1352,14 +1366,7 @@ static uint8_t discover_mcs_char_func(struct bt_conn *conn,
|
|||
|
||||
if (subscribe_all && sub_params) {
|
||||
BT_DBG("Subscribing - handle: 0x%04x", attr->handle);
|
||||
|
||||
/* With ccc_handle == 0 it will use auto discovery */
|
||||
sub_params->ccc_handle = 0;
|
||||
sub_params->end_handle = cur_mcs_inst->end_handle;
|
||||
sub_params->value = BT_GATT_CCC_NOTIFY;
|
||||
sub_params->value_handle = chrc->value_handle;
|
||||
sub_params->notify = mcs_notify_handler;
|
||||
bt_gatt_subscribe(conn, sub_params);
|
||||
do_subscribe(conn, chrc->value_handle, sub_params);
|
||||
}
|
||||
|
||||
/* Continue to search for more attributes */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue