From 75b4c3379df11e0b9859d31a76bd5e4df7f2f809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Wed, 11 Jun 2025 12:10:25 +0200 Subject: [PATCH] bluez5: hfp-hf: If available use AT+CLCC only to update calls state --- spa/plugins/bluez5/backend-native.c | 30 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/spa/plugins/bluez5/backend-native.c b/spa/plugins/bluez5/backend-native.c index 26fe3b033..17288bcbc 100644 --- a/spa/plugins/bluez5/backend-native.c +++ b/spa/plugins/bluez5/backend-native.c @@ -2214,6 +2214,11 @@ static bool rfcomm_hfp_hf(struct rfcomm *rfcomm, char* token) if (spa_streq(rfcomm->hf_indicators[indicator], "battchg")) { spa_bt_device_report_battery_level(rfcomm->device, value * 100 / 5); } else if (spa_streq(rfcomm->hf_indicators[indicator], "callsetup")) { + if (rfcomm->hfp_hf_clcc) { + rfcomm_send_cmd(rfcomm, "AT+CLCC"); + return true; + } + if (value == CIND_CALLSETUP_NONE) { struct spa_bt_telephony_call *call, *tcall; spa_list_for_each_safe(call, tcall, &rfcomm->telephony_ag->call_list, link) { @@ -2268,11 +2273,13 @@ static bool rfcomm_hfp_hf(struct rfcomm *rfcomm, char* token) } } - if (rfcomm->hfp_hf_clcc) - rfcomm_send_cmd(rfcomm, "AT+CLCC"); - else - rfcomm->hfp_hf_in_progress = false; + rfcomm->hfp_hf_in_progress = false; } else if (spa_streq(rfcomm->hf_indicators[indicator], "call")) { + if (rfcomm->hfp_hf_clcc) { + rfcomm_send_cmd(rfcomm, "AT+CLCC"); + return true; + } + if (value == 0) { struct spa_bt_telephony_call *call, *tcall; spa_list_for_each_safe(call, tcall, &rfcomm->telephony_ag->call_list, link) { @@ -2293,11 +2300,13 @@ static bool rfcomm_hfp_hf(struct rfcomm *rfcomm, char* token) } } - if (rfcomm->hfp_hf_clcc) - rfcomm_send_cmd(rfcomm, "AT+CLCC"); - else - rfcomm->hfp_hf_in_progress = false; + rfcomm->hfp_hf_in_progress = false; } else if (spa_streq(rfcomm->hf_indicators[indicator], "callheld")) { + if (rfcomm->hfp_hf_clcc) { + rfcomm_send_cmd(rfcomm, "AT+CLCC"); + return true; + } + if (value == 0) { /* Reject waiting call or no held calls */ struct spa_bt_telephony_call *call, *tcall; bool found_waiting = false; @@ -2348,10 +2357,7 @@ static bool rfcomm_hfp_hf(struct rfcomm *rfcomm, char* token) } } - if (rfcomm->hfp_hf_clcc) - rfcomm_send_cmd(rfcomm, "AT+CLCC"); - else - rfcomm->hfp_hf_in_progress = false; + rfcomm->hfp_hf_in_progress = false; } } } else if (sscanf(token, "+CLIP: \"%16[^\"]\",%u", number, &type) == 2) {