Bluetooth: Audio: Use BT_GATT_SUBSCRIBE_FLAG_VOLATILE
The LE Audio implementations do not really support bonding yet, and removing subs on disconnect is the most effective (and correct) way of ensuring that we do not subscribe more than once when we re-discover after reconnection. The broadcast assistant and the media control client does not support multiple connections as of this commit, so they needed special treatment. In the case that we do discovery on multiple ACL connections, it is important that the existing subscriptions are removed correctly by calling bt_gatt_unsubscribe. In order to implement this change properly on some of the clients, thet had no proper connection references or support for clearing the data on disconnects, they had to be updated as well. The csip_notify.sh test has been disabled, as that expected a notification in the client, but since this commit removes that (until bonding is properly supported in the clients), then the test will fail. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
922ac3c7c1
commit
ec41dd9ba6
14 changed files with 325 additions and 122 deletions
|
@ -409,9 +409,10 @@ static uint8_t micp_discover_func(struct bt_conn *conn,
|
|||
sub_params->value = BT_GATT_CCC_NOTIFY;
|
||||
sub_params->value_handle = chrc->value_handle;
|
||||
sub_params->notify = mute_notify_handler;
|
||||
atomic_set_bit(sub_params->flags, BT_GATT_SUBSCRIBE_FLAG_VOLATILE);
|
||||
|
||||
err = bt_gatt_subscribe(conn, sub_params);
|
||||
if (err == 0) {
|
||||
if (err == 0 || err == -EALREADY) {
|
||||
LOG_DBG("Subscribed to handle 0x%04X", attr->handle);
|
||||
} else {
|
||||
LOG_DBG("Could not subscribe to handle 0x%04X: %d", attr->handle,
|
||||
|
@ -480,14 +481,6 @@ static void micp_mic_ctlr_reset(struct bt_micp_mic_ctlr *mic_ctlr)
|
|||
if (mic_ctlr->conn != NULL) {
|
||||
struct bt_conn *conn = mic_ctlr->conn;
|
||||
|
||||
/* It's okay if this fails. In case of disconnect, we can't
|
||||
* unsubscribe and it will just fail.
|
||||
* In case that we reset due to another call of the discover
|
||||
* function, we will unsubscribe (regardless of bonding state)
|
||||
* to accommodate the new discovery values.
|
||||
*/
|
||||
(void)bt_gatt_unsubscribe(conn, &mic_ctlr->mute_sub_params);
|
||||
|
||||
bt_conn_unref(conn);
|
||||
mic_ctlr->conn = NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue