From 41f943630d9a03c40e95057b2ac3d96470b9c71e Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 12 Sep 2024 16:40:22 -0400 Subject: [PATCH] client: Print a warning when setting discoverable without a timeout This makes command discoverable to print a warning if discoverable-timeout is not set(0): [bluetooth]# discoverable-timeout 0 [bluetooth]# Changing discoverable-timeout 0 succeeded [bluetooth]# [CHG] Controller 4C:49:6C:44:F5:E7 DiscoverableTimeout: 0x00000000 (0) [bluetooth]# discoverable on Warning: setting discoverable while discoverable-timeout not set(0) is not recommended --- client/main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client/main.c b/client/main.c index a96a42638..2a5c7527b 100644 --- a/client/main.c +++ b/client/main.c @@ -1095,6 +1095,7 @@ static void cmd_pairable(int argc, char *argv[]) static void cmd_discoverable(int argc, char *argv[]) { + DBusMessageIter iter; dbus_bool_t discoverable; char *str; @@ -1104,6 +1105,18 @@ static void cmd_discoverable(int argc, char *argv[]) if (check_default_ctrl() == FALSE) return bt_shell_noninteractive_quit(EXIT_FAILURE); + if (discoverable && g_dbus_proxy_get_property(default_ctrl->proxy, + "DiscoverableTimeout", &iter)) { + uint32_t value; + + dbus_message_iter_get_basic(&iter, &value); + + if (!value) + bt_shell_printf("Warning: setting discoverable while " + "discoverable-timeout not set(0) is not" + " recommended\n"); + } + str = g_strdup_printf("discoverable %s", discoverable == TRUE ? "on" : "off"); -- 2.47.3