diff mbox series

[BlueZ] obexctl: Add optional argument channel to connect command

Message ID 20220214183214.1803894-1-luiz.dentz@gmail.com
State Superseded
Headers show
Series [BlueZ] obexctl: Add optional argument channel to connect command | expand

Commit Message

Luiz Augusto von Dentz Feb. 14, 2022, 6:32 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds a third argument to connect command so a channel can be passed
to CreateSession which is useful since it possible to force a specific
RFCOMM channel.
---
 tools/obexctl.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

Comments

bluez.test.bot@gmail.com Feb. 14, 2022, 7:58 p.m. UTC | #1
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=614210

---Test result---

Test Summary:
CheckPatch                    PASS      1.47 seconds
GitLint                       PASS      1.01 seconds
Prep - Setup ELL              PASS      48.15 seconds
Build - Prep                  PASS      0.86 seconds
Build - Configure             PASS      9.88 seconds
Build - Make                  PASS      1716.51 seconds
Make Check                    PASS      12.72 seconds
Make Check w/Valgrind         PASS      494.06 seconds
Make Distcheck                PASS      263.34 seconds
Build w/ext ELL - Configure   PASS      10.39 seconds
Build w/ext ELL - Make        PASS      1692.25 seconds
Incremental Build with patchesPASS      0.00 seconds



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/tools/obexctl.c b/tools/obexctl.c
index e671d253b..41f9401f5 100644
--- a/tools/obexctl.c
+++ b/tools/obexctl.c
@@ -114,6 +114,7 @@  static void connect_reply(DBusMessage *message, void *user_data)
 struct connect_args {
 	char *dev;
 	char *target;
+	uint16_t channel;
 };
 
 static void connect_args_free(void *data)
@@ -139,13 +140,14 @@  static void connect_setup(DBusMessageIter *iter, void *user_data)
 					DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
 					&dict);
 
-	if (args->target == NULL)
-		goto done;
-
-	g_dbus_dict_append_entry(&dict, "Target",
+	if (args->target)
+		g_dbus_dict_append_entry(&dict, "Target",
 					DBUS_TYPE_STRING, &args->target);
 
-done:
+	if (args->channel)
+		g_dbus_dict_append_entry(&dict, "Channel",
+					DBUS_TYPE_UINT16, &args->channel);
+
 	dbus_message_iter_close_container(iter, &dict);
 }
 
@@ -153,6 +155,7 @@  static void cmd_connect(int argc, char *argv[])
 {
 	struct connect_args *args;
 	const char *target = "opp";
+	int channel = 0;
 
 	if (!client) {
 		bt_shell_printf("Client proxy not available\n");
@@ -162,9 +165,20 @@  static void cmd_connect(int argc, char *argv[])
 	if (argc > 2)
 		target = argv[2];
 
+	if (argc > 3) {
+		char *endptr = NULL;
+
+		channel = strtol(argv[3], &endptr, 0);
+		if (!endptr || *endptr != '\0' || channel > UINT16_MAX) {
+			bt_shell_printf("Invalid channel\n");
+			return bt_shell_noninteractive_quit(EXIT_FAILURE);
+		}
+	}
+
 	args = g_new0(struct connect_args, 1);
 	args->dev = g_strdup(argv[1]);
 	args->target = g_strdup(target);
+	args->channel = channel;
 
 	if (g_dbus_proxy_method_call(client, "CreateSession", connect_setup,
 			connect_reply, args, connect_args_free) == FALSE) {
@@ -1832,7 +1846,8 @@  static void cmd_mkdir(int argc, char *argv[])
 static const struct bt_shell_menu main_menu = {
 	.name = "main",
 	.entries = {
-	{ "connect",      "<dev> [uuid]", cmd_connect, "Connect session" },
+	{ "connect",      "<dev> [uuid] [channel]", cmd_connect,
+						"Connect session" },
 	{ "disconnect",   "[session]", cmd_disconnect, "Disconnect session",
 						session_generator },
 	{ "list",         NULL,       cmd_list, "List available sessions" },