Bluetooth: controller: Fix reconfiguring of CIG and CISes

Up until now, it has not been possible to reconfigure a CIG and its
CISes after initial configuration, without first removing the CIG.

With this commit, le_set_cig_parameters allows the following
reconfiguration operations in configuration state:
- Set new CIG configuration parameters on existing CIG
- Iteratively configure single CIS (of more CISes)
- Increment number of CISes via multiple configuration calls
- Keep handle- and CIS_ID relation

Changes:
- Pass handles in le_set_cig_parameters from ll_cig_parameters_commit
  via output variable.
- Implement CIG state variable instead of 'started', with states
  IDLE/CONFIGURABLE, ACTIVE and INACTIVE.
- Implement ll_conn_iso_stream_get_by_id for easier access to specific
  CIS.

This fixes the following CIS Central EBQ tests:
- HCI/CIS/BI-10-C
- HCI/CIS/BI-11-C
- HCI/CIS/BI-13-C
- HCI/CIS/BV-05-C

Signed-off-by: Morten Priess <mtpr@oticon.com>
This commit is contained in:
Morten Priess 2023-05-22 16:48:34 +02:00 committed by Anas Nashif
commit 5db51d3679
7 changed files with 164 additions and 101 deletions

View file

@ -2025,26 +2025,21 @@ static void le_set_cig_parameters(struct net_buf *buf, struct net_buf **evt)
rp = hci_cmd_complete(evt, sizeof(*rp) + cis_count * sizeof(uint16_t));
rp->cig_id = cig_id;
rp->num_handles = cis_count;
/* Only apply parameters if all went well */
if (!status) {
status = ll_cig_parameters_commit(cig_id);
uint16_t handles[CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP];
status = ll_cig_parameters_commit(cig_id, handles);
if (status == BT_HCI_ERR_SUCCESS) {
struct ll_conn_iso_group *cig;
uint16_t handle;
cig = ll_conn_iso_group_get_by_id(cig_id);
handle = UINT16_MAX;
for (uint8_t i = 0; i < cis_count; i++) {
(void)ll_conn_iso_stream_get_by_group(cig, &handle);
rp->handle[i] = sys_cpu_to_le16(handle);
rp->handle[i] = sys_cpu_to_le16(handles[i]);
}
}
}
rp->num_handles = status ? 0U : cis_count;
rp->status = status;
}
@ -2102,26 +2097,21 @@ static void le_set_cig_params_test(struct net_buf *buf, struct net_buf **evt)
rp = hci_cmd_complete(evt, sizeof(*rp) + cis_count * sizeof(uint16_t));
rp->cig_id = cig_id;
rp->num_handles = cis_count;
/* Only apply parameters if all went well */
if (!status) {
status = ll_cig_parameters_commit(cig_id);
uint16_t handles[CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP];
status = ll_cig_parameters_commit(cig_id, handles);
if (status == BT_HCI_ERR_SUCCESS) {
struct ll_conn_iso_group *cig;
uint16_t handle;
cig = ll_conn_iso_group_get_by_id(cig_id);
handle = UINT16_MAX;
for (uint8_t i = 0; i < cis_count; i++) {
(void)ll_conn_iso_stream_get_by_group(cig, &handle);
rp->handle[i] = sys_cpu_to_le16(handle);
rp->handle[i] = sys_cpu_to_le16(handles[i]);
}
}
}
rp->num_handles = status ? 0U : cis_count;
rp->status = status;
}