hci.c (40f86dfdd04a8ed10369c86120ec8d79e4b6ed78) hci.c (778463d0f731df37e1842c96eae3caaecf0f34af)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 216 unchanged lines hidden (view full) ---

225#ifdef ENABLE_LE_EXTENDED_ADVERTISING
226static void hci_periodic_advertiser_list_free(void);
227static le_advertising_set_t * hci_advertising_set_for_handle(uint8_t advertising_handle);
228#endif /* ENABLE_LE_EXTENDED_ADVERTISING */
229#endif /* ENABLE_LE_PERIPHERAL */
230#ifdef ENABLE_LE_ISOCHRONOUS_STREAMS
231static uint8_t hci_iso_stream_create(hci_iso_type_t iso_type, hci_con_handle_t con_handle, uint8_t group_id);
232static void hci_iso_stream_finalize(hci_iso_stream_t * iso_stream);
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 216 unchanged lines hidden (view full) ---

225#ifdef ENABLE_LE_EXTENDED_ADVERTISING
226static void hci_periodic_advertiser_list_free(void);
227static le_advertising_set_t * hci_advertising_set_for_handle(uint8_t advertising_handle);
228#endif /* ENABLE_LE_EXTENDED_ADVERTISING */
229#endif /* ENABLE_LE_PERIPHERAL */
230#ifdef ENABLE_LE_ISOCHRONOUS_STREAMS
231static uint8_t hci_iso_stream_create(hci_iso_type_t iso_type, hci_con_handle_t con_handle, uint8_t group_id);
232static void hci_iso_stream_finalize(hci_iso_stream_t * iso_stream);
233static void hci_iso_stream_finalize_by_type_and_group_id(hci_iso_type_t iso_type, uint8_t group_id);
233static hci_iso_stream_t * hci_iso_stream_for_con_handle(hci_con_handle_t con_handle);
234static void hci_iso_stream_requested_finalize(uint8_t big_handle);
235static void hci_iso_stream_requested_confirm(uint8_t big_handle);
236static void hci_iso_packet_handler(uint8_t * packet, uint16_t size);
237static le_audio_big_t * hci_big_for_handle(uint8_t big_handle);
238static void hci_iso_notify_can_send_now(void);
239static void hci_emit_big_created(const le_audio_big_t * big, uint8_t status);
240static void hci_emit_big_terminated(const le_audio_big_t * big);

--- 3727 unchanged lines hidden (view full) ---

3968 }
3969 }
3970 if (big->state == LE_AUDIO_BIG_STATE_W4_ESTABLISHED) {
3971 big->state = LE_AUDIO_BIG_STATE_SETUP_ISO_PATH;
3972 big->state_vars.next_bis = 0;
3973 }
3974 } else {
3975 // create BIG failed or has been stopped by us
234static hci_iso_stream_t * hci_iso_stream_for_con_handle(hci_con_handle_t con_handle);
235static void hci_iso_stream_requested_finalize(uint8_t big_handle);
236static void hci_iso_stream_requested_confirm(uint8_t big_handle);
237static void hci_iso_packet_handler(uint8_t * packet, uint16_t size);
238static le_audio_big_t * hci_big_for_handle(uint8_t big_handle);
239static void hci_iso_notify_can_send_now(void);
240static void hci_emit_big_created(const le_audio_big_t * big, uint8_t status);
241static void hci_emit_big_terminated(const le_audio_big_t * big);

--- 3727 unchanged lines hidden (view full) ---

3969 }
3970 }
3971 if (big->state == LE_AUDIO_BIG_STATE_W4_ESTABLISHED) {
3972 big->state = LE_AUDIO_BIG_STATE_SETUP_ISO_PATH;
3973 big->state_vars.next_bis = 0;
3974 }
3975 } else {
3976 // create BIG failed or has been stopped by us
3976 hci_iso_stream_requested_finalize(big->big_handle);
3977 hci_iso_stream_finalize_by_type_and_group_id(HCI_ISO_TYPE_BIS, big->big_handle);
3977 btstack_linked_list_remove(&hci_stack->le_audio_bigs, (btstack_linked_item_t *) big);
3978 if (big->state == LE_AUDIO_BIG_STATE_W4_ESTABLISHED){
3979 hci_emit_big_created(big, status);
3980 } else {
3981 hci_emit_big_terminated(big);
3982 }
3983 }
3984 }

--- 4967 unchanged lines hidden (view full) ---

