From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 1/5] shared/hfp: Add Call answer support
Date: Fri, 19 Sep 2025 10:23:30 +0200 [thread overview]
Message-ID: <20250919082334.1443310-1-frederic.danis@collabora.com> (raw)
This also manage the +CIEV:<call>,… event to create, remove or update
calls.
---
src/shared/hfp.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++
src/shared/hfp.h | 4 +++
2 files changed, 83 insertions(+)
diff --git a/src/shared/hfp.c b/src/shared/hfp.c
index 29b467ae3..7e35f239a 100644
--- a/src/shared/hfp.c
+++ b/src/shared/hfp.c
@@ -1651,9 +1651,36 @@ static void ciev_service_cb(uint8_t val, void *user_data)
hfp->callbacks_data);
}
+static bool update_call_to_active(struct hfp_hf *hfp)
+{
+ const struct queue_entry *entry;
+ struct hf_call *call;
+
+ for (entry = queue_get_entries(hfp->calls); entry;
+ entry = entry->next) {
+ call = entry->data;
+
+ if (call->status == CALL_STATUS_DIALING ||
+ call->status == CALL_STATUS_ALERTING ||
+ call->status == CALL_STATUS_INCOMING) {
+ call->status = CALL_STATUS_ACTIVE;
+ if (hfp->callbacks &&
+ hfp->callbacks->call_status_updated)
+ hfp->callbacks->call_status_updated(
+ call->id,
+ call->status,
+ hfp->callbacks_data);
+ return true;
+ }
+ }
+
+ return false;
+}
+
static void ciev_call_cb(uint8_t val, void *user_data)
{
struct hfp_hf *hfp = user_data;
+ uint id;
DBG(hfp, "%u", val);
@@ -1662,6 +1689,32 @@ static void ciev_call_cb(uint8_t val, void *user_data)
DBG(hfp, "hf: Incorrect call state: %u", val);
return;
}
+
+ switch (val) {
+ case CIND_CALL_NONE:
+ /* Remove all calls */
+ queue_remove_all(hfp->calls, NULL, hfp, remove_call_cb);
+ break;
+ case CIND_CALL_IN_PROGRESS:
+ {
+ /* Find incoming, dialing or alerting call to change
+ * it to active
+ */
+ if (update_call_to_active(hfp))
+ return;
+
+ /* else create new already active call */
+ id = next_call_index(hfp);
+ if (id == 0) {
+ DBG(hfp, "hf: No new call index available");
+ return;
+ }
+ call_new(hfp, id, CALL_STATUS_ACTIVE, NULL);
+ }
+ break;
+ default:
+ DBG(hfp, "hf: Unsupported call state: %u", val);
+ }
}
static bool call_outgoing_match(const void *data, const void *match_data)
@@ -2367,3 +2420,29 @@ const char *hfp_hf_call_get_number(struct hfp_hf *hfp, uint id)
return call->line_id;
}
+
+bool hfp_hf_call_answer(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->status != CALL_STATUS_INCOMING) {
+ DBG(hfp, "hf: %d not in incoming call state: %u",
+ call->status);
+ return false;
+ }
+
+ return hfp_hf_send_command(hfp, resp_cb, user_data, "ATA");
+}
diff --git a/src/shared/hfp.h b/src/shared/hfp.h
index fec63c150..c623e48e6 100644
--- a/src/shared/hfp.h
+++ b/src/shared/hfp.h
@@ -236,3 +236,7 @@ bool hfp_hf_session_register(struct hfp_hf *hfp,
bool hfp_hf_session(struct hfp_hf *hfp);
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);
--
2.43.0
next reply other threads:[~2025-09-19 8:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 8:23 Frédéric Danis [this message]
2025-09-19 8:23 ` [PATCH BlueZ 2/5] unit/test-hfp: Add Answer Incoming Call tests for HF Frédéric Danis
2025-09-19 8:23 ` [PATCH BlueZ 3/5] shared/hfp: Add Call hangup support Frédéric Danis
2025-09-19 8:23 ` [PATCH BlueZ 4/5] unit/test-hfp: Add Reject Incoming Call tests for HF Frédéric Danis
2025-09-19 8:23 ` [PATCH BlueZ 5/5] unit/test-hfp: Add Terminate " Frédéric Danis
2025-09-19 9:51 ` [BlueZ,1/5] shared/hfp: Add Call answer support bluez.test.bot
2025-09-30 16:50 ` [PATCH BlueZ 1/5] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250919082334.1443310-1-frederic.danis@collabora.com \
--to=frederic.danis@collabora.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.