Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 949801474CC for ; Wed, 1 Oct 2025 06:54:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759301679; cv=none; b=ewbcqBxQpkhoEzS+G6PQ6MFeRDLSHLxHPfhc3i4jfgphU57WxPz3oBNDYa8HrDu+vPua92P4Gukhrkx2Wd8G4dpA3fbUc0jePDSPCMgwbDE8Rh/EuiSMgJ4Jfp7Z4NuGMKn6sa/+fapJhtlriZcBnnzy28rLYVC32OQxzCNtfuY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759301679; c=relaxed/simple; bh=eSedF+3HbLC/IMX3GTnfpeMHk6XuK9fj/lRYKTq07V0=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Type; b=O8OHjk+GP6mHETp0s0/8qTxI8LJFSpDyi3+PPHFKNNb3pclTZj4zY6GfwbhOStCsJFBtJXokMG9PD3jTwVAm/1fK2eAxNP/ovOQApOo5h1ZxAj1YOXMsDAgSj845pAB9gv9RevXiTD3dtGTjBlBxQgtNd+py0NOdXsSnF4lJE0M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=eJv+YlWU; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="eJv+YlWU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1759301675; bh=eSedF+3HbLC/IMX3GTnfpeMHk6XuK9fj/lRYKTq07V0=; h=From:To:Subject:Date:From; b=eJv+YlWUXdcRpU70CdaX7sOgQrndTY2sHLGERPApW4v0vVrOlhtczn1o6DlQ94njK MWbPN5ttpQ27Wvys+oaaaeu1yZ4Rih6qzDSNYGKItmOr5MTr+L6js56qfyNq4wUtbp dHMEl5OUYxio9Gkt9yaAt7eiyWSr1W8QDBzkj9cQ7uIpHWss/NdwGBY0NOiPFXDy5U wkLiQZI5uULsIRPylsUtIyJIJk7FsMtDlM4mt0vOcnfw4Kjssfdw5VsvWGeK1qCRXb 75kCQy61EZNg49hlHMu3daFqWmx7I1PF1LChnY4cdg/bGDOi1rhxARjl2ARva4BCNH 9GtcmZpqafyGQ== Received: from fdanis-ThinkPad-X1.. (2a02-8428-af44-1001-2e77-3033-4926-5452.rev.sfr.net [IPv6:2a02:8428:af44:1001:2e77:3033:4926:5452]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fdanis) by bali.collaboradmins.com (Postfix) with ESMTPSA id 77F9917E005F for ; Wed, 1 Oct 2025 08:54:35 +0200 (CEST) From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/6] shared/hfp: Add dial support Date: Wed, 1 Oct 2025 08:54:24 +0200 Message-ID: <20251001065429.268068-1-frederic.danis@collabora.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit If no number, NULL or empry string, is passed to hfp_hf_dial() this will try to call the last dialed phone number using AT+BLDN. If the phone number starts with '>' and is followed by a number nnn…, up to 10 digits, it will call the phone number in memory entry nnn…. Else it will performed a voice call to the number provided. --- src/shared/hfp.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++-- src/shared/hfp.h | 3 +++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/shared/hfp.c b/src/shared/hfp.c index 133bff248..c7a04b536 100644 --- a/src/shared/hfp.c +++ b/src/shared/hfp.c @@ -102,6 +102,7 @@ struct hfp_hf { uint8_t battchg; struct queue *calls; + char *dialing_number; }; struct cmd_handler { @@ -1388,6 +1389,11 @@ void hfp_hf_unref(struct hfp_hf *hfp) queue_destroy(hfp->calls, remove_call_cb); hfp->calls = NULL; + if (hfp->dialing_number) { + free(hfp->dialing_number); + hfp->dialing_number = NULL; + } + if (!hfp->in_disconnect) { free(hfp); return; @@ -1622,7 +1628,8 @@ static struct hf_call *call_new(struct hfp_hf *hfp, unsigned int id, call = new0(struct hf_call, 1); call->id = id; call->status = status; - call->line_id = number; + if (number) + call->line_id = strdup(number); call->hfp = hfp; queue_push_tail(hfp->calls, call); @@ -1807,7 +1814,11 @@ static void ciev_callsetup_cb(uint8_t val, void *user_data) DBG(hfp, "hf: No new call index available"); return; } - call_new(hfp, id, status, NULL); + call_new(hfp, id, status, hfp->dialing_number); + if (hfp->dialing_number) { + free(hfp->dialing_number); + hfp->dialing_number = NULL; + } break; } } @@ -2421,6 +2432,50 @@ const char *hfp_hf_call_get_number(struct hfp_hf *hfp, uint id) return call->line_id; } +bool hfp_hf_dial(struct hfp_hf *hfp, const char *number, + hfp_response_func_t resp_cb, + void *user_data) +{ + const char *c; + int count = 0; + + DBG(hfp, ""); + + if (!hfp) + return false; + + if (number == NULL || strlen(number) == 0) + return hfp_hf_send_command(hfp, resp_cb, user_data, + "AT+BLDN"); + + if (number[0] == '>') { + for (c = number + 1; *c != '\0'; c++) { + if (!(*c >= '0' && *c <= '9')) + return false; + count++; + } + if (count < 1 || count > 10) + return false; + } else { + for (c = number; *c != '\0'; c++) { + if (!(*c >= '0' && *c <= '9') && + !(*c >= 'A' && *c <= 'D') && + *c != '#' && *c != '*' && + *c != '+' && *c != ',') + return false; + count++; + } + if (count < 1 || count > 80) + return false; + } + + if (hfp->dialing_number) + free(hfp->dialing_number); + hfp->dialing_number = strdup(number); + + return hfp_hf_send_command(hfp, resp_cb, user_data, "ATD%s;", number); +} + bool hfp_hf_call_answer(struct hfp_hf *hfp, uint id, hfp_response_func_t resp_cb, void *user_data) diff --git a/src/shared/hfp.h b/src/shared/hfp.h index 4b171ad88..21214eee4 100644 --- a/src/shared/hfp.h +++ b/src/shared/hfp.h @@ -237,6 +237,9 @@ bool hfp_hf_session(struct hfp_hf *hfp); const char *hfp_hf_call_get_number(struct hfp_hf *hfp, uint id); +bool hfp_hf_dial(struct hfp_hf *hfp, const char *number, + hfp_response_func_t resp_cb, + void *user_data); bool hfp_hf_call_answer(struct hfp_hf *hfp, uint id, hfp_response_func_t resp_cb, void *user_data); -- 2.43.0