From c3e4c50866d4e0c3d21e6b859d52d78d9b95cf27 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Fri, 17 Jan 2025 13:49:40 +0100 Subject: [PATCH] samples: Bluetooth: TMAP periph: Handle empty URI string The supported URI list may be empty which the sample did not properly support. Signed-off-by: Emil Gydesen --- samples/bluetooth/tmap_peripheral/src/ccp_call_ctrl.c | 7 +++++++ samples/bluetooth/tmap_peripheral/src/main.c | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/samples/bluetooth/tmap_peripheral/src/ccp_call_ctrl.c b/samples/bluetooth/tmap_peripheral/src/ccp_call_ctrl.c index 97d9c64e919..bf840793a2d 100644 --- a/samples/bluetooth/tmap_peripheral/src/ccp_call_ctrl.c +++ b/samples/bluetooth/tmap_peripheral/src/ccp_call_ctrl.c @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include @@ -139,6 +140,12 @@ int ccp_originate_call(void) int err; char uri[CONFIG_BT_TBS_MAX_URI_LENGTH]; + /* If remote_uri is empty then we cannot place a call */ + if (remote_uri[0] == '\0') { + printk("Remote does not support any URI schemes, cannot place call\n"); + return -ENOENT; + } + strcpy(uri, remote_uri); strcat(uri, URI_SEPARATOR); strcat(uri, CALLER_ID); diff --git a/samples/bluetooth/tmap_peripheral/src/main.c b/samples/bluetooth/tmap_peripheral/src/main.c index 2a7ecc61759..24351738f72 100644 --- a/samples/bluetooth/tmap_peripheral/src/main.c +++ b/samples/bluetooth/tmap_peripheral/src/main.c @@ -289,9 +289,10 @@ int main(void) err = ccp_originate_call(); if (err != 0) { printk("Error sending call originate command!\n"); + } else { + /* Start timer to send terminate call command */ + k_work_schedule(&call_terminate_set_work, K_MSEC(2000)); } - /* Start timer to send terminate call command */ - k_work_schedule(&call_terminate_set_work, K_MSEC(2000)); } if (peer_is_ums) {