8952}
8953
8954static void hci_iso_stream_finalize(hci_iso_stream_t * iso_stream){
8955 log_info("hci_iso_stream_finalize con_handle 0x%04x, group_id 0x%02x", iso_stream->con_handle, iso_stream->group_id);
8956 btstack_linked_list_remove(&hci_stack->iso_streams, (btstack_linked_item_t*) iso_stream);
8957 btstack_memory_hci_iso_stream_free(iso_stream);
8958}
8959
3978 btstack_linked_list_remove(&hci_stack->le_audio_bigs, (btstack_linked_item_t *) big);
3979 if (big->state == LE_AUDIO_BIG_STATE_W4_ESTABLISHED){
3980 hci_emit_big_created(big, status);
3981 } else {
3982 hci_emit_big_terminated(big);
3983 }
3984 }
3985 }

--- 4967 unchanged lines hidden (view full) ---

8953}
8954
8955static void hci_iso_stream_finalize(hci_iso_stream_t * iso_stream){
8956 log_info("hci_iso_stream_finalize con_handle 0x%04x, group_id 0x%02x", iso_stream->con_handle, iso_stream->group_id);
8957 btstack_linked_list_remove(&hci_stack->iso_streams, (btstack_linked_item_t*) iso_stream);
8958 btstack_memory_hci_iso_stream_free(iso_stream);
8959}
8960
8961static void hci_iso_stream_finalize_by_type_and_group_id(hci_iso_type_t iso_type, uint8_t group_id) {
8962 btstack_linked_list_iterator_t it;
8963 btstack_linked_list_iterator_init(&it, &hci_stack->iso_streams);
8964 while (btstack_linked_list_iterator_has_next(&it)){
8965 hci_iso_stream_t * iso_stream = (hci_iso_stream_t *) btstack_linked_list_iterator_next(&it);
8966 if ((iso_stream->group_id == group_id) &&
8967 (iso_stream->iso_type == iso_type)){
8968 btstack_linked_list_iterator_remove(&it);
8969 btstack_memory_hci_iso_stream_free(iso_stream);
8970 }
8971 }
8972}
8973
8960static void hci_iso_stream_requested_finalize(uint8_t group_id) {
8961 btstack_linked_list_iterator_t it;
8962 btstack_linked_list_iterator_init(&it, &hci_stack->iso_streams);
8963 while (btstack_linked_list_iterator_has_next(&it)){
8964 hci_iso_stream_t * iso_stream = (hci_iso_stream_t *) btstack_linked_list_iterator_next(&it);
8965 if ((iso_stream->state == HCI_ISO_STREAM_STATE_REQUESTED ) &&
8966 (iso_stream->group_id == group_id)){
8967 btstack_linked_list_iterator_remove(&it);

--- 280 unchanged lines hidden (view full) ---

9248 status = hci_iso_stream_create(HCI_ISO_TYPE_BIS, HCI_CON_HANDLE_INVALID, big_params->big_handle);
9249 if (status != ERROR_CODE_SUCCESS) {
9250 break;
9251 }
9252 }
9253
9254 // free structs on error
9255 if (status != ERROR_CODE_SUCCESS){
8974static void hci_iso_stream_requested_finalize(uint8_t group_id) {
8975 btstack_linked_list_iterator_t it;
8976 btstack_linked_list_iterator_init(&it, &hci_stack->iso_streams);
8977 while (btstack_linked_list_iterator_has_next(&it)){
8978 hci_iso_stream_t * iso_stream = (hci_iso_stream_t *) btstack_linked_list_iterator_next(&it);
8979 if ((iso_stream->state == HCI_ISO_STREAM_STATE_REQUESTED ) &&
8980 (iso_stream->group_id == group_id)){
8981 btstack_linked_list_iterator_remove(&it);

--- 280 unchanged lines hidden (view full) ---

9262 status = hci_iso_stream_create(HCI_ISO_TYPE_BIS, HCI_CON_HANDLE_INVALID, big_params->big_handle);
9263 if (status != ERROR_CODE_SUCCESS) {
9264 break;
9265 }
9266 }
9267
9268 // free structs on error
9269 if (status != ERROR_CODE_SUCCESS){
9256 hci_iso_stream_requested_finalize(big_params->big_handle);
9270 hci_iso_stream_finalize_by_type_and_group_id(HCI_ISO_TYPE_BIS, big_params->big_handle);
9257 return status;
9258 }
9259
9260 le_audio_big_t * big = storage;
9261 big->big_handle = big_params->big_handle;
9262 big->params = big_params;
9263 big->state = LE_AUDIO_BIG_STATE_CREATE;
9264 big->num_bis = big_params->num_bis;

--- 163 unchanged lines hidden ---
9271 return status;
9272 }
9273
9274 le_audio_big_t * big = storage;
9275 big->big_handle = big_params->big_handle;
9276 big->params = big_params;
9277 big->state = LE_AUDIO_BIG_STATE_CREATE;
9278 big->num_bis = big_params->num_bis;

--- 163 unchanged lines hidden ---