Skip to contentSkip to conversation

doc: Add new telephony related profiles interfaces

PATCH Applied Frédéric Danis 3 participants 7 messages Dec 11, 2025 – Dec 12, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/5 doc: Add new telephony related profiles interfaces

These are interfaces are meant to be generic to the telephony related "headset" profiles like HSP HS, HFP HF, and CCP.

---
 Makefile.am                 |   4 +
 doc/org.bluez.Call.rst      | 140 ++++++++++++++++++++++
 doc/org.bluez.Telephony.rst | 225 ++++++++++++++++++++++++++++++++++++
 3 files changed, 369 insertions(+)
 create mode 100644 doc/org.bluez.Call.rst
 create mode 100644 doc/org.bluez.Telephony.rst
Makefile.am +4 -0
index e152ae648..060a90cfc 100644
@@ -397,6 +397,7 @@ man_MANS += doc/org.bluez.obex.Client.5 doc/org.bluez.obex.Session.5 \
 		doc/org.bluez.obex.Message.5 \
 		doc/org.bluez.obex.AgentManager.5 doc/org.bluez.obex.Agent.5 \
 		doc/org.bluez.obex.Image.5
+man_MANS += doc/org.bluez.Telephony.5 doc/org.bluez.Call.5
 endif
 manual_pages += src/bluetoothd.8
 manual_pages += doc/hci.7 doc/mgmt.7 doc/l2cap.7 doc/rfcomm.7 doc/sco.7 \
@@ -433,6 +434,7 @@ manual_pages += doc/org.bluez.obex.Client.5 doc/org.bluez.obex.Session.5 \
 		doc/org.bluez.obex.Message.5 \
 		doc/org.bluez.obex.AgentManager.5 doc/org.bluez.obex.Agent.5 \
 		doc/org.bluez.obex.Image.5
+manual_pages += doc/org.bluez.Telephony.5 doc/org.bluez.Call.5
 
 EXTRA_DIST += src/genbuiltin src/bluetooth.conf \
 			src/main.conf profiles/network/network.conf \
@@ -517,6 +519,8 @@ EXTRA_DIST += doc/org.bluez.obex.Client.rst doc/org.bluez.obex.Session.rst \
 		doc/org.bluez.obex.AgentManager.rst doc/org.bluez.obex.Agent.rst \
 		doc/org.bluez.obex.Image.rst
 
+EXTRA_DIST += doc/org.bluez.Telephony.rst doc/org.bluez.Call.rst
+
 EXTRA_DIST += doc/pics-opp.txt doc/pixit-opp.txt \
 		doc/pts-opp.txt
 
doc/org.bluez.Call.rst new file +140 -0

140 lines not on this page · raw message

doc/org.bluez.Telephony.rst new file +225 -0

225 lines not on this page · raw message

Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 2/5 audio/telephony: Add shared interfaces implementation

This implements the Telephony and Call DBus interfaces which will be shared by telephony related "headset" profiles.
---
v1->v2: Improve commit message

 profiles/audio/telephony.c | 885 +++++++++++++++++++++++++++++++++++++
 profiles/audio/telephony.h | 115 +++++
 2 files changed, 1000 insertions(+)
 create mode 100644 profiles/audio/telephony.c
 create mode 100644 profiles/audio/telephony.h
