diff --git a/client/main.c b/client/main.c
index ce753c1..06ae25c 100644
--- a/client/main.c
+++ b/client/main.c
bt_shell_set_env("AUTO_REGISTER_ENDPOINT",
(void *)endpoint_option);
- mgmt_enable_submenu();
assistant_enable_submenu();
client = g_dbus_client_new(dbus_conn, "org.bluez", "/org/bluez");
diff --git a/client/mgmt.c b/client/mgmt.c
index 6c6d62f..0a9cc58 100644
--- a/client/mgmt.c
+++ b/client/mgmt.c
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
+static void mgmt_menu_pre_run(const struct bt_shell_menu *menu);
+
#define PROMPT_ON COLOR_BLUE "[mgmt]" COLOR_OFF "> "
static void update_prompt(uint16_t index)
static const struct bt_shell_menu mgmt_menu = {
.name = "mgmt",
.desc = "Management Submenu",
+ .pre_run = mgmt_menu_pre_run,
.entries = {
{ "select", "<index>",
cmd_select, "Select a different index" },
bt_shell_add_submenu(&monitor_menu);
}
-bool mgmt_enable_submenu(void)
+static void mgmt_menu_pre_run(const struct bt_shell_menu *menu)
{
mgmt = mgmt_new_default();
if (!mgmt) {
fprintf(stderr, "Unable to open mgmt_socket\n");
- return false;
+ return;
}
if (getenv("MGMT_DEBUG"))
mgmt_set_debug(mgmt, mgmt_debug, "mgmt: ", NULL);
register_mgmt_callbacks(mgmt, mgmt_index);
-
- return true;
}
void mgmt_remove_submenu(void)
diff --git a/client/mgmt.h b/client/mgmt.h
index b0f3caf..6d235fb 100644
--- a/client/mgmt.h
+++ b/client/mgmt.h
*/
void mgmt_add_submenu(void);
-bool mgmt_enable_submenu(void);
void mgmt_remove_submenu(void);
void mgmt_set_index(const char *arg);
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 0f6051d..0f3de28 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
bt_shell_init(argc, argv, &opt);
mgmt_add_submenu();
- if (!mgmt_enable_submenu()) {
- fprintf(stderr, "Unable to open mgmt_socket\n");
- return EXIT_FAILURE;
- }
-
mgmt_set_index(index_option);
bt_shell_attach(fileno(stdin));
status = bt_shell_run();