Skip to contentSkip to conversation

shared/ad: Add defines for possible flags

PATCH Superseded Luiz Augusto von Dentz 2 participants 3 messages Jun 5, 2020 Bluetooth drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 shared/ad: Add defines for possible flags

From: Luiz Augusto von Dentz <[email protected]>

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(-)
src/advertising.c +5 -4
index 829c481f6..4c91586c2 100644
@@ -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;
 		}
src/shared/ad.h +5 -0
index a31df0fe5..19aa1d035 100644
@@ -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;
Signature · 1 line
2.25.3
author maintainer
#1 lore raw

PATCH 2/2 advertising: Fix reseting NO_BREDR flag

From: Luiz Augusto von Dentz <[email protected]>

When setting BT_AD_FLAG_LIMITED it was actually overwritting 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(-)
src/advertising.c +10 -6
index 4c91586c2..076d591b6 100644
@@ -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))
Signature · 1 line
2.25.3
#2 lore raw

RE: [BlueZ,2/2] advertising: Fix reseting NO_BREDR flag

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning.

Test Result:
checkpatch Failed

Outputs:
WARNING:TYPO_SPELLING: 'reseting' may be misspelled - perhaps 'resetting'? #4:
Subject: [PATCH] advertising: Fix reseting NO_BREDR flag

WARNING:TYPO_SPELLING: 'overwritting' may be misspelled - perhaps 'overwriting'? #6:
When setting BT_AD_FLAG_LIMITED it was actually overwritting

- total: 0 errors, 2 warnings, 28 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

Your patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

---
Regards,
Linux Bluetooth