profiles/audio/telephony.c new file +885 -0
new file mode 100644
index 000000000..454b6882c
@@ -0,0 +1,885 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright © 2025 Collabora Ltd.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <limits.h>
+
+#include <stdint.h>
+
+#include <glib.h>
+
+#include "bluetooth/bluetooth.h"
+#include "bluetooth/sdp.h"
+#include "bluetooth/sdp_lib.h"
+#include "bluetooth/uuid.h"
+
+#include "gdbus/gdbus.h"
+
+#include "btio/btio.h"
+#include "src/adapter.h"
+#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"
+#include "src/service.h"
+#include "src/shared/hfp.h"
+
+#include "telephony.h"
+
+#define TELEPHONY_INTERFACE "org.bluez.Telephony1"
+#define TELEPHONY_CALL_INTERFACE "org.bluez.Call1"
+
+struct telephony {
+	struct btd_service		*service;
+	struct btd_device		*device;
+	char				*path;
+	bdaddr_t			src;
+	bdaddr_t			dst;
+	void				*profile_data;
+	struct telephony_callbacks	*cbs;
+	GSList				*uri_schemes;
+	enum connection_state		state;
+	bool				network_service;
+	uint8_t				signal;
+	bool				roaming;
+	uint8_t				battchg;
+	char				*operator_name;
+	bool				inband_ringtone;
+};
+
+static const char *state_to_string(enum connection_state state)
+{
+	switch (state) {
+	case CONNECTING:
+		return "connecting";
+	case SESSION_CONNECTING:
+		return "session_connecting";
+	case CONNECTED:
+		return "connected";
+	case DISCONNECTING:
+		return "disconnecting";
+	}
+
+	return NULL;
+}
+
+static const char *call_state_to_string(enum call_state state)
+{
+	switch (state) {
+	case CALL_STATE_ACTIVE:
+		return "active";
+	case CALL_STATE_HELD:
+		return "held";
+	case CALL_STATE_DIALING:
+		return "dialing";
+	case CALL_STATE_ALERTING:
+		return "alerting";
+	case CALL_STATE_INCOMING:
+		return "incoming";
+	case CALL_STATE_WAITING:
+		return "waiting";
+	case CALL_STATE_RESPONSE_AND_HOLD:
+		return "response_and_hold";
+	case CALL_STATE_DISCONNECTED:
+		return "disconnected";
+	}
+
+	return NULL;
+}
+
+struct telephony *telephony_new(struct btd_service *service,
+				void *profile_data,
+				struct telephony_callbacks *cbs)
+{
+	struct btd_device *device = btd_service_get_device(service);
+	const char *path = device_get_path(device);
+	struct btd_adapter *adapter = device_get_adapter(device);
+	struct telephony *ag;
+	static int id;
+
+	ag = g_new0(struct telephony, 1);
+	bacpy(&ag->src, btd_adapter_get_address(adapter));
+	bacpy(&ag->dst, device_get_address(device));
+	ag->service = btd_service_ref(service);
+	ag->device = btd_device_ref(device);
+	ag->path = g_strdup_printf("%s/telephony%u", path, id++);
+	ag->profile_data = profile_data;
+	ag->cbs = cbs;
+
+	return ag;
+}
+
+void telephony_free(struct telephony *telephony)
+{
+	btd_service_unref(telephony->service);
+	btd_device_unref(telephony->device);
+	g_free(telephony->operator_name);
+	g_slist_free_full(telephony->uri_schemes, g_free);
+	g_free(telephony->path);
+	g_free(telephony);
+}
+
+static DBusMessage *dial(DBusConnection *conn, DBusMessage *msg,
+					void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	if (telephony->cbs && telephony->cbs->dial)
+		return telephony->cbs->dial(conn, msg,
+					telephony->profile_data);
+
+	return btd_error_not_supported(msg);
+}
+
+static DBusMessage *swap_calls(DBusConnection *conn, DBusMessage *msg,
+					void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	if (telephony->cbs && telephony->cbs->swap_calls)
+		return telephony->cbs->swap_calls(conn, msg,
+					telephony->profile_data);
+
+	return btd_error_not_supported(msg);
+}
+
+static DBusMessage *release_and_answer(DBusConnection *conn, DBusMessage *msg,
+	void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	if (telephony->cbs && telephony->cbs->release_and_answer)
+		return telephony->cbs->release_and_answer(conn, msg,
+					telephony->profile_data);
+
+	return btd_error_not_supported(msg);
+}
+
+static DBusMessage *release_and_swap(DBusConnection *conn, DBusMessage *msg,
+	void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	if (telephony->cbs && telephony->cbs->release_and_swap)
+		return telephony->cbs->release_and_swap(conn, msg,
+					telephony->profile_data);
+
+	return btd_error_not_supported(msg);
+}
+
+static DBusMessage *hold_and_answer(DBusConnection *conn, DBusMessage *msg,
+	void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	if (telephony->cbs && telephony->cbs->hold_and_answer)
+		return telephony->cbs->hold_and_answer(conn, msg,
+					telephony->profile_data);
+
+	return btd_error_not_supported(msg);
+}
+
+static DBusMessage *hangup_all(DBusConnection *conn, DBusMessage *msg,
+	void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	if (telephony->cbs && telephony->cbs->hangup_all)
+		return telephony->cbs->hangup_all(conn, msg,
+					telephony->profile_data);
+
+	return btd_error_not_supported(msg);
+}
+
+static DBusMessage *create_multiparty(DBusConnection *conn, DBusMessage *msg,
+	void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	if (telephony->cbs && telephony->cbs->create_multiparty)
+		return telephony->cbs->create_multiparty(conn, msg,
+					telephony->profile_data);
+
+	return btd_error_not_supported(msg);
+}
+
+static DBusMessage *send_tones(DBusConnection *conn, DBusMessage *msg,
+	void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	if (telephony->cbs && telephony->cbs->send_tones)
+		return telephony->cbs->send_tones(conn, msg,
+					telephony->profile_data);
+
+	return btd_error_not_supported(msg);
+}
+
+static gboolean property_get_uuid(const GDBusPropertyTable *property,
+					DBusMessageIter *iter,
+					void *user_data)
+{
+	struct telephony *telephony = user_data;
+	struct btd_profile *p = btd_service_get_profile(telephony->service);
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &p->remote_uuid);
+
+	return TRUE;
+}
+
+static gboolean property_get_uri_schemes(const GDBusPropertyTable *property,
+					DBusMessageIter *iter,
+					void *user_data)
+{
+	struct telephony *telephony = user_data;
+	DBusMessageIter entry;
+	GSList *l;
+
+	dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+				DBUS_TYPE_STRING_AS_STRING, &entry);
+
+	for (l = telephony->uri_schemes; l != NULL; l = l->next)
+		dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
+							&l->data);
+
+	dbus_message_iter_close_container(iter, &entry);
+
+	return TRUE;
+}
+
+static gboolean property_get_state(const GDBusPropertyTable *property,
+					DBusMessageIter *iter,
+					void *user_data)
+{
+	struct telephony *telephony = user_data;
+	const char *string;
+
+	string = state_to_string(telephony->state);
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &string);
+
+	return TRUE;
+}
+
+static gboolean property_get_service(const GDBusPropertyTable *property,
+					DBusMessageIter *iter,
+					void *user_data)
+{
+	struct telephony *telephony = user_data;
+	dbus_bool_t value;
+
+	value = telephony->network_service;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &value);
+
+	return TRUE;
+}
+
+static gboolean property_get_signal(const GDBusPropertyTable *property,
+					DBusMessageIter *iter,
+					void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE,
+					&telephony->signal);
+
+	return TRUE;
+}
+
+static gboolean property_get_roaming(const GDBusPropertyTable *property,
+					DBusMessageIter *iter,
+					void *user_data)
+{
+	struct telephony *telephony = user_data;
+	dbus_bool_t value;
+
+	value = telephony->roaming;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &value);
+
+	return TRUE;
+}
+
+static gboolean property_get_battchg(const GDBusPropertyTable *property,
+					DBusMessageIter *iter,
+					void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE,
+					&telephony->battchg);
+
+	return TRUE;
+}
+
+static gboolean property_operator_name_exists(
+	const GDBusPropertyTable *property,
+	void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	return telephony->operator_name != NULL;
+}
+
+static gboolean property_get_operator_name(const GDBusPropertyTable *property,
+	DBusMessageIter *iter, void *user_data)
+{
+	struct telephony *telephony = user_data;
+
+	if (telephony->operator_name == NULL)
+		return FALSE;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
+					&telephony->operator_name);
+
+	return TRUE;
+}
+
+static gboolean property_get_inband_ringtone(const GDBusPropertyTable *property,
+					DBusMessageIter *iter,
+					void *user_data)
+{
+	struct telephony *telephony = user_data;
+	dbus_bool_t value;
+
+	value = telephony->inband_ringtone;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &value);
+
+	return TRUE;
+}
+
+static const GDBusMethodTable telephony_methods[] = {
+	{ GDBUS_ASYNC_METHOD("Dial", GDBUS_ARGS({"uri", "s"}), NULL,
+						dial) },
+	{ GDBUS_ASYNC_METHOD("SwapCalls", NULL, NULL, swap_calls) },
+	{ GDBUS_ASYNC_METHOD("ReleaseAndAnswer", NULL, NULL,
+						release_and_answer) },
+	{ GDBUS_ASYNC_METHOD("ReleaseAndSwap", NULL, NULL,
+						release_and_swap) },
+	{ GDBUS_ASYNC_METHOD("HoldAndAnswer", NULL, NULL,
+						hold_and_answer) },
+	{ GDBUS_ASYNC_METHOD("HangupAll", NULL, NULL, hangup_all) },
+	{ GDBUS_ASYNC_METHOD("CreateMultiparty", NULL,
+						GDBUS_ARGS({ "calls", "ao" }),
+						create_multiparty) },
+	{ GDBUS_ASYNC_METHOD("SendTones", GDBUS_ARGS({"number", "s"}), NULL,
+						send_tones) },
+	{ }
+};
+
+static const GDBusPropertyTable telephony_properties[] = {
+	{ "UUID", "s", property_get_uuid },
+	{ "SupportedURISchemes", "as", property_get_uri_schemes },
+	{ "State", "s", property_get_state },
+	{ "Service", "b", property_get_service },
+	{ "Signal", "y", property_get_signal },
+	{ "Roaming", "b", property_get_roaming },
+	{ "BattChg", "y", property_get_battchg },
+	{ "OperatorName", "s", property_get_operator_name, NULL,
+			property_operator_name_exists },
+	{ "InbandRingtone", "b", property_get_inband_ringtone },
+	{ }
+};
+
+static void path_unregister(void *data)
+{
+	struct telephony *telephony = data;
+
+	DBG("Unregistered interface %s on path %s",  TELEPHONY_INTERFACE,
+						telephony->path);
+}
+
+int telephony_register_interface(struct telephony *telephony)
+{
+	if (telephony->cbs == NULL)
+		return -EINVAL;
+
+	if (!g_dbus_register_interface(btd_get_dbus_connection(),
+			telephony->path,
+			TELEPHONY_INTERFACE,
+			telephony_methods, NULL,
+			telephony_properties, telephony,
+			path_unregister)) {
+		return -EINVAL;
+	}
+
+	DBG("Registered interface %s on path %s", TELEPHONY_INTERFACE,
+						telephony->path);
+
+	return 0;
+}
+
+void telephony_unregister_interface(struct telephony *telephony)
+{
+	g_dbus_unregister_interface(btd_get_dbus_connection(), telephony->path,
+					TELEPHONY_INTERFACE);
+}
+
+struct btd_service *telephony_get_service(struct telephony *telephony)
+{
+	return telephony->service;
+}
+
+struct btd_device *telephony_get_device(struct telephony *telephony)
+{
+	return telephony->device;
+}
+
+const char *telephony_get_path(struct telephony *telephony)
+{
+	return telephony->path;
+}
+
+bdaddr_t telephony_get_src(struct telephony *telephony)
+{
+	return telephony->src;
+}
+
+bdaddr_t telephony_get_dst(struct telephony *telephony)
+{
+	return telephony->dst;
+}
+
+void *telephony_get_profile_data(struct telephony *telephony)
+{
+	return telephony->profile_data;
+}
+
+void telephony_add_uri_scheme(struct telephony *telephony, const char *scheme)
+{
+	telephony->uri_schemes = g_slist_append(telephony->uri_schemes,
+						g_strdup(scheme));
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+					telephony->path, TELEPHONY_INTERFACE,
+					"SupportedURISchemes");
+}
+
+void telephony_remove_uri_scheme(struct telephony *telephony,
+				const char *scheme)
+{
+	GSList *l;
+
+	l = g_slist_find_custom(telephony->uri_schemes, scheme,
+				(GCompareFunc)strcasecmp);
+	if (!l)
+		return;
+
+	telephony->uri_schemes = g_slist_delete_link(telephony->uri_schemes,
+							l);
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+					telephony->path, TELEPHONY_INTERFACE,
+					"SupportedURISchemes");
+}
+
+void telephony_set_state(struct telephony *telephony,
+				enum connection_state state)
+{
+	char address[18];
+
+	if (telephony->state == state)
+		return;
+
+	ba2str(&telephony->dst, address);
+	DBG("device %s state %s -> %s", address,
+				state_to_string(telephony->state),
+				state_to_string(state));
+
+	telephony->state = state;
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+					telephony->path, TELEPHONY_INTERFACE,
+					"State");
+}
+
+enum connection_state telephony_get_state(struct telephony *telephony)
+{
+	return telephony->state;
+}
+
+void telephony_set_network_service(struct telephony *telephony, bool service)
+{
+	char address[18];
+
+	if (telephony->network_service == service)
+		return;
+
+	ba2str(&telephony->dst, address);
+	DBG("device %s network service %u -> %u", address,
+					telephony->network_service,
+					service);
+
+	telephony->network_service = service;
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+			telephony->path, TELEPHONY_INTERFACE,
+			"Service");
+}
+
+bool telephony_get_network_service(struct telephony *telephony)
+{
+	return telephony->network_service;
+}
+
+void telephony_set_signal(struct telephony *telephony, uint8_t signal)
+{
+	char address[18];
+
+	if (telephony->signal == signal)
+		return;
+
+	ba2str(&telephony->dst, address);
+	DBG("device %s signal %u -> %u", address, telephony->signal, signal);
+
+	telephony->signal = signal;
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+			telephony->path, TELEPHONY_INTERFACE,
+			"Signal");
+}
+
+uint8_t telephony_get_signal(struct telephony *telephony)
+{
+	return telephony->signal;
+}
+
+void telephony_set_roaming(struct telephony *telephony, bool roaming)
+{
+	char address[18];
+
+	if (telephony->roaming == roaming)
+		return;
+
+	ba2str(&telephony->dst, address);
+	DBG("device %s roaming %u -> %u", address,
+					telephony->roaming,
+					roaming);
+
+	telephony->roaming = roaming;
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+			telephony->path, TELEPHONY_INTERFACE,
+			"Roaming");
+}
+
+bool telephony_get_roaming(struct telephony *telephony)
+{
+	return telephony->roaming;
+}
+
+void telephony_set_battchg(struct telephony *telephony, uint8_t battchg)
+{
+	char address[18];
+
+	if (telephony->battchg == battchg)
+		return;
+
+	ba2str(&telephony->dst, address);
+	DBG("device %s battchg %u -> %u", address, telephony->battchg, battchg);
+
+	telephony->battchg = battchg;
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+			telephony->path, TELEPHONY_INTERFACE,
+			"BattChg");
+}
+
+uint8_t telephony_get_battchg(struct telephony *telephony)
+{
+	return telephony->battchg;
+}
+
+void telephony_set_operator_name(struct telephony *telephony,
+					const char *name)
+{
+	char address[18];
+
+	if (telephony->operator_name &&
+			g_str_equal(telephony->operator_name, name))
+		return;
+
+	ba2str(&telephony->dst, address);
+	DBG("device %s operator name %s -> %s", address,
+			telephony->operator_name, name);
+
+	if (telephony->operator_name)
+		g_free(telephony->operator_name);
+	telephony->operator_name = g_strdup(name);
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+			telephony->path, TELEPHONY_INTERFACE,
+			"OperatorName");
+}
+
+const char *telephony_get_operator_name(struct telephony *telephony)
+{
+	return telephony->operator_name;
+}
+
+void telephony_set_inband_ringtone(struct telephony *telephony, bool enabled)
+{
+	char address[18];
+
+	if (telephony->inband_ringtone == enabled)
+		return;
+
+	ba2str(&telephony->dst, address);
+	DBG("device %s inband ringtone %u -> %u", address,
+					telephony->inband_ringtone,
+					enabled);
+
+	telephony->inband_ringtone = enabled;
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+			telephony->path, TELEPHONY_INTERFACE,
+			"InbandRingtone");
+}
+
+bool telephony_get_inband_ringtone(struct telephony *telephony)
+{
+	return telephony->inband_ringtone;
+}
+
+struct call *telephony_new_call(struct telephony *telephony,
+				uint8_t idx,
+				enum call_state state,
+				void *user_data)
+{
+	struct call *call;
+
+	call = g_new0(struct call, 1);
+	call->device = telephony;
+	call->state = state;
+	call->idx = idx;
+	call->path = g_strdup_printf("%s/call%u", telephony->path, call->idx);
+
+	return call;
+}
+
+void telephony_free_call(struct call *call)
+{
+	if (call->pending_msg)
+		dbus_message_unref(call->pending_msg);
+
+	g_free(call->name);
+	g_free(call->incoming_line);
+	g_free(call->line_id);
+	g_free(call->path);
+	g_free(call);
+}
+
+static DBusMessage *call_answer(DBusConnection *conn, DBusMessage *msg,
+	void *call_data)
+{
+	struct call *call = call_data;
+	struct telephony *telephony = call->device;
+
+	return telephony->cbs->call_answer(conn, msg, call_data);
+}
+
+static DBusMessage *call_hangup(DBusConnection *conn, DBusMessage *msg,
+	void *call_data)
+{
+	struct call *call = call_data;
+	struct telephony *telephony = call->device;
+
+	return telephony->cbs->call_hangup(conn, msg, call_data);
+}
+
+static gboolean call_line_id_exists(const GDBusPropertyTable *property,
+	void *data)
+{
+	struct call *call = data;
+
+	return call->line_id != NULL;
+}
+
+static gboolean call_property_get_line_id(
+	const GDBusPropertyTable *property,
+	DBusMessageIter *iter, void *data)
+{
+	struct call *call = data;
+
+	if (call->line_id == NULL)
+		return FALSE;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &call->line_id);
+
+	return TRUE;
+}
+
+static gboolean call_incoming_line_exists(const GDBusPropertyTable *property,
+	void *data)
+{
+	struct call *call = data;
+
+	return call->incoming_line != NULL;
+}
+
+static gboolean call_property_get_incoming_line(
+	const GDBusPropertyTable *property,
+	DBusMessageIter *iter, void *data)
+{
+	struct call *call = data;
+
+	if (call->incoming_line == NULL)
+		return FALSE;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
+		&call->incoming_line);
+
+	return TRUE;
+}
+
+static gboolean call_name_exists(const GDBusPropertyTable *property,
+	void *data)
+{
+	struct call *call = data;
+
+	return call->name != NULL;
+}
+
+static gboolean call_property_get_name(const GDBusPropertyTable *property,
+	DBusMessageIter *iter, void *data)
+{
+	struct call *call = data;
+
+	if (call->name == NULL)
+		return FALSE;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &call->name);
+
+	return TRUE;
+}
+
+static gboolean call_property_get_multiparty(
+	const GDBusPropertyTable *property,
+	DBusMessageIter *iter, void *data)
+{
+	struct call *call = data;
+	dbus_bool_t value;
+
+	value = call->multiparty;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &value);
+
+	return TRUE;
+}
+
+static gboolean call_property_get_state(const GDBusPropertyTable *property,
+	DBusMessageIter *iter, void *data)
+{
+	struct call *call = data;
+	const char *string;
+
+	string = call_state_to_string(call->state);
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &string);
+
+	return TRUE;
+}
+
+static const GDBusMethodTable telephony_call_methods[] = {
+	{ GDBUS_ASYNC_METHOD("Answer", NULL, NULL, call_answer) },
+	{ GDBUS_ASYNC_METHOD("Hangup", NULL, NULL, call_hangup) },
+	{ }
+};
+
+static const GDBusPropertyTable telephony_call_properties[] = {
+	{ "LineIdentification", "s", call_property_get_line_id, NULL,
+			call_line_id_exists },
+	{ "IncomingLine", "s", call_property_get_incoming_line, NULL,
+			call_incoming_line_exists },
+	{ "Name", "s", call_property_get_name, NULL, call_name_exists },
+	{ "Multiparty", "b", call_property_get_multiparty },
+	{ "State", "s", call_property_get_state },
+	{ }
+};
+
+static void call_path_unregister(void *user_data)
+{
+	struct call *call = user_data;
+
+	DBG("Unregistered interface %s on path %s",  TELEPHONY_CALL_INTERFACE,
+			call->path);
+
+	telephony_free_call(call);
+}
+
+int telephony_call_register_interface(struct call *call)
+{
+	if (call->device->cbs == NULL)
+		return -EINVAL;
+
+	if (!g_dbus_register_interface(btd_get_dbus_connection(),
+			call->path,
+			TELEPHONY_CALL_INTERFACE,
+			telephony_call_methods, NULL,
+			telephony_call_properties, call,
+			call_path_unregister)) {
+		return -EINVAL;
+	}
+
+	DBG("Registered interface %s on path %s", TELEPHONY_CALL_INTERFACE,
+						call->path);
+
+	return 0;
+}
+
+void telephony_call_unregister_interface(struct call *call)
+{
+	g_dbus_unregister_interface(btd_get_dbus_connection(),
+					call->path,
+					TELEPHONY_CALL_INTERFACE);
+}
+
+void telephony_call_set_state(struct call *call, enum call_state state)
+{
+	if (call->state == state)
+		return;
+
+	DBG("%s state %s -> %s", call->path, call_state_to_string(call->state),
+					call_state_to_string(state));
+
+	call->state = state;
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+			call->path, TELEPHONY_CALL_INTERFACE,
+			"State");
+}
+
+void telephony_call_set_line_id(struct call *call, const char *line_id)
+{
+	if (call->line_id && g_str_equal(call->line_id, line_id))
+		return;
+
+	g_free(call->line_id);
+	call->line_id = g_strdup(line_id);
+
+	DBG("%s line_id: %s", call->path, call->line_id);
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+			call->path, TELEPHONY_CALL_INTERFACE,
+			"LineIdentification");
+}
profiles/audio/telephony.h new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 3/5 audio/hfp-hf: Add skeleton for HFP profile

