2024-03-07 15:59:14

by Iulia Tanasescu

[permalink] [raw]
Subject: [PATCH BlueZ 0/4] client: Add scripts to start broadcast source/sink

This patch adds some shell fixes and introduces bluetoothctl scripts
for starting a broadcast source/sink.

Iulia Tanasescu (4):
client/gatt: Quit shell after user input has been processed
client/adv_monitor: Remove shell quit from adv_monitor_register_app
shared/shell: Add fixes for the init script scenario
client: Add scripts to start broadcast source/sink

client/adv_monitor.c | 8 ++++----
client/gatt.c | 9 +++++----
client/scripts/broadcast-sink.bt | 7 +++++++
client/scripts/broadcast-source.bt | 11 +++++++++++
src/shared/shell.c | 17 ++++++++++++++++-
5 files changed, 43 insertions(+), 9 deletions(-)
create mode 100644 client/scripts/broadcast-sink.bt
create mode 100644 client/scripts/broadcast-source.bt

--
2.39.2



2024-03-07 15:59:23

by Iulia Tanasescu

[permalink] [raw]
Subject: [PATCH BlueZ 3/4] shared/shell: Add fixes for the init script scenario

This adds some fixes to the scenario when the shell is run with
the -i/--init-script command line option.

In bt_shell_dequeue_exec, if a prompt was released with the current
line, all other prompts, if any left, should also try to be released.
If no other prompts are available, the next line should be executed
on bt_shell_noninteractive_quit.

In bt_shell_prompt_input, if data is already available in data.queue,
execution should continue and the prompt should be released with the
input.
---
src/shared/shell.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index 7bcfcff3e..0e4cbb7b1 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -638,7 +638,15 @@ static void bt_shell_dequeue_exec(void)
bt_shell_printf("%s\n", data.line);

if (!bt_shell_release_prompt(data.line)) {
- bt_shell_dequeue_exec();
+ /* If a prompt was released with this line,
+ * try to release all the other prompts,
+ * if any are left. Otherwise, the next
+ * line will be executed on
+ * bt_shell_noninteractive_quit.
+ */
+ if (data.saved_prompt)
+ bt_shell_dequeue_exec();
+
return;
}

@@ -693,6 +701,13 @@ void bt_shell_prompt_input(const char *label, const char *msg,
prompt_input(str, func, user_data);

free(str);
+
+ if (data.line && !queue_isempty(data.queue))
+ /* If a prompt was set to receive input and
+ * data is already available, try to execute
+ * the line and release the prompt.
+ */
+ bt_shell_dequeue_exec();
}

static void prompt_free(void *data)
--
2.39.2


2024-03-07 15:59:26

by Iulia Tanasescu

[permalink] [raw]
Subject: [PATCH BlueZ 4/4] client: Add scripts to start broadcast source/sink

This adds sample bluetoothctl scripts for the broadcast source/sink
scenarios.

The broadcast-source.bt script does the full setup: It registers a
broadcast source endpoint, with supported locations as FL/FR and
media context supported. It then configures the endpoint to create
a stereo media stream, for the BIG handle 1. The transport is also
acquired.

The broadcast-sink.bt script registers a broadacast sink endpoint,
supporting FL/FR locations and the media context. It also starts
scanning, and the user is responsible to detect sources and select
which endpoint to config.
---
client/scripts/broadcast-sink.bt | 7 +++++++
client/scripts/broadcast-source.bt | 11 +++++++++++
2 files changed, 18 insertions(+)
create mode 100644 client/scripts/broadcast-sink.bt
create mode 100644 client/scripts/broadcast-source.bt

diff --git a/client/scripts/broadcast-sink.bt b/client/scripts/broadcast-sink.bt
new file mode 100644
index 000000000..b912231b2
--- /dev/null
+++ b/client/scripts/broadcast-sink.bt
@@ -0,0 +1,7 @@
+power on
+endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06
+y
+a
+3
+4
+scan on
\ No newline at end of file
diff --git a/client/scripts/broadcast-source.bt b/client/scripts/broadcast-source.bt
new file mode 100644
index 000000000..6da9e23e2
--- /dev/null
+++ b/client/scripts/broadcast-source.bt
@@ -0,0 +1,11 @@
+power on
+endpoint.register 00001852-0000-1000-8000-00805f9b34fb 0x06
+y
+a
+3
+4
+endpoint.config /org/bluez/hci0/pac_bcast0 /local/endpoint/ep0 16_2_1
+1
+3
+0x03 0x02 0x04 0x00
+transport.acquire /org/bluez/hci0/pac_bcast0/fd0
\ No newline at end of file
--
2.39.2


2024-03-07 15:59:33

by Iulia Tanasescu

[permalink] [raw]
Subject: [PATCH BlueZ 1/4] client/gatt: Quit shell after user input has been processed

