From 5499681bc63226c03984e3493eebd0dc4cd2243f Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 5 Jun 2025 14:13:10 -0400 Subject: [PATCH] client: Use -EINPROGRESS with scan and advertise command This uses -EINPROGRESS with commands scan and advertise since they need to keep running in the background so they don't exit but shouldn't block other command from executing in case they are invoked from a script. --- client/advertising.c | 9 ++------- client/main.c | 3 ++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/client/advertising.c b/client/advertising.c index 382ae420e..f9df1b855 100644 --- a/client/advertising.c +++ b/client/advertising.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "gdbus/gdbus.h" #include "src/shared/util.h" @@ -238,7 +239,7 @@ static void register_reply(DBusMessage *message, void *user_data) ad.registered = true; bt_shell_printf("Advertising object registered\n"); print_ad(); - /* Leave advertise running even on noninteractive mode */ + return bt_shell_noninteractive_quit(-EINPROGRESS); } else { bt_shell_printf("Failed to register advertisement: %s\n", error.name); dbus_error_free(&error); @@ -874,8 +875,6 @@ static void ad_clear_service(int type) { g_free(ad.service[type].uuid); memset(&ad.service[type], 0, sizeof(ad.service[type])); - - return bt_shell_noninteractive_quit(EXIT_SUCCESS); } static bool ad_add_data(struct ad_data *data, int argc, char *argv[]) @@ -950,8 +949,6 @@ void ad_disable_service(DBusConnection *conn, int type) static void ad_clear_manufacturer(int type) { memset(&ad.manufacturer[type], 0, sizeof(ad.manufacturer[type])); - - return bt_shell_noninteractive_quit(EXIT_SUCCESS); } void ad_advertise_manufacturer(DBusConnection *conn, int type, @@ -1006,8 +1003,6 @@ void ad_disable_manufacturer(DBusConnection *conn, int type) static void ad_clear_data(int type) { memset(&ad.data[type], 0, sizeof(ad.data[type])); - - return bt_shell_noninteractive_quit(EXIT_SUCCESS); } void ad_advertise_data(DBusConnection *conn, int type, int argc, char *argv[]) diff --git a/client/main.c b/client/main.c index c2321952b..d99a5158e 100644 --- a/client/main.c +++ b/client/main.c @@ -1219,7 +1219,8 @@ static void start_discovery_reply(DBusMessage *message, void *user_data) bt_shell_printf("Discovery %s\n", enable ? "started" : "stopped"); filter.active = enable; - /* Leave the discovery running even on noninteractive mode */ + + return bt_shell_noninteractive_quit(-EINPROGRESS); } static void clear_discovery_filter(DBusMessageIter *iter, void *user_data) -- 2.47.3