hci: implement gap_cig_remove

This commit is contained in:
Matthias Ringwald 2024-01-24 14:42:54 +01:00
parent f2e409f3a3
commit d90722d454
2 changed files with 47 additions and 1 deletions

View File

@ -6997,6 +6997,7 @@ static bool hci_run_iso_tasks(void){
}
// CIG
bool cig_active;
btstack_linked_list_iterator_init(&it, &hci_stack->le_audio_cigs);
while (btstack_linked_list_iterator_has_next(&it)) {
le_audio_cig_t *cig = (le_audio_cig_t *) btstack_linked_list_iterator_next(&it);
@ -7082,12 +7083,30 @@ static bool hci_run_iso_tasks(void){
}
// emit done
cig->state = LE_AUDIO_CIG_STATE_ACTIVE;
break;
case LE_AUDIO_CIG_STATE_REMOVE:
// check if CIG Active
cig_active = false;
for (i = 0; i < cig->num_cis; i++) {
if (cig->cis_con_handles[i] != HCI_CON_HANDLE_INVALID){
hci_iso_stream_t * stream = hci_iso_stream_for_con_handle(cig->cis_con_handles[i]);
if (stream != NULL){
cig_active = true;
break;
}
}
}
if (cig_active == false){
btstack_linked_list_iterator_remove(&it);
hci_send_cmd(&hci_le_remove_cig, cig->cig_id);
return true;
}
default:
break;
}
}
// CIS Accept/Reject
// CIS Accept/Reject/Setup ISO Path/Close
btstack_linked_list_iterator_init(&it, &hci_stack->iso_streams);
while (btstack_linked_list_iterator_has_next(&it)) {
hci_iso_stream_t *iso_stream = (hci_iso_stream_t *) btstack_linked_list_iterator_next(&it);
@ -7118,6 +7137,10 @@ static bool hci_run_iso_tasks(void){
iso_stream->state = HCI_ISO_STREAM_STATE_W4_ISO_SETUP_OUTPUT;
hci_send_cmd(&hci_le_setup_iso_data_path, iso_stream->cis_handle, 1, 0, HCI_AUDIO_CODING_FORMAT_TRANSPARENT, 0, 0, 0, 0, NULL);
break;
case HCI_ISO_STREAM_STATE_W2_CLOSE:
iso_stream->state = HCI_ISO_STREAM_STATE_W4_DISCONNECTED;
hci_send_cmd(&hci_disconnect, iso_stream->cis_handle);
break;
default:
break;
}
@ -10557,6 +10580,27 @@ uint8_t gap_cig_create(le_audio_cig_t * storage, le_audio_cig_params_t * cig_par
return ERROR_CODE_SUCCESS;
}
uint8_t gap_cig_remove(uint8_t cig_id){
le_audio_cig_t * cig = hci_cig_for_id(cig_id);
if (cig == NULL){
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
}
// close active CIS
uint8_t i;
for (i=0;i<cig->num_cis;i++){
hci_iso_stream_t * stream = hci_iso_stream_for_con_handle(cig->cis_con_handles[i]);
if (stream != NULL){
stream->state = HCI_ISO_STREAM_STATE_W2_CLOSE;
}
}
cig->state = LE_AUDIO_CIG_STATE_REMOVE;
hci_run();
return ERROR_CODE_SUCCESS;
}
uint8_t gap_cis_create(uint8_t cig_id, hci_con_handle_t cis_con_handles [], hci_con_handle_t acl_con_handles []){
le_audio_cig_t * cig = hci_cig_for_id(cig_id);
if (cig == NULL){

View File

@ -721,6 +721,8 @@ typedef enum{
HCI_ISO_STREAM_STATE_W4_ISO_SETUP_INPUT,
HCI_ISO_STREAM_STATE_W2_SETUP_ISO_OUTPUT,
HCI_ISO_STREAM_STATE_W4_ISO_SETUP_OUTPUT,
HCI_ISO_STREAM_STATE_W2_CLOSE,
HCI_ISO_STREAM_STATE_W4_DISCONNECTED,
} hci_iso_stream_state_t;
typedef struct {