hci: check as first the connection identifier, then if there is a free place on Bluetooth module

This commit is contained in:
Milanka Ringwald 2023-05-25 17:27:00 +02:00 committed by Matthias Ringwald
parent 7555fa8be4
commit 79a2851b6a

View File

@ -965,14 +965,6 @@ uint8_t hci_send_acl_packet_buffer(int size){
uint8_t * packet = hci_stack->hci_packet_buffer;
hci_con_handle_t con_handle = READ_ACL_CONNECTION_HANDLE(packet);
// check for free places on Bluetooth module
if (!hci_can_send_prepared_acl_packet_now(con_handle)) {
log_error("hci_send_acl_packet_buffer called but no free ACL buffers on controller");
hci_release_packet_buffer();
hci_emit_transport_packet_sent();
return BTSTACK_ACL_BUFFERS_FULL;
}
hci_connection_t *connection = hci_connection_for_handle( con_handle);
if (!connection) {
log_error("hci_send_acl_packet_buffer called but no connection for handle 0x%04x", con_handle);
@ -981,6 +973,14 @@ uint8_t hci_send_acl_packet_buffer(int size){
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
}
// check for free places on Bluetooth module
if (!hci_can_send_prepared_acl_packet_now(con_handle)) {
log_error("hci_send_acl_packet_buffer called but no free ACL buffers on controller");
hci_release_packet_buffer();
hci_emit_transport_packet_sent();
return BTSTACK_ACL_BUFFERS_FULL;
}
#ifdef ENABLE_CLASSIC
hci_connection_timestamp(connection);
#endif