In reply to Frédéric Danis

This starts the Telephony interface for HFP HF, allowing to connect to the remote HFP AG device.
---
v1->v2:
- Fix 'make distcheck' by adding missing profiles/audio/telephony.h to builtin_sources
- Improve commit message

 Makefile.plugins        |   5 +
 configure.ac            |   7 ++
 profiles/audio/hfp-hf.c | 220 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 232 insertions(+)
 create mode 100644 profiles/audio/hfp-hf.c
Makefile.plugins +5 -0
index 3572ee845..3a95b5fb5 100644
@@ -160,3 +160,8 @@ if ASHA
 builtin_modules += asha
 builtin_sources += profiles/audio/asha.h profiles/audio/asha.c
 endif
+
+if HFP
+builtin_modules += hfp
+builtin_sources += profiles/audio/telephony.h profiles/audio/telephony.c profiles/audio/hfp-hf.c
+endif
configure.ac +7 -0
index 16b81aca3..b6f6789be 100644
@@ -248,6 +248,13 @@ if test "${enable_asha}" != "no"; then
 	AC_DEFINE(HAVE_ASHA, 1, [Define to 1 if you have ASHA support.])
 fi
 
+AC_ARG_ENABLE(hfp, AS_HELP_STRING([--disable-hfp],
+		[disable HFP support]), [enable_hfp=${enableval}])
+AM_CONDITIONAL(HFP, test "${enable_hfp}" != "no")
+if test "${enable_hfp}" != "no"; then
+	AC_DEFINE(HAVE_HFP, 1, [Define to 1 if you have HFP support.])
+fi
+
 AC_ARG_ENABLE(tools, AS_HELP_STRING([--disable-tools],
 		[disable Bluetooth tools]), [enable_tools=${enableval}])
 AM_CONDITIONAL(TOOLS, test "${enable_tools}" != "no")
