From 5453bb52682462393d1763246d3a70426f39ac20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Fri, 19 Sep 2025 10:23:32 +0200 Subject: [PATCH] shared/hfp: Add Call hangup support --- src/shared/hfp.c | 25 +++++++++++++++++++++++++ src/shared/hfp.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/src/shared/hfp.c b/src/shared/hfp.c index 7e35f239a..133bff248 100644 --- a/src/shared/hfp.c +++ b/src/shared/hfp.c @@ -2446,3 +2446,28 @@ bool hfp_hf_call_answer(struct hfp_hf *hfp, uint id, return hfp_hf_send_command(hfp, resp_cb, user_data, "ATA"); } + +bool hfp_hf_call_hangup(struct hfp_hf *hfp, uint id, + hfp_response_func_t resp_cb, + void *user_data) +{ + struct hf_call *call; + + DBG(hfp, ""); + + if (!hfp) + return false; + + call = queue_find(hfp->calls, call_id_match, UINT_TO_PTR(id)); + if (!call) { + DBG(hfp, "hf: no call with id: %u", id); + return false; + } + + if (call_setup_match(call, NULL) || call_active_match(call, NULL)) { + return hfp_hf_send_command(hfp, resp_cb, user_data, + "AT+CHUP"); + } + + return false; +} diff --git a/src/shared/hfp.h b/src/shared/hfp.h index c623e48e6..4b171ad88 100644 --- a/src/shared/hfp.h +++ b/src/shared/hfp.h @@ -240,3 +240,6 @@ const char *hfp_hf_call_get_number(struct hfp_hf *hfp, uint id); bool hfp_hf_call_answer(struct hfp_hf *hfp, uint id, hfp_response_func_t resp_cb, void *user_data); +bool hfp_hf_call_hangup(struct hfp_hf *hfp, uint id, + hfp_response_func_t resp_cb, + void *user_data); -- 2.47.3