Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/3] mgmt-api: Update Device Found Event documentation
@ 2023-06-20 20:40 Luiz Augusto von Dentz
  2023-06-20 20:40 ` [PATCH BlueZ 2/3] monitor: Add missing flags to MGMT Device Found Event Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2023-06-20 20:40 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This updates Device Found Event documentation to mention the new flag
introduced to track when the event is generated due a interleaved Scan
Response that couldn't be merged.
---
 doc/mgmt-api.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index c7191a028238..59e61d361dc2 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -4399,6 +4399,7 @@ Device Found Event
 		2	Not Connectable
 		3	Reserved (not in use)
 		4	Name Request Failed
+		5	Scan Response
 
 	For the RSSI field a value of 127 indicates that the RSSI is
 	not available. That can happen with Bluetooth 1.1 and earlier
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 2/3] monitor: Add missing flags to MGMT Device Found Event
  2023-06-20 20:40 [PATCH BlueZ 1/3] mgmt-api: Update Device Found Event documentation Luiz Augusto von Dentz
@ 2023-06-20 20:40 ` Luiz Augusto von Dentz
  2023-06-20 20:40 ` [PATCH BlueZ 3/3] adapter: Handle Device Found Event with Scan Response flag Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2023-06-20 20:40 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds the missing flags to MGMT Device Found Event so they can be
decoded properly.
---
 monitor/packet.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/monitor/packet.c b/monitor/packet.c
index 6d73e5abfcbc..4473fda29a46 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -12858,6 +12858,8 @@ static const struct bitfield_data mgmt_device_flags_table[] = {
 	{  1, "Legacy Pairing"			},
 	{  2, "Not Connectable"			},
 	{  3, "Connection Locally Initiated"	},
+	{  4, "Name Request Failed"		},
+	{  5, "Scan Response"			},
 	{ }
 };
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 3/3] adapter: Handle Device Found Event with Scan Response flag
  2023-06-20 20:40 [PATCH BlueZ 1/3] mgmt-api: Update Device Found Event documentation Luiz Augusto von Dentz
  2023-06-20 20:40 ` [PATCH BlueZ 2/3] monitor: Add missing flags to MGMT Device Found Event Luiz Augusto von Dentz
