All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1 1/2] client: Add command wake
@ 2024-12-17 18:13 Luiz Augusto von Dentz
  2024-12-17 18:13 ` [PATCH BlueZ v1 2/2] device: Fix not being able to set WakeAllowed Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2024-12-17 18:13 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds command wake which can be used to set WakeAllowed property:

[bluetoothctl]> wake XX:XX:XX:XX:XX:XX off
[bluetoothctl]> Changing wake off succeeded
[bluetoothctl]> [CHG] Device XX:XX:XX:XX:XX:XX WakeAllowed: no
[bluetoothctl]> wake XX:XX:XX:XX:XX:XX on
[bluetoothctl]> Changing wake on succeeded
[bluetoothctl]> [CHG] Device XX:XX:XX:XX:XX:XX WakeAllowed: yes
[bluetoothctl]> wake XX:XX:XX:XX:XX:XX
---
 client/main.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/client/main.c b/client/main.c
index c4fc49427021..322326ab9b80 100644
--- a/client/main.c
+++ b/client/main.c
@@ -2050,6 +2050,42 @@ static void cmd_disconn(int argc, char *argv[])
 						proxy_address(proxy));
 }
 
+static void cmd_wake(int argc, char *argv[])
+{
+	GDBusProxy *proxy;
+	dbus_bool_t value;
+	char *str;
+
+	proxy = find_device(argc, argv);
+	if (!proxy)
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+
+	if (argc <= 2) {
+		print_property(proxy, "WakeAllowed");
+		return;
+	}
+
+	if (!strcasecmp(argv[2], "on")) {
+		value = TRUE;
+	} else if (!strcasecmp(argv[2], "off")) {
+		value = FALSE;
+	} else {
+		bt_shell_printf("Invalid value %s\n", argv[2]);
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+	}
+
+	str = g_strdup_printf("wake %s", value == TRUE ? "on" : "off");
+
+	if (g_dbus_proxy_set_property_basic(proxy, "WakeAllowed",
+					DBUS_TYPE_BOOLEAN, &value,
+					generic_callback, str, g_free))
+		return;
+
+	g_free(str);
+
+	return bt_shell_noninteractive_quit(EXIT_FAILURE);
+}
+
 static void cmd_list_attributes(int argc, char *argv[])
 {
 	GDBusProxy *proxy;
@@ -3130,6 +3166,8 @@ static const struct bt_shell_menu main_menu = {
 							dev_generator },
 	{ "disconnect",   "[dev]",    cmd_disconn, "Disconnect device",
 							dev_generator },
+	{ "wake",         "[dev] [on/off]",    cmd_wake, "Get/Set wake support",
+							dev_generator },
 	{ } },
 };
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-18 14:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-17 18:13 [PATCH BlueZ v1 1/2] client: Add command wake Luiz Augusto von Dentz
2024-12-17 18:13 ` [PATCH BlueZ v1 2/2] device: Fix not being able to set WakeAllowed Luiz Augusto von Dentz
2024-12-17 19:18 ` [BlueZ,v1,1/2] client: Add command wake bluez.test.bot
2024-12-18 14:40 ` [PATCH BlueZ v1 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.