Skip to contentSkip to conversation

shared/shell: Add prompt item to bt_shell_menu structure

PATCH In review Inga Stotland 2 participants 3 messages Oct 23, 2019 – Nov 13, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shared/shell: Add prompt item to bt_shell_menu structure

This allows to associate specific prompts with main menu and submenus thus providing for better navigation when submenus are in use.

---
 src/shared/shell.c | 3 +++
 src/shared/shell.h | 1 +
 2 files changed, 4 insertions(+)
src/shared/shell.c +3 -0
index cfdcc76c4..a821c8d0a 100644
@@ -1226,6 +1226,9 @@ bool bt_shell_set_menu(const struct bt_shell_menu *menu)
 	if (!data.main)
 		data.main = menu;
 
+	if (menu->prompt)
+		bt_shell_set_prompt(menu->prompt);
+
 	return true;
 }
 
src/shared/shell.h +1 -0
index e14d58381..a9eee506f 100644
@@ -53,6 +53,7 @@ struct bt_shell_menu_entry {
 struct bt_shell_menu {
 	const char *name;
 	const char *desc;
+	const char *prompt;
 	const struct bt_shell_menu_entry entries[];
 };
 
Signature · 1 line
2.21.0
#1 lore raw

Hi Luiz,

Quoted 27 lines · Inga Stotland

This allows to associate specific prompts with main menu and submenus thus providing for better navigation when submenus are in use.

---
 src/shared/shell.c | 3 +++
 src/shared/shell.h | 1 +
 2 files changed, 4 insertions(+)
src/shared/shell.c +3 -0
index cfdcc76c4..a821c8d0a 100644
@@ -1226,6 +1226,9 @@ bool bt_shell_set_menu(const struct bt_shell_menu *menu)
 	if (!data.main)
 		data.main = menu;
 
+	if (menu->prompt)
+		bt_shell_set_prompt(menu->prompt);
+
 	return true;
 }
 
src/shared/shell.h +0 -0
index e14d58381..a9eee506f 100644

src/shared/shell.h struct bt_shell_menu_entry { · line 59

Quoted 7 lines
src/shared/shell.h +1 -0
@@ -53,6 +53,7 @@ struct bt_shell_menu_entry {
 struct bt_shell_menu {
 	const char *name;
 	const char *desc;
+	const char *prompt;
 	const struct bt_shell_menu_entry entries[];
 };
 

Do you have any comments for this patch?

Best regards,
Inga

#2 lore raw

Hi Inga,

Quoted 26 lines · Inga

Hi Luiz,

Quoted 22 lines · Inga Stotland

This allows to associate specific prompts with main menu and submenus thus providing for better navigation when submenus are in use.

---
 src/shared/shell.c | 3 +++
 src/shared/shell.h | 1 +
 2 files changed, 4 insertions(+)
src/shared/shell.c +3 -0
index cfdcc76c4..a821c8d0a 100644
@@ -1226,6 +1226,9 @@ bool bt_shell_set_menu(const struct bt_shell_menu *menu)
      if (!data.main)
              data.main = menu;
 
+     if (menu->prompt)
+             bt_shell_set_prompt(menu->prompt);
+
      return true;
 }
 
Quoted 14 lines

src/shared/shell.h struct bt_shell_menu_entry { · line 59

Quoted 12 lines
src/shared/shell.h +1 -0
index e14d58381..a9eee506f 100644
@@ -53,6 +53,7 @@ struct bt_shell_menu_entry {
 struct bt_shell_menu {
      const char *name;
      const char *desc;
+     const char *prompt;
      const struct bt_shell_menu_entry entries[];
 };
 

Do you have any comments for this patch?

I recall experimenting with something similar, but the problem is that sometimes there is already a prompt set, for instance we set the address when connected on bluetoothctl and that should probably stay even if you change the menu, perhaps instead overwrite the prompt we could have another section so we append the menu name at the end of the prompt or something like that.

Signature · 1 line
Luiz Augusto von Dentz