2023-12-22 05:45:42

by 15013537245

[permalink] [raw]
Subject: [PATCH] [BlueZ] adapter: Fix airpod device pair fail

From: Clancy Shang <[email protected]>

Airpod is performing inquiry scans in BR/EDR and advertising in a
unconnectabl mode whit the same public address at the same time.
with this featrue, when found airpod device, set the bredr support,
fix it pair fail bug.

Signed-off-by: Clancy Shang <[email protected]>
---
src/adapter.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 022390f0d..488355e9c 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -7066,6 +7066,25 @@ 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 +7300,12 @@ 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);

--
2.25.1



2023-12-22 07:11:17

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ] adapter: Fix airpod device pair fail

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

---Test result---

Test Summary:
CheckPatch PASS 0.28 seconds
GitLint PASS 0.19 seconds
BuildEll PASS 23.90 seconds
BluezMake PASS 734.76 seconds
MakeCheck PASS 11.50 seconds
MakeDistcheck PASS 159.71 seconds
CheckValgrind PASS 220.13 seconds
CheckSmatch PASS 324.61 seconds
bluezmakeextell PASS 106.00 seconds
IncrementalBuild PASS 677.70 seconds
ScanBuild PASS 926.75 seconds



---
Regards,
Linux Bluetooth

2023-12-22 12:27:04

by Paul Menzel

[permalink] [raw]
Subject: Re: [PATCH] [BlueZ] adapter: Fix airpod device pair fail

Dear Clancy,


Thank you for your patch. Some nits below.

Am 22.12.23 um 06:45 schrieb [email protected]:
> From: Clancy Shang <[email protected]>
>
> Airpod is performing inquiry scans in BR/EDR and advertising in a
> unconnectabl mode whit the same public address at the same time.

a*n* unconnectabl*e* mode w*ith*

> with this featrue, when found airpod device, set the bredr support,

feat*ur*e

> fix it pair fail bug.

Do the Airpods follow the Bluetooth specification, or do they violate
it, and need a workaround?

>
> Signed-off-by: Clancy Shang <[email protected]>
> ---
> src/adapter.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 022390f0d..488355e9c 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -7066,6 +7066,25 @@ 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) {
> +

The blank line seems unnecessary.

> + 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 +7300,12 @@ 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)) {

No idea, if there is a rule, but other instances put the && on the line
above, and align the condition with the one in the first line.

> + 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);
>


Kind regards,

Paul