@ 2023-06-20 20:40 ` Luiz Augusto von Dentz
  2023-06-20 22:31 ` [BlueZ,1/3] mgmt-api: Update Device Found Event documentation bluez.test.bot
  2023-06-21 22:10 ` [PATCH BlueZ 1/3] " patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2023-06-20 20:40 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This handles recently introduced Scan Response flag since that
shouldn't affect connectable flag the device would be considered
connectable but it shall not create a new device by itself.
---
 lib/mgmt.h        |  1 +
 src/adapter.c     | 44 +++++++++++++++++++++++++-------------------
 src/adapter.h     |  8 +++-----
 src/adv_monitor.c | 17 +++--------------
 4 files changed, 32 insertions(+), 38 deletions(-)

diff --git a/lib/mgmt.h b/lib/mgmt.h
index c3c9052320bb..062fa027127c 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -902,6 +902,7 @@ struct mgmt_ev_auth_failed {
 #define MGMT_DEV_FOUND_NOT_CONNECTABLE		BIT(2)
 #define MGMT_DEV_FOUND_INITIATED_CONN		BIT(3)
 #define MGMT_DEV_FOUND_NAME_REQUEST_FAILED	BIT(4)
+#define MGMT_DEV_FOUND_SCAN_RSP			BIT(5)
 
 #define MGMT_EV_DEVICE_FOUND		0x0012
 struct mgmt_ev_device_found {
diff --git a/src/adapter.c b/src/adapter.c
index 74ed52468b81..2679d4302307 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -7088,12 +7088,10 @@ static bool device_is_discoverable(struct btd_adapter *adapter,
 	return discoverable;
 }
 
-void btd_adapter_update_found_device(struct btd_adapter *adapter,
+void btd_adapter_device_found(struct btd_adapter *adapter,
 					const bdaddr_t *bdaddr,
 					uint8_t bdaddr_type, int8_t rssi,
-					bool confirm, bool legacy,
-					bool not_connectable,
-					bool name_resolve_failed,
+					uint32_t flags,
 					const uint8_t *data, uint8_t data_len,
 					bool monitoring)
 {
@@ -7102,9 +7100,20 @@ void btd_adapter_update_found_device(struct btd_adapter *adapter,
 	struct eir_data eir_data;
 	bool name_known, discoverable;
 	char addr[18];
+	bool confirm;
+	bool legacy;
+	bool not_connectable;
+	bool name_resolve_failed;
+	bool scan_rsp;
 	bool duplicate = false;
 	struct queue *matched_monitors = NULL;
 
+	confirm = (flags & MGMT_DEV_FOUND_CONFIRM_NAME);
+	legacy = (flags & MGMT_DEV_FOUND_LEGACY_PAIRING);
+	not_connectable = (flags & MGMT_DEV_FOUND_NOT_CONNECTABLE);
+	name_resolve_failed = (flags & MGMT_DEV_FOUND_NAME_REQUEST_FAILED);
+	scan_rsp = (flags & MGMT_DEV_FOUND_SCAN_RSP);
+
 	if (!btd_adv_monitor_offload_enabled(adapter->adv_monitor_manager) ||
 				(MGMT_VERSION(mgmt_version, mgmt_revision) <
 							MGMT_VERSION(1, 22))) {
@@ -7137,6 +7146,14 @@ void btd_adapter_update_found_device(struct btd_adapter *adapter,
 
 	dev = btd_adapter_find_device(adapter, bdaddr, bdaddr_type);
 	if (!dev) {
+		/* In case of being just a scan response don't attempt to create
+		 * the device.
+		 */
+		if (scan_rsp) {
+			eir_data_free(&eir_data);
+			return;
+		}
+
 		if (!discoverable && !monitoring && !eir_data.rsi) {
 			eir_data_free(&eir_data);
 			return;
@@ -7317,10 +7334,6 @@ static void device_found_callback(uint16_t index, uint16_t length,
 	const uint8_t *eir;
 	uint16_t eir_len;
 	uint32_t flags;
-	bool confirm_name;
-	bool legacy;
-	bool not_connectable;
-	bool name_resolve_failed;
 	char addr[18];
 
 	if (length < sizeof(*ev)) {
@@ -7342,22 +7355,15 @@ static void device_found_callback(uint16_t index, uint16_t length,
 	else
 		eir = ev->eir;
 
-	flags = btohl(ev->flags);
+	flags = le32_to_cpu(ev->flags);
 
 	ba2str(&ev->addr.bdaddr, addr);
 	DBG("hci%u addr %s, rssi %d flags 0x%04x eir_len %u",
 			index, addr, ev->rssi, flags, eir_len);
 
-	confirm_name = (flags & MGMT_DEV_FOUND_CONFIRM_NAME);
-	legacy = (flags & MGMT_DEV_FOUND_LEGACY_PAIRING);
-	not_connectable = (flags & MGMT_DEV_FOUND_NOT_CONNECTABLE);
-	name_resolve_failed = (flags & MGMT_DEV_FOUND_NAME_REQUEST_FAILED);
-
-	btd_adapter_update_found_device(adapter, &ev->addr.bdaddr,
-					ev->addr.type, ev->rssi, confirm_name,
-					legacy, not_connectable,
-					name_resolve_failed, eir, eir_len,
-					false);
+	btd_adapter_device_found(adapter, &ev->addr.bdaddr,
+					ev->addr.type, ev->rssi, flags,
+					eir, eir_len, false);
 }
 
 struct agent *adapter_get_agent(struct btd_adapter *adapter)
diff --git a/src/adapter.h b/src/adapter.h
index 32e49a933b13..ca96c1f6575f 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -88,14 +88,12 @@ struct btd_device *btd_adapter_find_device_by_path(struct btd_adapter *adapter,
 						   const char *path);
 struct btd_device *btd_adapter_find_device_by_fd(int fd);
 
-void btd_adapter_update_found_device(struct btd_adapter *adapter,
+void btd_adapter_device_found(struct btd_adapter *adapter,
 					const bdaddr_t *bdaddr,
 					uint8_t bdaddr_type, int8_t rssi,
-					bool confirm, bool legacy,
-					bool not_connectable,
-					bool name_resolve_failed,
+					uint32_t flags,
 					const uint8_t *data, uint8_t data_len,
-					bool monitored);
+					bool monitoring);
 
 const char *adapter_get_path(struct btd_adapter *adapter);
 const bdaddr_t *btd_adapter_get_address(struct btd_adapter *adapter);
diff --git a/src/adv_monitor.c b/src/adv_monitor.c
index 33f4d9619c1c..cb38916fc28b 100644
--- a/src/adv_monitor.c
+++ b/src/adv_monitor.c
@@ -1583,10 +1583,6 @@ static void adv_monitor_device_found_callback(uint16_t index, uint16_t length,
 	const uint8_t *ad_data = NULL;
 	uint16_t ad_data_len;
 	uint32_t flags;
-	bool confirm_name;
-	bool legacy;
-	bool not_connectable;
-	bool name_resolve_failed;
 	char addr[18];
 
 	if (length < sizeof(*ev)) {
@@ -1605,21 +1601,14 @@ static void adv_monitor_device_found_callback(uint16_t index, uint16_t length,
 	if (ad_data_len > 0)
 		ad_data = ev->ad_data;
 
-	flags = btohl(ev->flags);
+	flags = le32_to_cpu(ev->flags);
 
 	ba2str(&ev->addr.bdaddr, addr);
 	DBG("hci%u addr %s, rssi %d flags 0x%04x ad_data_len %u",
 			index, addr, ev->rssi, flags, ad_data_len);
 
-	confirm_name = (flags & MGMT_DEV_FOUND_CONFIRM_NAME);
-	legacy = (flags & MGMT_DEV_FOUND_LEGACY_PAIRING);
-	not_connectable = (flags & MGMT_DEV_FOUND_NOT_CONNECTABLE);
-	name_resolve_failed = (flags & MGMT_DEV_FOUND_NAME_REQUEST_FAILED);
-
-	btd_adapter_update_found_device(adapter, &ev->addr.bdaddr,
-					ev->addr.type, ev->rssi, confirm_name,
-					legacy, not_connectable,
-					name_resolve_failed, ad_data,
+	btd_adapter_device_found(adapter, &ev->addr.bdaddr,
+					ev->addr.type, ev->rssi, flags, ad_data,
 					ad_data_len, true);
 
 	if (handle) {
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [BlueZ,1/3] mgmt-api: Update Device Found Event documentation
  2023-06-20 20:40 [PATCH BlueZ 1/3] mgmt-api: Update Device Found Event documentation Luiz Augusto von Dentz
  2023-06-20 20:40 ` [PATCH BlueZ 2/3] monitor: Add missing flags to MGMT Device Found Event Luiz Augusto von Dentz
  2023-06-20 20:40 ` [PATCH BlueZ 3/3] adapter: Handle Device Found Event with Scan Response flag Luiz Augusto von Dentz
@ 2023-06-20 22:31 ` bluez.test.bot
  2023-06-21 22:10 ` [PATCH BlueZ 1/3] " patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2023-06-20 22:31 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1387 bytes --]

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.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=758865

---Test result---

Test Summary:
CheckPatch                    PASS      1.48 seconds
GitLint                       PASS      1.03 seconds
BuildEll                      PASS      26.57 seconds
BluezMake                     PASS      790.04 seconds
MakeCheck                     PASS      12.17 seconds
MakeDistcheck                 PASS      155.14 seconds
CheckValgrind                 PASS      248.12 seconds
CheckSmatch                   WARNING   335.64 seconds
bluezmakeextell               PASS      101.25 seconds
IncrementalBuild              PASS      1960.96 seconds
ScanBuild                     PASS      1008.06 seconds

Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
monitor/packet.c: note: in included file:monitor/display.h:82:26: warning: Variable length array is used.monitor/packet.c:1832:26: warning: Variable length array is used.monitor/packet.c: note: in included file:monitor/bt.h:3552:52: warning: array of flexible structuresmonitor/bt.h:3540:40: warning: array of flexible structures


---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ 1/3] mgmt-api: Update Device Found Event documentation
  2023-06-20 20:40 [PATCH BlueZ 1/3] mgmt-api: Update Device Found Event documentation Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2023-06-20 22:31 ` [BlueZ,1/3] mgmt-api: Update Device Found Event documentation bluez.test.bot
