* [PATCH BlueZ v2 1/2] shared/ad: Add defines for possible flags
@ 2020-06-05 18:17 Luiz Augusto von Dentz
2020-06-05 18:17 ` [PATCH BlueZ v2 2/2] advertising: Fix resetting NO_BREDR flag Luiz Augusto von Dentz
2020-06-05 23:26 ` [PATCH BlueZ v2 1/2] shared/ad: Add defines for possible flags Luiz Augusto von Dentz
0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2020-06-05 18:17 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds defines for limited disverable, general discoveral and BR/EDR
not supported.
---
src/advertising.c | 9 +++++----
src/shared/ad.h | 5 +++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/advertising.c b/src/advertising.c
index 829c481f6..4c91586c2 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -673,7 +673,7 @@ static bool set_flags(struct btd_adv_client *client, uint8_t flags)
/* Set BR/EDR Not Supported for LE only */
if (!btd_adapter_get_bredr(client->manager->adapter))
- flags |= 0x04;
+ flags |= BT_AD_FLAG_NO_BREDR;
if (!bt_ad_add_flags(client->data, &flags, 1))
return false;
@@ -700,8 +700,8 @@ static bool parse_discoverable(DBusMessageIter *iter,
if (discoverable) {
/* Set BR/EDR Not Supported if adapter is no discoverable */
if (!btd_adapter_get_discoverable(client->manager->adapter))
- flags = 0x04;
- flags |= 0x02;
+ flags = BT_AD_FLAG_NO_BREDR;
+ flags |= BT_AD_FLAG_GENERAL;
} else
flags = 0x00;
@@ -1065,7 +1065,8 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client)
}
/* Set Limited Discoverable if DiscoverableTimeout is set */
- if (client->disc_to_id && !set_flags(client, 0x01)) {
+ if (client->disc_to_id &&
+ !set_flags(client, BT_AD_FLAG_LIMITED)) {
error("Failed to set Limited Discoverable Flag");
goto fail;
}
diff --git a/src/shared/ad.h b/src/shared/ad.h
index a31df0fe5..19aa1d035 100644
--- a/src/shared/ad.h
+++ b/src/shared/ad.h
@@ -71,6 +71,11 @@
#define BT_AD_3D_INFO_DATA 0x3d
#define BT_AD_MANUFACTURER_DATA 0xff
+/* Low Energy Advertising Flags */
+#define BT_AD_FLAG_LIMITED 0x01 /* Limited Discoverable */
+#define BT_AD_FLAG_GENERAL 0x02 /* General Discoverable */
+#define BT_AD_FLAG_NO_BREDR 0x04 /* BR/EDR not supported */
+
typedef void (*bt_ad_func_t)(void *data, void *user_data);
struct bt_ad;
--
2.25.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH BlueZ v2 2/2] advertising: Fix resetting NO_BREDR flag
2020-06-05 18:17 [PATCH BlueZ v2 1/2] shared/ad: Add defines for possible flags Luiz Augusto von Dentz
@ 2020-06-05 18:17 ` Luiz Augusto von Dentz
2020-06-05 23:26 ` [PATCH BlueZ v2 1/2] shared/ad: Add defines for possible flags Luiz Augusto von Dentz
1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2020-06-05 18:17 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When setting BT_AD_FLAG_LIMITED it was actually overwriting
BT_AD_FLAG_NO_BREDR as well so this moves the logic of detecting if the
instance needs to set BT_AD_FLAG_NO_BREDR to set_flags so it is always
updated when attempting to set any flags.
---
src/advertising.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/advertising.c b/src/advertising.c
index 4c91586c2..076d591b6 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -675,6 +675,13 @@ static bool set_flags(struct btd_adv_client *client, uint8_t flags)
if (!btd_adapter_get_bredr(client->manager->adapter))
flags |= BT_AD_FLAG_NO_BREDR;
+ /* Set BR/EDR Not Supported if adapter is not discoverable but the
+ * instance is.
+ */
+ if ((flags & (BT_AD_FLAG_GENERAL | BT_AD_FLAG_LIMITED)) &&
+ !btd_adapter_get_discoverable(client->manager->adapter))
+ flags |= BT_AD_FLAG_NO_BREDR;
+
if (!bt_ad_add_flags(client->data, &flags, 1))
return false;
@@ -697,12 +704,9 @@ static bool parse_discoverable(DBusMessageIter *iter,
dbus_message_iter_get_basic(iter, &discoverable);
- if (discoverable) {
- /* Set BR/EDR Not Supported if adapter is no discoverable */
- if (!btd_adapter_get_discoverable(client->manager->adapter))
- flags = BT_AD_FLAG_NO_BREDR;
- flags |= BT_AD_FLAG_GENERAL;
- } else
+ if (discoverable)
+ flags = BT_AD_FLAG_GENERAL;
+ else
flags = 0x00;
if (!set_flags(client , flags))
--
2.25.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH BlueZ v2 1/2] shared/ad: Add defines for possible flags
2020-06-05 18:17 [PATCH BlueZ v2 1/2] shared/ad: Add defines for possible flags Luiz Augusto von Dentz
2020-06-05 18:17 ` [PATCH BlueZ v2 2/2] advertising: Fix resetting NO_BREDR flag Luiz Augusto von Dentz
@ 2020-06-05 23:26 ` Luiz Augusto von Dentz
1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2020-06-05 23:26 UTC (permalink / raw)
To: linux-bluetooth
Hi,
On Fri, Jun 5, 2020 at 11:17 AM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This adds defines for limited disverable, general discoveral and BR/EDR
> not supported.
> ---
> src/advertising.c | 9 +++++----
> src/shared/ad.h | 5 +++++
> 2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/src/advertising.c b/src/advertising.c
> index 829c481f6..4c91586c2 100644
> --- a/src/advertising.c
> +++ b/src/advertising.c
> @@ -673,7 +673,7 @@ static bool set_flags(struct btd_adv_client *client, uint8_t flags)
>
> /* Set BR/EDR Not Supported for LE only */
> if (!btd_adapter_get_bredr(client->manager->adapter))
> - flags |= 0x04;
> + flags |= BT_AD_FLAG_NO_BREDR;
>
> if (!bt_ad_add_flags(client->data, &flags, 1))
> return false;
> @@ -700,8 +700,8 @@ static bool parse_discoverable(DBusMessageIter *iter,
> if (discoverable) {
> /* Set BR/EDR Not Supported if adapter is no discoverable */
> if (!btd_adapter_get_discoverable(client->manager->adapter))
> - flags = 0x04;
> - flags |= 0x02;
> + flags = BT_AD_FLAG_NO_BREDR;
> + flags |= BT_AD_FLAG_GENERAL;
> } else
> flags = 0x00;
>
> @@ -1065,7 +1065,8 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client)
> }
>
> /* Set Limited Discoverable if DiscoverableTimeout is set */
> - if (client->disc_to_id && !set_flags(client, 0x01)) {
> + if (client->disc_to_id &&
> + !set_flags(client, BT_AD_FLAG_LIMITED)) {
> error("Failed to set Limited Discoverable Flag");
> goto fail;
> }
> diff --git a/src/shared/ad.h b/src/shared/ad.h
> index a31df0fe5..19aa1d035 100644
> --- a/src/shared/ad.h
> +++ b/src/shared/ad.h
> @@ -71,6 +71,11 @@
> #define BT_AD_3D_INFO_DATA 0x3d
> #define BT_AD_MANUFACTURER_DATA 0xff
>
> +/* Low Energy Advertising Flags */
> +#define BT_AD_FLAG_LIMITED 0x01 /* Limited Discoverable */
> +#define BT_AD_FLAG_GENERAL 0x02 /* General Discoverable */
> +#define BT_AD_FLAG_NO_BREDR 0x04 /* BR/EDR not supported */
> +
> typedef void (*bt_ad_func_t)(void *data, void *user_data);
>
> struct bt_ad;
> --
> 2.25.3
Pushed.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-05 23:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 18:17 [PATCH BlueZ v2 1/2] shared/ad: Add defines for possible flags Luiz Augusto von Dentz
2020-06-05 18:17 ` [PATCH BlueZ v2 2/2] advertising: Fix resetting NO_BREDR flag Luiz Augusto von Dentz
2020-06-05 23:26 ` [PATCH BlueZ v2 1/2] shared/ad: Add defines for possible flags Luiz Augusto von Dentz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.