Inside gatt_register_service and gatt_register_chrc,
bt_shell_noninteractive_quit should be called after
the input was processed.
---
client/gatt.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/client/gatt.c b/client/gatt.c
index f03fc1526..84b7f3f49 100644
--- a/client/gatt.c
+++ b/client/gatt.c
@@ -4,6 +4,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2014 Intel Corporation. All rights reserved.
+ * Copyright 2024 NXP
*
*
*/
@@ -1685,6 +1686,8 @@ static void service_set_primary(const char *input, void *user_data)
g_dbus_unregister_interface(service->conn, service->path,
SERVICE_INTERFACE);
}
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}

static uint16_t parse_handle(const char *arg)
@@ -1737,8 +1740,6 @@ void gatt_register_service(DBusConnection *conn, GDBusProxy *proxy,

bt_shell_prompt_input(service->path, "Primary (yes/no):",
service_set_primary, service);
-
- return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}

static struct service *service_find(const char *pattern)
@@ -2761,6 +2762,8 @@ static void chrc_set_value(const char *input, void *user_data)
}

chrc->max_val_len = chrc->value_len;
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}

static gboolean attr_authorization_flag_exists(char **flags)
@@ -2817,8 +2820,6 @@ void gatt_register_chrc(DBusConnection *conn, GDBusProxy *proxy,
print_chrc(chrc, COLORED_NEW);

bt_shell_prompt_input(chrc->path, "Enter value:", chrc_set_value, chrc);
-
- return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}

static struct chrc *chrc_find(const char *pattern)
--
2.39.2


2024-03-07 15:59:36

by Iulia Tanasescu

[permalink] [raw]
Subject: [PATCH BlueZ 2/4] client/adv_monitor: Remove shell quit from adv_monitor_register_app

In adv_monitor, adv_monitor_register_app is called when an advertising
monitor manager proxy has been added, when a new adapter is added.

This commit removes bt_shell_noninteractive_quit from this function,
since it causes the shell to exit without a user command having
executed.
---
client/adv_monitor.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/client/adv_monitor.c b/client/adv_monitor.c
index 792379fc4..29e670960 100644
--- a/client/adv_monitor.c
+++ b/client/adv_monitor.c
@@ -4,6 +4,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2020 Google LLC
+ * Copyright 2024 NXP
*
*
*/
@@ -372,12 +373,11 @@ static void register_reply(DBusMessage *message, void *user_data)

if (!dbus_set_error_from_message(&error, message)) {
bt_shell_printf("AdvertisementMonitor path registered\n");
- return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+ return;
}

bt_shell_printf("Failed to register path: %s\n", error.name);
dbus_error_free(&error);
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
}

static void unregister_setup(DBusMessageIter *iter, void *user_data)
@@ -408,13 +408,13 @@ void adv_monitor_register_app(DBusConnection *conn)
{
if (manager.app_registered) {
bt_shell_printf("Advertisement Monitor already registered\n");
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ return;
} else if (manager.supported_types == NULL ||
!g_dbus_proxy_method_call(manager.proxy, "RegisterMonitor",
register_setup, register_reply,
NULL, NULL)) {
bt_shell_printf("Failed to register Advertisement Monitor\n");
- return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ return;
}
manager.app_registered = TRUE;
}
--
2.39.2


2024-03-07 18:56:11

by bluez.test.bot

[permalink] [raw]
Subject: RE: client: Add scripts to start broadcast source/sink

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=833470

---Test result---

Test Summary:
CheckPatch PASS 1.68 seconds
GitLint PASS 1.18 seconds
BuildEll PASS 23.93 seconds
BluezMake PASS 1643.40 seconds
MakeCheck PASS 12.94 seconds
MakeDistcheck PASS 173.15 seconds
CheckValgrind PASS 242.04 seconds
CheckSmatch WARNING 345.94 seconds
bluezmakeextell PASS 117.44 seconds
IncrementalBuild PASS 6043.82 seconds
ScanBuild WARNING 975.67 seconds

Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:
src/shared/shell.c:1243:13: warning: Access to field 'options' results in a dereference of a null pointer (loaded from variable 'opt')
if (c != opt->options[index - offset].val) {
^~~~~~~~~~~~
1 warning generated.



---
Regards,
Linux Bluetooth

2024-03-08 16:20:41

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ 0/4] client: Add scripts to start broadcast source/sink

Hello:

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

On Thu, 7 Mar 2024 17:58:46 +0200 you wrote:
> This patch adds some shell fixes and introduces bluetoothctl scripts
> for starting a broadcast source/sink.
>
> Iulia Tanasescu (4):
> client/gatt: Quit shell after user input has been processed
> client/adv_monitor: Remove shell quit from adv_monitor_register_app
> shared/shell: Add fixes for the init script scenario
> client: Add scripts to start broadcast source/sink
>
> [...]

Here is the summary with links:
- [BlueZ,1/4] client/gatt: Quit shell after user input has been processed
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=352e75263632
- [BlueZ,2/4] client/adv_monitor: Remove shell quit from adv_monitor_register_app
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=32e9d15a6094
- [BlueZ,3/4] shared/shell: Add fixes for the init script scenario
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=fcbea6f3658d
- [BlueZ,4/4] client: Add scripts to start broadcast source/sink
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=9e9f079e8952

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html