Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp561858lqp; Fri, 5 Apr 2024 02:01:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXFWkrpN/alvzI3z7HD8GgJESQXeTjJR9WjBFDKEca4R8BODRiqFvmyDHmIslJmV/thV+5NunpD+wBPKkWHNEQxxx9mxl1eLN5dU5/wNw== X-Google-Smtp-Source: AGHT+IHw5lwo/s8Gc3pSLQvGOzKo+McNKFXzAQxre17Erhjp9deJYdyQnpHOCV9Tv2n0kt4SHE8g X-Received: by 2002:a05:6214:230a:b0:698:7243:4843 with SMTP id gc10-20020a056214230a00b0069872434843mr812592qvb.56.1712307664951; Fri, 05 Apr 2024 02:01:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712307664; cv=pass; d=google.com; s=arc-20160816; b=YyYdBj6HxqX6I7/Hk6ahshasoIOu+FgZThvcfqxGcvn091a0IfhVJkumrM1zNPwLf4 i4c0ybPjnJYQcPgAOCvXUmVq9T0+iOuQlPIwbMdg/i0P3mhKVLa7q34ycBZh+9v31x8S pEW2aIZTXNgjpi+1biDofLzvH+0BFtkwNIMAq8YqNx4SnDNrn75OkvaE8G33KdM+Wcu3 VPa+5ON4LyWHkCX7MC0lJniMGvbidtXf1RerqAN8wT7ce547FRw21jEK1ZGurnSI4UWa FzTzlrINu/Japc6FDomf5GJ/rCh/DnP7Pqhj5X2pM8j+4fhNv+tFEfCOk0S+N8mBZwan 49vw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from :dkim-signature; bh=0MnoFkBFojLsjqmnkm38/26XR7+wIDzWrmZv25XN8z8=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=xyCb8mhWbxI+RwQ02LmVB6aGOzQyaWvP8zwA9IJFOc+E25cAPb6x8nLjQJz3aO5XyA 7NEC5gn4pdmlj0OPsIT4Midp4suz/hgkcrsJPPrON0OZeAoRH+uCNRZI229E6oBDn5WA CHOg2/8+UYZN0mhVG3pCqvwDRp1D4voKVdiO/Y8Il0npSWv59RjjIvGBBZEYpyo/ZdNj EBIb1tq99XaWu48eSzr5v6glzpR5LAyh3lx/fc+Akx5Sb2j7xa9/+bZMyj0OXt46JP5j SQ8JCYFZEJdqjgwkIEAd/hxhr4I9T7mQra0KtP7WdIjpnCNvA6wq5NpkODyYChCGf5l+ ziVg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=p906NtlW; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-bluetooth+bounces-3253-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c15-20020ad4430f000000b00699378bb7a0si1305965qvs.131.2024.04.05.02.01.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 02:01:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-3253-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=p906NtlW; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-bluetooth+bounces-3253-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A9E151C20FB4 for ; Fri, 5 Apr 2024 09:01:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 84C6F15F338; Fri, 5 Apr 2024 09:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="p906NtlW" X-Original-To: linux-bluetooth@vger.kernel.org Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 758C3611E for ; Fri, 5 Apr 2024 09:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712307659; cv=none; b=B7M+DC9kpPYmJnQWa8MFvX7KlrKOQVf3yusKSL/I/QO7609/xD9fElT3GuadizAvcLm+Ia9HuB5bj5sTn9+BlcRj2BFZhHuoYq6yMyKTF9h72pl3KSQ67cb5YbRN2lkHWy02U0bx7L9Z13SKW+2Q2UtxUnrw84ac6IJwxmF3/LI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712307659; c=relaxed/simple; bh=PDf98gx4S3mdROcdbjQGarOTtoZYCaL+6X6Wy3c8TNQ=; h=From:To:Subject:Date:Message-Id:MIME-Version:Content-Type; b=XUg78/XDp0Ho46E2FXcaByMQ7YaSZ7uVbdfugcx8KGhFSKXZmIHwu3q0cjLeM8W57/CS36fDXM8HrHn0Fneltg4n8+CVcK8WF6TaGL8+uLEdA9fGJQYPMam5c+3udAKKwGreTzGWRZxB58hZ+lEnhIzPyVAHzQ4hVMm646f7JUE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=p906NtlW; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712307655; bh=PDf98gx4S3mdROcdbjQGarOTtoZYCaL+6X6Wy3c8TNQ=; h=From:To:Subject:Date:From; b=p906NtlWjkP3TFqMvQo43aHYlL5TrPsBxUwOaUSvpAsUgI8MynA3R4KPCR7oCM44P IPGVfaUEn9gp4m1CmJMuynqAAtbqIKs/RtS9tsi3wVldXCGFR+qtgda2LazfuRN0fZ J/OacMTdOu2WlbrRu+qVq8fZz3E6wVd8LfF2X2IsI6cv1gGzaPf4EbFctz4HJG9SmM eV3m4QyEOUcihD5thOo+S5JccxwP0VGp8sF+ETq3aTx9uE662nymO/iQ8IApiXIwKf UCEFday3tofHaerg0NkBJ4dERuO4qAiBfaMKkpbMYTi+kR+IThoXO53aKIm8de6Tjg zXnIObLfoZf+g== Received: from fdanis-XPS-13-9370.. (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fdanis) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 8C33E3780EC6 for ; Fri, 5 Apr 2024 09:00:55 +0000 (UTC) From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] device: Fix airpods pairing Date: Fri, 5 Apr 2024 11:00:50 +0200 Message-Id: <20240405090050.1477187-1-frederic.danis@collabora.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Apple Airpods are discoverable and pairable in BREDR mode, but also advertise in unconnectable mode in LE with the same Public address, at the same time. As the pairing process uses the latest seen address, sometimes it uses the LE Public address to pair, which fails. This commit introduces the connectable state when selecting the bearer to use for a connection. The last_seen value is used only for connectable devices. --- src/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/device.c b/src/device.c index ac0b0e003..1d4b8ab36 100644 --- a/src/device.c +++ b/src/device.c @@ -2537,13 +2537,13 @@ static uint8_t select_conn_bearer(struct btd_device *dev) if (dev->bdaddr_type == BDADDR_LE_RANDOM) return dev->bdaddr_type; - if (dev->bredr_state.last_seen) { + if (dev->bredr_state.connectable && dev->bredr_state.last_seen) { bredr_last = current - dev->bredr_state.last_seen; if (bredr_last > SEEN_TRESHHOLD) bredr_last = NVAL_TIME; } - if (dev->le_state.last_seen) { + if (dev->le_state.connectable && dev->le_state.last_seen) { le_last = current - dev->le_state.last_seen; if (le_last > SEEN_TRESHHOLD) le_last = NVAL_TIME; -- 2.34.1