struct connect_args {
char *dev;
char *target;
+ uint8_t channel;
};
static void connect_args_free(void *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_BYTE, &args->channel);
+
dbus_message_iter_close_container(iter, &dict);
}
{
struct connect_args *args;
const char *target = "opp";
+ int channel = 0;
if (!client) {
bt_shell_printf("Client proxy not available\n");
if (argc > 2)
target = argv[2];
+ if (argc > 3) {
+ char *endptr = NULL;
+
+ channel = strtol(argv[3], &endptr, 0);
+ if (!endptr || *endptr != '\0' || channel > UINT8_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) {
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" },