From 8e8ce044f9bdcad889a72a952e56419e7e39c740 Mon Sep 17 00:00:00 2001 From: Alberto Fanjul Date: Tue, 8 Nov 2022 08:49:54 +0100 Subject: [PATCH] Add command friendly-name to sink controller --- src/ctl/sinkctl.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/ctl/sinkctl.c b/src/ctl/sinkctl.c index e2167de..eb932aa 100644 --- a/src/ctl/sinkctl.c +++ b/src/ctl/sinkctl.c @@ -189,6 +189,41 @@ static int cmd_show(char **args, unsigned int n) return 0; } +/* + * cmd: set-friendly-name + */ + +static int cmd_set_friendly_name(char **args, unsigned int n) +{ + struct ctl_link *l = NULL; + const char *name; + + if (n < 1) { + cli_command_printf("To what?\n"); + return 0; + } + + if (n > 1) { + l = ctl_wifi_search_link(wifi, args[0]); + if (!l) { + cli_error("unknown link %s", args[0]); + return 0; + } + + name = args[1]; + } else { + name = args[0]; + } + + l = l ? : running_link; + if (!l) { + cli_error("no running link"); + return 0; + } + + return ctl_link_set_friendly_name(l, name); +} + /* * cmd: run */ @@ -381,6 +416,7 @@ static const struct cli_cmd cli_cmds[] = { { "show", "", CLI_M, CLI_LESS, 1, cmd_show, "Show detailed object information" }, { "run", "", CLI_M, CLI_EQUAL, 1, cmd_run, "Run sink on given link" }, { "bind", "", CLI_M, CLI_EQUAL, 1, cmd_bind, "Like 'run' but bind the link name to run when it is hotplugged" }, + { "set-friendly-name", "[link] ", CLI_M, CLI_LESS, 2, cmd_set_friendly_name, "Set friendly name of an object" }, { "set-managed", " ", CLI_M, CLI_EQUAL, 2, cmd_set_managed, "Manage or unmnage a link" }, { "quit", NULL, CLI_Y, CLI_MORE, 0, cmd_quit, "Quit program" }, { "exit", NULL, CLI_Y, CLI_MORE, 0, cmd_quit, NULL },