profiles/audio/hfp-hf.c new file +220 -0

220 lines not on this page · raw message

Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 4/5 audio/hfp-hf: Add HFP SLC connection and event support

In reply to Frédéric Danis

This implements the HFP HF SLC connection and events support for the Telephony DBus interface.
---
v1->v2: Improve commit message

 profiles/audio/hfp-hf.c | 96 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)
profiles/audio/hfp-hf.c +96 -0
index 5375168cf..d25cda389 100644
@@ -40,6 +40,7 @@
 #include "src/plugin.h"
 #include "src/profile.h"
 #include "src/service.h"
+#include "src/shared/hfp.h"
 
 #include "telephony.h"
 
@@ -50,12 +51,25 @@ struct hfp_device {
 	struct telephony	*telephony;
 	uint16_t		version;
 	GIOChannel		*io;
+	struct hfp_hf		*hf;
 };
 
+static void hfp_hf_debug(const char *str, void *user_data)
+{
+	DBG_IDX(0xffff, "%s", str);
+}
+
 static void device_destroy(struct hfp_device *dev)
 {
 	DBG("%s", telephony_get_path(dev->telephony));
 
+	telephony_set_state(dev->telephony, DISCONNECTING);
+
+	if (dev->hf) {
+		hfp_hf_unref(dev->hf);
+		dev->hf = NULL;
+	}
+
 	if (dev->io) {
 		g_io_channel_unref(dev->io);
 		dev->io = NULL;
@@ -64,6 +78,62 @@ static void device_destroy(struct hfp_device *dev)
 	telephony_unregister_interface(dev->telephony);
 }
 
+static void hfp_hf_update_indicator(enum hfp_indicator indicator, uint32_t val,
+							void *user_data)
+{
+	struct hfp_device *dev = user_data;
+
+	switch (indicator) {
+	case HFP_INDICATOR_SERVICE:
+		telephony_set_network_service(dev->telephony, val);
+		break;
+	case HFP_INDICATOR_CALL:
+		break;
+	case HFP_INDICATOR_CALLSETUP:
+		break;
+	case HFP_INDICATOR_CALLHELD:
+		break;
+	case HFP_INDICATOR_SIGNAL:
+		telephony_set_signal(dev->telephony, val);
+		break;
+	case HFP_INDICATOR_ROAM:
+		telephony_set_roaming(dev->telephony, val);
+		break;
+	case HFP_INDICATOR_BATTCHG:
+		telephony_set_battchg(dev->telephony, val);
+		break;
+	case HFP_INDICATOR_LAST:
+	default:
+		DBG("Unknown signal indicator: %u", indicator);
+	}
+}
+
+static void hfp_hf_session_ready_cb(enum hfp_result res, enum hfp_error cme_err,
+							void *user_data)
+{
+	struct hfp_device *dev = user_data;
+
+	if (res != HFP_RESULT_OK) {
+		error("Session setup error: %d, dropping connection", res);
+		hfp_hf_disconnect(dev->hf);
+		return;
+	}
+
+	telephony_set_state(dev->telephony, CONNECTED);
+}
+
+static struct hfp_hf_callbacks hf_session_callbacks = {
+	.session_ready = hfp_hf_session_ready_cb,
+	.update_indicator = hfp_hf_update_indicator,
+};
+
+static void hfp_disconnect_watch(void *user_data)
+{
+	DBG("");
+
+	device_destroy(user_data);
+}
+
 static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 {
 	struct hfp_device *dev = user_data;
@@ -76,8 +146,27 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 		goto failed;
 	}
 
+	dev->hf = hfp_hf_new(g_io_channel_unix_get_fd(chan));
+	if (!dev->hf) {
+		error("Could not create hfp io");
+		goto failed;
+	}
+
+	hfp_hf_set_debug(dev->hf, hfp_hf_debug, NULL, NULL);
 	g_io_channel_set_close_on_unref(chan, FALSE);
 
+	hfp_hf_set_close_on_unref(dev->hf, true);
+	hfp_hf_set_disconnect_handler(dev->hf, hfp_disconnect_watch,
+					dev, NULL);
+	hfp_hf_session_register(dev->hf, &hf_session_callbacks, dev);
+
+	if (!hfp_hf_session(dev->hf)) {
+		error("Could not start SLC creation");
+		hfp_hf_disconnect(dev->hf);
+		goto failed;
+	}
+
+	telephony_set_state(dev->telephony, SESSION_CONNECTING);
 	btd_service_connecting_complete(service, 0);
 
 	return;
@@ -149,8 +238,15 @@ static int hfp_connect(struct btd_service *service)
 
 static int hfp_disconnect(struct btd_service *service)
 {
+	struct hfp_device *dev;
+
 	DBG("");
 
+	dev = btd_service_get_user_data(service);
+
+	if (dev->hf)
+		hfp_hf_disconnect(dev->hf);
+
 	btd_service_disconnecting_complete(service, 0);
 
 	return 0;
Signature · 1 line
2.43.0
#4 lore raw

PATCH v2 5/5 client/telephony: Add new submenu

In reply to Frédéric Danis

This add a new submenu to bluetoothctl to be able to manage telephony related "headset" profiles.
It currently allows to control calls from an HFP phone, i.e. starts a call, hangup a call, accepting or rejecting an incoming call.

Audio part is not yet supported.
---
v1->v2: Improve commit message

 Makefile.tools                    |   9 +-
 client/bluetoothctl-telephony.rst |  95 ++++++
 client/main.c                     |   3 +
 client/telephony.c                | 528 ++++++++++++++++++++++++++++++
 client/telephony.h                |  12 +
 5 files changed, 644 insertions(+), 3 deletions(-)
 create mode 100644 client/bluetoothctl-telephony.rst
 create mode 100644 client/telephony.c
 create mode 100644 client/telephony.h
Makefile.tools +6 -3
index 561b03d0b..cc8aab55c 100644
@@ -15,7 +15,8 @@ client_bluetoothctl_SOURCES = client/main.c \
 					client/player.h client/player.c \
 					client/mgmt.h client/mgmt.c \
 					client/assistant.h client/assistant.c \
-					client/hci.h client/hci.c
+					client/hci.h client/hci.c \
+					client/telephony.h client/telephony.c
 client_bluetoothctl_LDADD = lib/libbluetooth-internal.la \
 			gdbus/libgdbus-internal.la src/libshared-glib.la \
 			$(GLIB_LIBS) $(DBUS_LIBS) -lreadline
@@ -361,7 +362,8 @@ man_MANS += tools/rctest.1 tools/l2ping.1 tools/btattach.1 tools/isotest.1 \
 		client/bluetoothctl-advertise.1 client/bluetoothctl-endpoint.1 \
 		client/bluetoothctl-gatt.1 client/bluetoothctl-player.1 \
 		client/bluetoothctl-scan.1 client/bluetoothctl-transport.1 \
-		client/bluetoothctl-assistant.1 client/bluetoothctl-hci.1
+		client/bluetoothctl-assistant.1 client/bluetoothctl-hci.1 \
+		client/bluetoothctl-telephony.1
 
 endif
 
@@ -494,7 +496,8 @@ manual_pages += tools/hciattach.1 tools/hciconfig.1 \
 			client/bluetoothctl-scan.1 \
 			client/bluetoothctl-transport.1 \
 			client/bluetoothctl-assistant.1 \
-			client/bluetoothctl-hci.1
+			client/bluetoothctl-hci.1 \
+			client/bluetoothctl-telephony.1
 
 if HID2HCI
 udevdir = $(UDEV_DIR)
client/bluetoothctl-telephony.rst new file +95 -0

95 lines not on this page · raw message

client/main.c +3 -0
index 2203a2a2b..cb016a579 100644
@@ -38,6 +38,7 @@
 #include "mgmt.h"
 #include "assistant.h"
 #include "hci.h"
+#include "telephony.h"
 
 /* String display constants */
 #define COLORED_NEW	COLOR_GREEN "NEW" COLOR_OFF
@@ -3922,6 +3923,7 @@ int main(int argc, char *argv[])
 	mgmt_add_submenu();
 	assistant_add_submenu();
 	hci_add_submenu();
+	telephony_add_submenu();
 	bt_shell_set_prompt(PROMPT_OFF, NULL);
 
 	bt_shell_handle_non_interactive_help();
@@ -3962,6 +3964,7 @@ int main(int argc, char *argv[])
 	mgmt_remove_submenu();
 	assistant_remove_submenu();
 	hci_remove_submenu();
+	telephony_remove_submenu();
 
 	g_dbus_client_unref(client);
 
client/telephony.c new file +528 -0

528 lines not on this page · raw message

client/telephony.h new file +12 -0
new file mode 100644
index 000000000..a869da240
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright © 2025 Collabora Ltd.
+ *
+ *
+ */
+
+void telephony_add_submenu(void);
+void telephony_remove_submenu(void);
Signature · 1 line
2.43.0
#5 lore raw
In reply to Frédéric Danis

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1032412

---Test result---

Test Summary:

CheckPatch                    PENDING   0.33 seconds
GitLint                       PENDING   0.36 seconds
BuildEll                      PASS      20.34 seconds
BluezMake                     PASS      654.40 seconds
MakeCheck                     PASS      22.25 seconds
MakeDistcheck                 PASS      245.83 seconds
CheckValgrind                 PASS      306.49 seconds
CheckSmatch                   PASS      356.69 seconds
bluezmakeextell               PASS      186.03 seconds
IncrementalBuild              PENDING   0.43 seconds
ScanBuild                     PASS      1055.47 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:

---
Regards,
Linux Bluetooth

#6 lore raw
In reply to Frédéric Danis
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 9 lines · On Thu, 11 Dec 2025 19:34:25 +0100 you wrote:

These are interfaces are meant to be generic to the telephony related "headset" profiles like HSP HS, HFP HF, and CCP.

---
 Makefile.am                 |   4 +
 doc/org.bluez.Call.rst      | 140 ++++++++++++++++++++++
 doc/org.bluez.Telephony.rst | 225 ++++++++++++++++++++++++++++++++++++
 3 files changed, 369 insertions(+)
 create mode 100644 doc/org.bluez.Call.rst
 create mode 100644 doc/org.bluez.Telephony.rst

Here is the summary with links:
- [BlueZ,v2,1/5] doc: Add new telephony related profiles interfaces

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=270b899e9630
  - [BlueZ,v2,2/5] audio/telephony: Add shared interfaces implementation
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7204618e59ad
  - [BlueZ,v2,3/5] audio/hfp-hf: Add skeleton for HFP profile
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=cfc372d4f21b
  - [BlueZ,v2,4/5] audio/hfp-hf: Add HFP SLC connection and event support
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5c7bb3096021
  - [BlueZ,v2,5/5] client/telephony: Add new submenu
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=b3677421feee

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html