* [PATCH BlueZ 1/2] shell: Set empty argument if optarg is NULL
@ 2022-08-29 21:37 Luiz Augusto von Dentz
2022-08-29 21:37 ` [PATCH BlueZ 2/2] client: Add -e/--endpoint option to auto register endpoints Luiz Augusto von Dentz
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2022-08-29 21:37 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This sets enmpty string ("") when argument don't set any optarg so the
application can tell when an option was set or not.
---
src/shared/shell.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shared/shell.c b/src/shared/shell.c
index dfda8128af91..4658819a4bde 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -1158,7 +1158,7 @@ void bt_shell_init(int argc, char **argv, const struct bt_shell_opt *opt)
return;
}
- *opt->optarg[index - offset] = optarg;
+ *opt->optarg[index - offset] = optarg ? : "";
}
index = -1;
--
2.37.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH BlueZ 2/2] client: Add -e/--endpoint option to auto register endpoints
2022-08-29 21:37 [PATCH BlueZ 1/2] shell: Set empty argument if optarg is NULL Luiz Augusto von Dentz
@ 2022-08-29 21:37 ` Luiz Augusto von Dentz
2022-08-29 22:30 ` [BlueZ,1/2] shell: Set empty argument if optarg is NULL bluez.test.bot
2022-08-30 21:30 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2022-08-29 21:37 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds -e/--endpoint option that can be used to auto register
supported endpoints.
---
client/main.c | 14 ++++--
client/player.c | 122 ++++++++++++++++++++++++++++++++++--------------
2 files changed, 98 insertions(+), 38 deletions(-)
diff --git a/client/main.c b/client/main.c
index 54f21fbdf9a0..6773d52627db 100644
--- a/client/main.c
+++ b/client/main.c
@@ -3109,23 +3109,27 @@ static const struct bt_shell_menu main_menu = {
static const struct option options[] = {
{ "agent", required_argument, 0, 'a' },
+ { "endpoints", no_argument, 0, 'e' },
{ 0, 0, 0, 0 }
};
static const char *agent_option;
+static const char *endpoint_option;
static const char **optargs[] = {
- &agent_option
+ &agent_option,
+ &endpoint_option
};
static const char *help[] = {
- "Register agent handler: <capability>"
+ "Register agent handler: <capability>",
+ "Register Media endpoints"
};
static const struct bt_shell_opt opt = {
.options = options,
.optno = sizeof(options) / sizeof(struct option),
- .optstr = "a:",
+ .optstr = "a:e",
.optarg = optargs,
.help = help,
};
@@ -3158,6 +3162,10 @@ int main(int argc, char *argv[])
bt_shell_set_env("DBUS_CONNECTION", dbus_conn);
+ if (endpoint_option)
+ bt_shell_set_env("AUTO_REGISTER_ENDPOINT",
+ (void *)endpoint_option);
+
admin_add_submenu();
player_add_submenu();
diff --git a/client/player.c b/client/player.c
index 99b036b8c3ec..3d2f41cb3666 100644
--- a/client/player.c
+++ b/client/player.c
@@ -510,41 +510,6 @@ static char *proxy_description(GDBusProxy *proxy, const char *title,
title, path);
}
-static void print_media(GDBusProxy *proxy, const char *description)
-{
- char *str;
-
- str = proxy_description(proxy, "Media", description);
-
- bt_shell_printf("%s\n", str);
-
- g_free(str);
-}
-
-static void print_player(GDBusProxy *proxy, const char *description)
-{
- char *str;
-
- str = proxy_description(proxy, "Player", description);
-
- bt_shell_printf("%s%s\n", str,
- default_player == proxy ? "[default]" : "");
-
- g_free(str);
-}
-
-static void cmd_list(int argc, char *arg[])
-{
- GList *l;
-
- for (l = players; l; l = g_list_next(l)) {
- GDBusProxy *proxy = l->data;
- print_player(proxy, NULL);
- }
-
- return bt_shell_noninteractive_quit(EXIT_SUCCESS);
-}
-
static void print_iter(const char *label, const char *name,
DBusMessageIter *iter)
{
@@ -627,6 +592,42 @@ static void print_property(GDBusProxy *proxy, const char *name)
print_iter("\t", name, &iter);
}
+static void print_media(GDBusProxy *proxy, const char *description)
+{
+ char *str;
+
+ str = proxy_description(proxy, "Media", description);
+
+ bt_shell_printf("%s\n", str);
+ print_property(proxy, "SupportedUUIDs");
+
+ g_free(str);
+}
+
+static void print_player(GDBusProxy *proxy, const char *description)
+{
+ char *str;
+
+ str = proxy_description(proxy, "Player", description);
+
+ bt_shell_printf("%s%s\n", str,
+ default_player == proxy ? "[default]" : "");
+
+ g_free(str);
+}
+
+static void cmd_list(int argc, char *arg[])
+{
+ GList *l;
+
+ for (l = players; l; l = g_list_next(l)) {
+ GDBusProxy *proxy = l->data;
+ print_player(proxy, NULL);
+ }
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
static void cmd_show_item(int argc, char *argv[])
{
GDBusProxy *proxy;
@@ -2412,11 +2413,62 @@ static const struct bt_shell_menu endpoint_menu = {
{} },
};
+static struct endpoint *endpoint_new(const struct capabilities *cap)
+{
+ struct endpoint *ep;
+
+ ep = new0(struct endpoint, 1);
+ ep->uuid = g_strdup(cap->uuid);
+ ep->codec = cap->codec_id;
+ ep->path = g_strdup_printf("%s/ep%u", BLUEZ_MEDIA_ENDPOINT_PATH,
+ g_list_length(local_endpoints));
+ /* Copy capabilities */
+ iov_append(&ep->caps, cap->data.iov_base, cap->data.iov_len);
+ local_endpoints = g_list_append(local_endpoints, ep);
+
+ return ep;
+}
+
+static void register_endpoints(GDBusProxy *proxy)
+{
+ struct endpoint *ep;
+ DBusMessageIter iter, array;
+
+ if (!g_dbus_proxy_get_property(proxy, "SupportedUUIDs", &iter))
+ return;
+
+ dbus_message_iter_recurse(&iter, &array);
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRING) {
+ const char *uuid;
+ size_t i;
+
+ dbus_message_iter_get_basic(&array, &uuid);
+
+ for (i = 0; i < ARRAY_SIZE(caps); i++) {
+ const struct capabilities *cap = &caps[i];
+
+ if (strcasecmp(cap->uuid, uuid))
+ continue;
+
+ ep = endpoint_new(cap);
+ ep->auto_accept = true;
+ ep->cig = BT_ISO_QOS_CIG_UNSET;
+ ep->cis = BT_ISO_QOS_CIS_UNSET;
+ endpoint_register(ep);
+ }
+
+ dbus_message_iter_next(&array);
+ }
+}
+
static void media_added(GDBusProxy *proxy)
{
medias = g_list_append(medias, proxy);
print_media(proxy, COLORED_NEW);
+
+ if (bt_shell_get_env("AUTO_REGISTER_ENDPOINT"))
+ register_endpoints(proxy);
}
static void player_added(GDBusProxy *proxy)
--
2.37.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [BlueZ,1/2] shell: Set empty argument if optarg is NULL
2022-08-29 21:37 [PATCH BlueZ 1/2] shell: Set empty argument if optarg is NULL Luiz Augusto von Dentz
2022-08-29 21:37 ` [PATCH BlueZ 2/2] client: Add -e/--endpoint option to auto register endpoints Luiz Augusto von Dentz
@ 2022-08-29 22:30 ` bluez.test.bot
2022-08-30 21:30 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2022-08-29 22:30 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 3103 bytes --]
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=672191
---Test result---
Test Summary:
CheckPatch FAIL 2.26 seconds
GitLint PASS 1.52 seconds
Prep - Setup ELL PASS 32.33 seconds
Build - Prep PASS 0.79 seconds
Build - Configure PASS 10.36 seconds
Build - Make PASS 958.09 seconds
Make Check PASS 13.15 seconds
Make Check w/Valgrind PASS 348.11 seconds
Make Distcheck PASS 292.00 seconds
Build w/ext ELL - Configure PASS 10.67 seconds
Build w/ext ELL - Make PASS 100.25 seconds
Incremental Build w/ patches PASS 237.25 seconds
Scan Build WARNING 643.54 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
Output:
[BlueZ,2/2] client: Add -e/--endpoint option to auto register endpoints
WARNING:LINE_SPACING: Missing a blank line after declarations
#216: FILE: client/player.c:625:
+ GDBusProxy *proxy = l->data;
+ print_player(proxy, NULL);
/github/workspace/src/12958474.patch total: 0 errors, 1 warnings, 185 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/12958474.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: Scan Build - WARNING
Desc: Run Scan Build with patches
Output:
*****************************************************************************
The bugs reported by the scan-build may or may not be caused by your patches.
Please check the list and fix the bugs if they are caused by your patch.
*****************************************************************************
client/player.c:1758:25: warning: Dereference of null pointer
iov_append(&cfg->caps, preset->data.iov_base, preset->data.iov_len);
^~~~~~~~~~~~~~~~~~~~~
1 warning generated.
src/shared/shell.c:1135:19: warning: Null pointer passed to 1st parameter expecting 'nonnull'
data.timeout = atoi(optarg);
^~~~~~~~~~~~
src/shared/shell.c:1155: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) {
^~~~~~~~~~~~
2 warnings generated.
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH BlueZ 1/2] shell: Set empty argument if optarg is NULL
2022-08-29 21:37 [PATCH BlueZ 1/2] shell: Set empty argument if optarg is NULL Luiz Augusto von Dentz
2022-08-29 21:37 ` [PATCH BlueZ 2/2] client: Add -e/--endpoint option to auto register endpoints Luiz Augusto von Dentz
2022-08-29 22:30 ` [BlueZ,1/2] shell: Set empty argument if optarg is NULL bluez.test.bot
@ 2022-08-30 21:30 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2022-08-30 21:30 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Mon, 29 Aug 2022 14:37:37 -0700 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This sets enmpty string ("") when argument don't set any optarg so the
> application can tell when an option was set or not.
> ---
> src/shared/shell.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Here is the summary with links:
- [BlueZ,1/2] shell: Set empty argument if optarg is NULL
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=75f73f6d6264
- [BlueZ,2/2] client: Add -e/--endpoint option to auto register endpoints
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=d297a5873d21
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-30 21:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-29 21:37 [PATCH BlueZ 1/2] shell: Set empty argument if optarg is NULL Luiz Augusto von Dentz
2022-08-29 21:37 ` [PATCH BlueZ 2/2] client: Add -e/--endpoint option to auto register endpoints Luiz Augusto von Dentz
2022-08-29 22:30 ` [BlueZ,1/2] shell: Set empty argument if optarg is NULL bluez.test.bot
2022-08-30 21:30 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.