hfp_hf: request can send now when needed

This commit is contained in:
Matthias Ringwald 2018-04-09 15:50:35 +02:00
parent 520c92d527
commit d4dd47ff43

View File

@ -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: