Re: Cannot use any submenu in bluetoothctl since bluez 5.48

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Vincent,

On 02/05/2018 03:57 PM, Vincent Petry wrote:
> Hello,
> 
> It appears that since bluez 5.48, the gatt commands and others have been
> moved into a submenu in the bluetoothctl shell.
> 
> I'm struggling to find a way to access the gatt commands. In the past I
> could just type "list-attributes" but now it says "Invalid command".
> 
> None of the following commands work:
> 
> - gatt
> - gatt help
> - help gatt
> - list-attributes
> 
> I had a quick look at the source code and I have the feeling that there
> is actually no way to access these commands.
> 
> If there is a way already, please make it easier and more intuitive to find.
> 

You can input "menu gatt" to enter gatt submenu and can use available commands
in gatt submenu (e.g. "list-attributes"). If you want to return to main menu,
you input "back". Then you can use available commands in main menu or enter
another submenu.

When inputting an invalid command, we may be able to add the messages like

  [bluetooth]# gatt
  Invalid command: gatt

  Use "help" for a list of available commands in a menu.
  Use "menu <submenu>" if you want to enter any submenu.
  Use "back" if you want to return to main menu.

with the following patch.

---
 src/shared/shell.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index f1b85f202..fad421ef1 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -335,6 +335,16 @@ static int menu_exec(const struct bt_shell_menu_entry *entry,
 	return -ENOENT;
 }
 
+static void help_messages(char *arg)
+{
+	print_text(COLOR_HIGHLIGHT,
+		"Invalid command: %s\n\n"
+		"Use \"help\" for a list of available commands in a menu.\n"
+		"Use \"menu <submenu>\" if you want to enter any submenu.\n"
+		"Use \"back\" if you want to return to main menu.",
+		arg);
+}
+
 static void shell_exec(int argc, char *argv[])
 {
 	if (!data.menu || !argv[0])
@@ -342,7 +352,7 @@ static void shell_exec(int argc, char *argv[])
 
 	if (menu_exec(default_menu, argc, argv) == -ENOENT) {
 		if (menu_exec(data.menu->entries, argc, argv) == -ENOENT)
-			print_text(COLOR_HIGHLIGHT, "Invalid command");
+			help_messages(argv[0]);
 	}
 }
 
-- 
2.14.1


Regards,
Eramoto

> My env:
> - openSUSE Tumbleweed snapshot 20180130
> - bluez 5.48
> - kernel 4.14.15-1-default
> 
> Thanks,
> 
> Vincent
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux