All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC BlueZ 05/10] audio/hfp-hf: Add dial support
Date: Wed, 28 May 2025 10:59:25 +0200	[thread overview]
Message-ID: <20250528085930.227816-6-frederic.danis@collabora.com> (raw)
In-Reply-To: <20250528085930.227816-1-frederic.danis@collabora.com>

---
 profiles/audio/hfp-hf.c | 72 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/profiles/audio/hfp-hf.c b/profiles/audio/hfp-hf.c
index 5068fff01..395f7ba61 100644
--- a/profiles/audio/hfp-hf.c
+++ b/profiles/audio/hfp-hf.c
@@ -36,6 +36,7 @@
 #include "src/btd.h"
 #include "src/dbus-common.h"
 #include "src/device.h"
+#include "src/error.h"
 #include "src/log.h"
 #include "src/plugin.h"
 #include "src/profile.h"
@@ -980,7 +981,78 @@ failed:
 	device_destroy(dev);
 }
 
+static void hfp_dial_cb(enum hfp_result result, enum hfp_error cme_err,
+							void *user_data)
+{
+	struct call *call = user_data;
+	DBusMessage *msg = call->pending_msg;
+	DBusMessage *reply;
+	struct hfp_device *dev = telephony_get_profile_data(call->device);
+
+	DBG("");
+
+	call->pending_msg = NULL;
+
+	if (result != HFP_RESULT_OK) {
+		error("Dialing error: %d", result);
+		reply = g_dbus_create_error(msg, ERROR_INTERFACE
+					".Failed",
+					"Dial command failed: %d", result);
+		g_dbus_send_message(btd_get_dbus_connection(), reply);
+		telephony_free_call(call);
+		return;
+	}
+
+	if (telephony_call_register_interface(call)) {
+		telephony_free_call(call);
+		return;
+	}
+
+	dev->calls = g_slist_append(dev->calls, call);
+
+	g_dbus_send_reply(btd_get_dbus_connection(), msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *hfp_dial(DBusConnection *conn, DBusMessage *msg,
+				void *profile_data)
+{
+	struct hfp_device *dev = profile_data;
+	const char *number;
+	struct call *call;
+
+	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &number,
+					DBUS_TYPE_INVALID)) {
+		return btd_error_invalid_args(msg);
+	}
+
+	call = telephony_new_call(dev->telephony, CALL_STATE_DIALING, NULL);
+	call->pending_msg = dbus_message_ref(msg);
+
+	if (number != NULL && number[0] != '\0') {
+		DBG("Dialing %s", number);
+
+		call->line_id = g_strdup(number);
+
+		if (!hfp_hf_send_command(dev->hf, hfp_dial_cb, call,
+							"ATD%s;", number))
+			goto failed;
+	} else {
+		DBG("Redialing");
+
+		if (!hfp_hf_send_command(dev->hf, hfp_dial_cb, call,
+							"AT+BLDN"))
+			goto failed;
+	}
+
+	return NULL;
+
+failed:
+	telephony_free_call(call);
+	return btd_error_failed(msg, "Dial command failed");
+}
+
 struct telephony_callbacks hfp_callbacks = {
+	.dial = hfp_dial,
 };
 
 static int hfp_connect(struct btd_service *service)
-- 
2.43.0


  parent reply	other threads:[~2025-05-28  8:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-28  8:59 [RFC BlueZ 00/10] New Telephony interface for HSP, HFP and CCP Frédéric Danis
2025-05-28  8:59 ` [RFC BlueZ 01/10] doc: Add new telephony related profiles interfaces Frédéric Danis
2025-05-28 10:33   ` New Telephony interface for HSP, HFP and CCP bluez.test.bot
2025-05-28  8:59 ` [RFC BlueZ 02/10] audio/telephony: Add shared interfaces implementation Frédéric Danis
2025-05-28  8:59 ` [RFC BlueZ 03/10] audio/telephony: Add skeleton for HFP profile Frédéric Danis
2025-05-28  8:59 ` [RFC BlueZ 04/10] audio/hfp-hf: Add HFP SLC connection and event support Frédéric Danis
2025-05-28  8:59 ` Frédéric Danis [this message]
2025-05-28  8:59 ` [RFC BlueZ 06/10] audio/hfp-hf: Add hangup all calls support Frédéric Danis
2025-05-28  8:59 ` [RFC BlueZ 07/10] audio/hfp-hf: Add answer a specific call support Frédéric Danis
2025-05-28  8:59 ` [RFC BlueZ 08/10] client/telephony: Add new submenu Frédéric Danis
2025-05-28  8:59 ` [RFC BlueZ 09/10] audio/hfp-hf: Remove call interface during profile disconnection Frédéric Danis
2025-05-28  8:59 ` [RFC BlueZ 10/10] audio/hfp-hf: Create existing call during SLC phase Frédéric Danis

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=20250528085930.227816-6-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.