diff --git a/src/classic/hfp_hf.c b/src/classic/hfp_hf.c index d286d8f80..e31011d1a 100644 --- a/src/classic/hfp_hf.c +++ b/src/classic/hfp_hf.c @@ -52,6 +52,7 @@ #include "bluetooth_sdp.h" #include "btstack_debug.h" +#include "btstack_event.h" #include "btstack_memory.h" #include "btstack_run_loop.h" #include "classic/core.h" @@ -587,8 +588,10 @@ static void hfp_run_for_context(hfp_connection_t * hfp_connection){ return; } - if (!rfcomm_can_send_packet_now(hfp_connection->rfcomm_cid)) return; - + if (!rfcomm_can_send_packet_now(hfp_connection->rfcomm_cid)) { + rfcomm_request_can_send_now_event(hfp_connection->rfcomm_cid); + return; + } int done = hfp_hf_run_for_context_service_level_connection(hfp_connection); if (!done){ done = hfp_hf_run_for_context_service_level_connection_queries(hfp_connection); @@ -1073,6 +1076,11 @@ static void rfcomm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t hfp_hf_handle_rfcomm_event(packet_type, channel, packet, size); break; case HCI_EVENT_PACKET: + if (packet[0] == RFCOMM_EVENT_CAN_SEND_NOW){ + uint16_t rfcomm_cid = rfcomm_event_can_send_now_get_rfcomm_cid(packet); + hfp_run_for_context(get_hfp_connection_context_for_rfcomm_cid(rfcomm_cid)); + return; + } hfp_handle_hci_event(packet_type, channel, packet, size, HFP_ROLE_HF); break; default: