mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 01:27:41 +00:00
hci: add hci_request_cis_can_send_now_events that causes HCI_EVENT_CIS_CAN_SEND_NOW
This commit is contained in:
parent
86d67f18a0
commit
2c07777174
36
src/hci.c
36
src/hci.c
@ -9414,6 +9414,15 @@ static void hci_emit_bis_can_send_now(const le_audio_big_t *big, uint8_t bis_ind
|
||||
hci_emit_event(&event[0], sizeof(event), 0); // don't dump
|
||||
}
|
||||
|
||||
static void hci_emit_cis_can_send_now(hci_con_handle_t cis_con_handle) {
|
||||
uint8_t event[4];
|
||||
uint16_t pos = 0;
|
||||
event[pos++] = HCI_EVENT_CIS_CAN_SEND_NOW;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
little_endian_store_16(event, pos, cis_con_handle);
|
||||
hci_emit_event(&event[0], sizeof(event), 0); // don't dump
|
||||
}
|
||||
|
||||
static le_audio_big_t * hci_big_for_handle(uint8_t big_handle){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, &hci_stack->le_audio_bigs);
|
||||
@ -9455,6 +9464,9 @@ static le_audio_cig_t * hci_cig_for_id(uint8_t cig_id){
|
||||
}
|
||||
|
||||
static void hci_iso_notify_can_send_now(void){
|
||||
|
||||
// BIG
|
||||
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, &hci_stack->le_audio_bigs);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
@ -9532,6 +9544,17 @@ static void hci_iso_notify_can_send_now(void){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CIS
|
||||
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);
|
||||
if ((iso_stream->can_send_now_requested) &&
|
||||
(iso_stream->num_packets_sent < hci_stack->iso_packets_to_queue)){
|
||||
iso_stream->can_send_now_requested = false;
|
||||
hci_emit_cis_can_send_now(iso_stream->con_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t gap_big_create(le_audio_big_t * storage, le_audio_big_params_t * big_params){
|
||||
@ -9660,6 +9683,19 @@ uint8_t hci_request_bis_can_send_now_events(uint8_t big_handle){
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t hci_request_cis_can_send_now_events(hci_con_handle_t cis_con_handle){
|
||||
hci_iso_stream_t * iso_stream = hci_iso_stream_for_con_handle(cis_con_handle);
|
||||
if (iso_stream == NULL){
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
if ((iso_stream->iso_type != HCI_ISO_TYPE_CIS) && (iso_stream->state != HCI_ISO_STREAM_STATE_ESTABLISHED)) {
|
||||
return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
}
|
||||
iso_stream->can_send_now_requested = true;
|
||||
hci_iso_notify_can_send_now();
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t gap_cig_create(le_audio_cig_t * storage, le_audio_cig_params_t * cig_params){
|
||||
if (hci_cig_for_id(cig_params->cig_id) != NULL){
|
||||
return ERROR_CODE_ACL_CONNECTION_ALREADY_EXISTS;
|
||||
|
11
src/hci.h
11
src/hci.h
@ -722,6 +722,9 @@ typedef struct {
|
||||
// packets to skip due to queuing them to late before
|
||||
uint8_t num_packets_to_skip;
|
||||
|
||||
// request to send
|
||||
bool can_send_now_requested;
|
||||
|
||||
// ready to send
|
||||
bool emit_ready_to_send;
|
||||
|
||||
@ -1412,6 +1415,14 @@ uint8_t hci_send_sco_packet_buffer(int size);
|
||||
*/
|
||||
uint8_t hci_request_bis_can_send_now_events(uint8_t big_handle);
|
||||
|
||||
/**
|
||||
* @brief Request emission of HCI_EVENT_CIS_CAN_SEND_NOW for CIS as soon as possible
|
||||
* @param cis_con_handle
|
||||
* @note HCI_EVENT_CIS_CAN_SEND_NOW might be emitted during call to this function
|
||||
* so packet handler should be ready to handle it
|
||||
*/
|
||||
uint8_t hci_request_cis_can_send_now_events(hci_con_handle_t cis_con_handle);
|
||||
|
||||
/**
|
||||
* @brief Send ISO packet prepared in HCI packet buffer
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user