diff mbox series

[BlueZ,1/3] player: Add reconfiguration prompt for broadcast source

Message ID 20240308165232.53906-2-silviu.barbulescu@nxp.com
State New
Headers show
Series Broadcast source reconfiguration support | expand

Commit Message

Silviu Florian Barbulescu March 8, 2024, 4:52 p.m. UTC
endpoint.config /org/bluez/hci0/pac_bcast0 /local/endpoint/ep0 48_4_1
[/local/endpoint/ep0] This is a BIS Reconfiguration? (yes/no): y
The BIS index is assigned in the order of the configuration
starting with 1
[/local/endpoint/ep0] BIS Index (value): 1
[/local/endpoint/ep0] BIG (auto/value): 0
[/local/endpoint/ep0] Enter channel location (value/no): 2
[/local/endpoint/ep0] Enter Metadata (value/no): n

---
 client/player.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)

Comments

Luiz Augusto von Dentz March 8, 2024, 5:37 p.m. UTC | #1
Hi Silviu,

On Fri, Mar 8, 2024 at 11:52 AM Silviu Florian Barbulescu
<silviu.barbulescu@nxp.com> wrote:
>
> endpoint.config /org/bluez/hci0/pac_bcast0 /local/endpoint/ep0 48_4_1
> [/local/endpoint/ep0] This is a BIS Reconfiguration? (yes/no): y
> The BIS index is assigned in the order of the configuration
> starting with 1
> [/local/endpoint/ep0] BIS Index (value): 1
> [/local/endpoint/ep0] BIG (auto/value): 0
> [/local/endpoint/ep0] Enter channel location (value/no): 2
> [/local/endpoint/ep0] Enter Metadata (value/no): n
>
> ---
>  client/player.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 44 insertions(+), 2 deletions(-)
>
> diff --git a/client/player.c b/client/player.c
> index a40bf66e3..35143115a 100644
> --- a/client/player.c
> +++ b/client/player.c
> @@ -3809,6 +3809,48 @@ static void config_endpoint_iso_group(const char *input, void *user_data)
>         }
>  }
>
> +static void endpoint_set_reconfigure_cfg(const char *input, void *user_data)
> +{
> +       char *endptr = NULL;
> +       int value;
> +       struct endpoint_config *cfg = user_data;
> +
> +       value = strtol(input, &endptr, 0);
> +
> +       if (!endptr || *endptr != '\0' || value > UINT8_MAX) {
> +               bt_shell_printf("Invalid argument: %s\n", input);
> +               return bt_shell_noninteractive_quit(EXIT_FAILURE);
> +       }
> +
> +       cfg->ep->iso_stream = value;
> +
> +       bt_shell_prompt_input(cfg->ep->path,
> +               "BIG (auto/value):",
> +               config_endpoint_iso_group, cfg);
> +}
> +
> +static void endpoint_is_reconfigure_cfg(const char *input, void *user_data)
> +{
> +       struct endpoint_config *cfg = user_data;
> +
> +       if (!strcasecmp(input, "n") || !strcasecmp(input, "no")) {
> +               cfg->ep->iso_stream = BT_ISO_QOS_STREAM_UNSET;
> +               goto done;
> +       } else {
> +               bt_shell_printf("The BIS index is assigned  in the order of "
> +                               "the configuration starting with 1\n");
> +               bt_shell_prompt_input(cfg->ep->path,
> +               "BIS Index (value):",
> +               endpoint_set_reconfigure_cfg, cfg);
> +               return;
> +       }
> +
> +done:
> +       bt_shell_prompt_input(cfg->ep->path,
> +               "BIG (auto/value):",
> +               config_endpoint_iso_group, cfg);
> +}
> +
>  static void endpoint_set_config_bcast(struct endpoint_config *cfg)
>  {
>         cfg->ep->bcode = g_new0(struct iovec, 1);
> @@ -3835,8 +3877,8 @@ static void endpoint_set_config_bcast(struct endpoint_config *cfg)
>         }
>
>         bt_shell_prompt_input(cfg->ep->path,
> -               "BIG (auto/value):",
> -               config_endpoint_iso_group, cfg);
> +               "This is a BIS reconfiguration? (yes/no):",
> +               endpoint_is_reconfigure_cfg, cfg);
>  }
>
>  static void cmd_config_endpoint(int argc, char *argv[])
> --
> 2.39.2

Instead of having a 2 step process we could ask the BIS index right
away and if the user answers no/0 it means it doesn't want to
reconfigure an existing index.
diff mbox series

Patch

diff --git a/client/player.c b/client/player.c
index a40bf66e3..35143115a 100644
--- a/client/player.c
+++ b/client/player.c
@@ -3809,6 +3809,48 @@  static void config_endpoint_iso_group(const char *input, void *user_data)
 	}
 }
 
+static void endpoint_set_reconfigure_cfg(const char *input, void *user_data)
+{
+	char *endptr = NULL;
+	int value;
+	struct endpoint_config *cfg = user_data;
+
+	value = strtol(input, &endptr, 0);
+
+	if (!endptr || *endptr != '\0' || value > UINT8_MAX) {
+		bt_shell_printf("Invalid argument: %s\n", input);
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+	}
+
+	cfg->ep->iso_stream = value;
+
+	bt_shell_prompt_input(cfg->ep->path,
+		"BIG (auto/value):",
+		config_endpoint_iso_group, cfg);
+}
+
+static void endpoint_is_reconfigure_cfg(const char *input, void *user_data)
+{
+	struct endpoint_config *cfg = user_data;
+
+	if (!strcasecmp(input, "n") || !strcasecmp(input, "no")) {
+		cfg->ep->iso_stream = BT_ISO_QOS_STREAM_UNSET;
+		goto done;
+	} else {
+		bt_shell_printf("The BIS index is assigned  in the order of "
+				"the configuration starting with 1\n");
+		bt_shell_prompt_input(cfg->ep->path,
+		"BIS Index (value):",
+		endpoint_set_reconfigure_cfg, cfg);
+		return;
+	}
+
+done:
+	bt_shell_prompt_input(cfg->ep->path,
+		"BIG (auto/value):",
+		config_endpoint_iso_group, cfg);
+}
+
 static void endpoint_set_config_bcast(struct endpoint_config *cfg)
 {
 	cfg->ep->bcode = g_new0(struct iovec, 1);
@@ -3835,8 +3877,8 @@  static void endpoint_set_config_bcast(struct endpoint_config *cfg)
 	}
 
 	bt_shell_prompt_input(cfg->ep->path,
-		"BIG (auto/value):",
-		config_endpoint_iso_group, cfg);
+		"This is a BIS reconfiguration? (yes/no):",
+		endpoint_is_reconfigure_cfg, cfg);
 }
 
 static void cmd_config_endpoint(int argc, char *argv[])