From: Luiz Augusto von Dentz Date: Fri, 11 Feb 2022 21:48:46 +0000 (-0800) Subject: main.conf: Introduce MaxControllers X-Git-Tag: accepted/tizen/unified/20230608.164325~359 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a5aa8609acb32b078b123559b05b4e1fc294ba8;p=platform%2Fupstream%2Fbluez.git main.conf: Introduce MaxControllers This introduces MaxControllers which can be used to limit the number of adapters exposed in the system. Signed-off-by: Manika Shrivastava Signed-off-by: Ayush Garg --- diff --git a/src/adapter.c b/src/adapter.c index 8e01a1d..e540468 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -16548,6 +16548,13 @@ static void index_added(uint16_t index, uint16_t length, const void *param, return; } + /* Check if at maximum adapters allowed in the system then ignore the + * adapter. + */ + if (btd_opts.max_adapters && + btd_opts.max_adapters == g_slist_length(adapters)) + return; + reset_adv_monitors(index); adapter = btd_adapter_new(index); diff --git a/src/btd.h b/src/btd.h index aae2298..097e3ea 100755 --- a/src/btd.h +++ b/src/btd.h @@ -126,6 +126,7 @@ struct btd_opts { uint16_t did_version; bt_mode_t mode; + uint16_t max_adapters; bt_gatt_cache_t gatt_cache; uint16_t gatt_mtu; uint8_t gatt_channels; diff --git a/src/main.c b/src/main.c index eee773b..12c84be 100755 --- a/src/main.c +++ b/src/main.c @@ -76,6 +76,7 @@ static const char *supported_options[] = { "NameResolving", "DebugKeys", "ControllerMode", + "MaxControllers" "MultiProfile", "FastConnectable", "Privacy", @@ -783,6 +784,14 @@ static void parse_config(GKeyFile *config) g_free(str); } + val = g_key_file_get_integer(config, "General", "MaxControllers", &err); + if (err) { + g_clear_error(&err); + } else { + DBG("MaxControllers=%d", val); + btd_opts.max_adapters = val; + } + str = g_key_file_get_string(config, "General", "MultiProfile", &err); if (err) { g_clear_error(&err); diff --git a/src/main.conf b/src/main.conf index b285995..f735ff7 100755 --- a/src/main.conf +++ b/src/main.conf @@ -57,6 +57,10 @@ # Possible values: "dual", "bredr", "le" #ControllerMode = dual +# Maximum number of controllers allowed to be exposed to the system. +# Default=0 (unlimited) +#MaxControllers=0 + # Enables Multi Profile Specification support. This allows to specify if # system supports only Multiple Profiles Single Device (MPSD) configuration # or both Multiple Profiles Single Device (MPSD) and Multiple Profiles Multiple