From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> This adds FilterDiscoverable option which can be use to control if devices in non-discoverable mode shall be filtered or not, the default is true to adhere to core spec: 9.2. Discovery modes and procedures All devices shall be in either non-discoverable mode or one of the discoverable modes. A device in the discoverable mode shall be in either the general discoverable mode or the limited discoverable mode. A device in the non-discoverable mode is not discoverable. Devices operating in either the general discoverable mode or the limited discoverable mode can be found by the discovering device. --- src/adapter.c | 4 +++- src/btd.h | 1 + src/main.c | 3 +++ src/main.conf | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/adapter.c b/src/adapter.c index 549a6c0b8324..dc5ba65d73fa 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -7239,8 +7239,10 @@ static bool device_is_discoverable(struct btd_adapter *adapter, if (bdaddr_type == BDADDR_BREDR || adapter->filtered_discovery) discoverable = true; - else + else if (btd_opts.filter_discoverable) discoverable = eir->flags & (EIR_LIM_DISC | EIR_GEN_DISC); + else + discoverable = true; /* * Mark as not discoverable if no client has requested discovery and diff --git a/src/btd.h b/src/btd.h index 18a5eb88696a..5c952bf17956 100644 --- a/src/btd.h +++ b/src/btd.h @@ -142,6 +142,7 @@ struct btd_opts { bool refresh_discovery; bool experimental; bool testing; + bool filter_discoverable; struct queue *kernel; uint16_t did_source; diff --git a/src/main.c b/src/main.c index a542d0fc50b0..6bb3bb8adb3e 100644 --- a/src/main.c +++ b/src/main.c @@ -91,6 +91,7 @@ static const char *supported_options[] = { "Testing", "KernelExperimental", "RemoteNameRequestRetryDelay", + "FilterDiscoverable", NULL }; @@ -1062,6 +1063,8 @@ static void parse_general(GKeyFile *config) parse_config_u32(config, "General", "RemoteNameRequestRetryDelay", &btd_opts.name_request_retry_delay, 0, UINT32_MAX); + parse_config_bool(config, "General", "FilterDiscoverable", + &btd_opts.filter_discoverable); } static void parse_gatt_cache(GKeyFile *config) diff --git a/src/main.conf b/src/main.conf index 86759d53c1f2..55618be5c923 100644 --- a/src/main.conf +++ b/src/main.conf @@ -148,6 +148,11 @@ # The value is in seconds. Default is 300, i.e. 5 minutes. #RemoteNameRequestRetryDelay = 300 +# Filter out non-discoverable devices based on discoverable flags (General or +# Limited). +# Defaults to true +#FilterDiscoverable = true + [BR] # The following values are used to load default adapter parameters for BR/EDR. # BlueZ loads the values into the kernel before the adapter is powered if the -- 2.51.0