From 22387625cf94157435d791d1c4eb2cac85b556df Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 10 Apr 2018 11:28:59 +0200 Subject: [PATCH] hfp: fix state management when hf + ag are active --- src/classic/hfp_ag.c | 6 ++++++ src/classic/hfp_hf.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/classic/hfp_ag.c b/src/classic/hfp_ag.c index ca5d6a54e..6d4caa1d0 100644 --- a/src/classic/hfp_ag.c +++ b/src/classic/hfp_ag.c @@ -1610,6 +1610,11 @@ static void hfp_run_for_context(hfp_connection_t *hfp_connection){ if (!hfp_connection) 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)) { 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); @@ -2000,6 +2005,7 @@ static void hfp_run(void){ btstack_linked_list_iterator_init(&it, hfp_get_connections()); while (btstack_linked_list_iterator_has_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); } } diff --git a/src/classic/hfp_hf.c b/src/classic/hfp_hf.c index e31011d1a..8ea230b12 100644 --- a/src/classic/hfp_hf.c +++ b/src/classic/hfp_hf.c @@ -552,6 +552,11 @@ static void hfp_run_for_context(hfp_connection_t * hfp_connection){ if (!hfp_connection) 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()){ hfp_connection->hf_accept_sco = 0; @@ -1066,6 +1071,7 @@ static void hfp_run(void){ btstack_linked_list_iterator_init(&it, hfp_get_connections()); while (btstack_linked_list_iterator_has_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); } }