@ 2023-06-21 22:10 ` patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2023-06-21 22:10 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 20 Jun 2023 13:40:51 -0700 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This updates Device Found Event documentation to mention the new flag
> introduced to track when the event is generated due a interleaved Scan
> Response that couldn't be merged.
> ---
>  doc/mgmt-api.txt | 1 +
>  1 file changed, 1 insertion(+)

Here is the summary with links:
  - [BlueZ,1/3] mgmt-api: Update Device Found Event documentation
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=98383b917a43
  - [BlueZ,2/3] monitor: Add missing flags to MGMT Device Found Event
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=741a04aba0c3
  - [BlueZ,3/3] adapter: Handle Device Found Event with Scan Response flag
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c8235156c31b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-21 22:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-20 20:40 [PATCH BlueZ 1/3] mgmt-api: Update Device Found Event documentation Luiz Augusto von Dentz
2023-06-20 20:40 ` [PATCH BlueZ 2/3] monitor: Add missing flags to MGMT Device Found Event Luiz Augusto von Dentz
2023-06-20 20:40 ` [PATCH BlueZ 3/3] adapter: Handle Device Found Event with Scan Response flag Luiz Augusto von Dentz
2023-06-20 22:31 ` [BlueZ,1/3] mgmt-api: Update Device Found Event documentation bluez.test.bot
2023-06-21 22:10 ` [PATCH BlueZ 1/3] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox