Skip to contentSkip to conversation

adapter: Fix airpod device pair fail

PATCH NAK [email protected] 3 participants 3 messages Jan 3, 2024 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 adapter: Fix airpod device pair fail

From: Clancy Shang <[email protected]>

Airpod is performing inquiry scans in BR/EDR and advertising in an unconnectable mode with the same public address at the same time. with this feature, when found airpod device, set the bredr support, fix it pairs fail bug.

---
 src/adapter.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
src/adapter.c +25 -0
index 022390f0d..71f7ed86d 100644
@@ -7066,6 +7066,24 @@ static void adapter_msd_notify(struct btd_adapter *adapter,
 	}
 }
 
+#define APPLE_INC_VENDOR_ID 0x004c
+
+static bool eir_msd_is_apple_inc(GSList *msd_list)
+{
+	GSList *msd_l, *msd_next;
+
+	for (msd_l = msd_list; msd_l != NULL; msd_l = msd_next) {
+		const struct eir_msd *msd = msd_l->data;
+
+		msd_next = g_slist_next(msd_l);
+
+		if (msd->company == APPLE_INC_VENDOR_ID)
+			return true;
+	}
+
+	return false;
+}
+
 static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data,
 								int8_t rssi)
 {
@@ -7281,6 +7299,13 @@ void btd_adapter_device_found(struct btd_adapter *adapter,
 		device_update_last_seen(dev, BDADDR_BREDR, !not_connectable);
 	}
 
+	if (eir_msd_is_apple_inc(eir_data.msd_list) &&
+					(not_connectable == true) &&
+					(bdaddr_type == BDADDR_LE_PUBLIC)) {
+		device_set_bredr_support(dev);
+		device_update_last_seen(dev, BDADDR_BREDR, true);
+	}
+
 	if (eir_data.name != NULL && eir_data.name_complete)
 		device_store_cached_name(dev, eir_data.name);
 
Signature · 1 line
2.25.1
#1 lore raw

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=814046

---Test result---

Test Summary:

CheckPatch                    PASS      0.50 seconds
GitLint                       PASS      0.33 seconds
BuildEll                      PASS      23.76 seconds
BluezMake                     PASS      687.48 seconds
MakeCheck                     PASS      12.14 seconds
MakeDistcheck                 PASS      158.97 seconds
CheckValgrind                 PASS      221.26 seconds
CheckSmatch                   PASS      325.52 seconds
bluezmakeextell               PASS      105.98 seconds
IncrementalBuild              PASS      643.72 seconds
ScanBuild                     PASS      933.53 seconds

---
Regards,
Linux Bluetooth

maintainer NAK
#2 lore raw
In reply to [email protected]

Hi,

Quoted 43 lines · On Wed, Jan 3, 2024 at 5:14 AM <[email protected]> wrote:

From: Clancy Shang <[email protected]>

Airpod is performing inquiry scans in BR/EDR and advertising in an unconnectable mode with the same public address at the same time. with this feature, when found airpod device, set the bredr support, fix it pairs fail bug.

---
 src/adapter.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
src/adapter.c +18 -0
index 022390f0d..71f7ed86d 100644
@@ -7066,6 +7066,24 @@ static void adapter_msd_notify(struct btd_adapter *adapter,
        }
 }
 
+#define APPLE_INC_VENDOR_ID 0x004c
+
+static bool eir_msd_is_apple_inc(GSList *msd_list)
+{
+       GSList *msd_l, *msd_next;
+
+       for (msd_l = msd_list; msd_l != NULL; msd_l = msd_next) {
+               const struct eir_msd *msd = msd_l->data;
+
+               msd_next = g_slist_next(msd_l);
+
+               if (msd->company == APPLE_INC_VENDOR_ID)
+                       return true;
+       }
+
+       return false;
+}
+
 static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data,
                                                                int8_t rssi)
 {

src/adapter.c void btd_adapter_device_found(struct btd_adapter *adapter, · line 7307

Quoted 9 lines
src/adapter.c +6 -0
@@ -7281,6 +7299,13 @@ void btd_adapter_device_found(struct btd_adapter *adapter,
                device_update_last_seen(dev, BDADDR_BREDR, !not_connectable);
        }
 
+       if (eir_msd_is_apple_inc(eir_data.msd_list) &&
+                                       (not_connectable == true) &&
+                                       (bdaddr_type == BDADDR_LE_PUBLIC)) {
+               device_set_bredr_support(dev);
+               device_update_last_seen(dev, BDADDR_BREDR, true);
+       }

NAK, we are not going to introduce device specific policy hardcoded in the code like this, if you really want to update last seen then you either need a dedicated driver that handles Apple UUID on its own plugin, or make the policy plugin register a driver for it, that said there is a flag for that indicates BR/EDR is supported not sure why apple it no advertising using it?

Quoted 7 lines
src/adapter.c +0 -1
        if (eir_data.name != NULL && eir_data.name_complete)
                device_store_cached_name(dev, eir_data.name);
 
--

2.25.1

Signature · 1 line
Luiz Augusto von Dentz