hfp: fix state management when hf + ag are active

This commit is contained in:
Matthias Ringwald 2018-04-10 11:28:59 +02:00
parent d4dd47ff43
commit 22387625cf
2 changed files with 12 additions and 0 deletions

View File

@ -1610,6 +1610,11 @@ static void hfp_run_for_context(hfp_connection_t *hfp_connection){
if (!hfp_connection) return; if (!hfp_connection) return;
if (!hfp_connection->rfcomm_cid) return; if (!hfp_connection->rfcomm_cid) return;
if (hfp_connection->local_role != HFP_ROLE_AG) {
log_info("HFP AG%p, wrong role %u", hfp_connection, hfp_connection->local_role);
return;
}
if (!rfcomm_can_send_packet_now(hfp_connection->rfcomm_cid)) { if (!rfcomm_can_send_packet_now(hfp_connection->rfcomm_cid)) {
log_info("hfp_run_for_context: request can send for 0x%02x", hfp_connection->rfcomm_cid); log_info("hfp_run_for_context: request can send for 0x%02x", hfp_connection->rfcomm_cid);
rfcomm_request_can_send_now_event(hfp_connection->rfcomm_cid); rfcomm_request_can_send_now_event(hfp_connection->rfcomm_cid);
@ -2000,6 +2005,7 @@ static void hfp_run(void){
btstack_linked_list_iterator_init(&it, hfp_get_connections()); btstack_linked_list_iterator_init(&it, hfp_get_connections());
while (btstack_linked_list_iterator_has_next(&it)){ while (btstack_linked_list_iterator_has_next(&it)){
hfp_connection_t * hfp_connection = (hfp_connection_t *)btstack_linked_list_iterator_next(&it); hfp_connection_t * hfp_connection = (hfp_connection_t *)btstack_linked_list_iterator_next(&it);
if (hfp_connection->local_role != HFP_ROLE_AG) continue;
hfp_run_for_context(hfp_connection); hfp_run_for_context(hfp_connection);
} }
} }

View File

@ -552,6 +552,11 @@ static void hfp_run_for_context(hfp_connection_t * hfp_connection){
if (!hfp_connection) return; if (!hfp_connection) return;
if (!hfp_connection->rfcomm_cid) return; if (!hfp_connection->rfcomm_cid) return;
if (hfp_connection->local_role != HFP_ROLE_HF) {
log_info("HFP HF%p, wrong role %u", hfp_connection, hfp_connection->local_role);
return;
}
if (hfp_connection->hf_accept_sco && hci_can_send_command_packet_now()){ if (hfp_connection->hf_accept_sco && hci_can_send_command_packet_now()){
hfp_connection->hf_accept_sco = 0; hfp_connection->hf_accept_sco = 0;
@ -1066,6 +1071,7 @@ static void hfp_run(void){
btstack_linked_list_iterator_init(&it, hfp_get_connections()); btstack_linked_list_iterator_init(&it, hfp_get_connections());
while (btstack_linked_list_iterator_has_next(&it)){ while (btstack_linked_list_iterator_has_next(&it)){
hfp_connection_t * hfp_connection = (hfp_connection_t *)btstack_linked_list_iterator_next(&it); hfp_connection_t * hfp_connection = (hfp_connection_t *)btstack_linked_list_iterator_next(&it);
if (hfp_connection->local_role != HFP_ROLE_HF) continue;
hfp_run_for_context(hfp_connection); hfp_run_for_context(hfp_connection);
} }
} }