From patchwork Wed Mar 29 21:09:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13193226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FC75C74A5B for ; Wed, 29 Mar 2023 21:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229941AbjC2VJz (ORCPT ); Wed, 29 Mar 2023 17:09:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjC2VJg (ORCPT ); Wed, 29 Mar 2023 17:09:36 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C0439F for ; Wed, 29 Mar 2023 14:09:36 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id k17so7438124iob.1 for ; Wed, 29 Mar 2023 14:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680124175; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=e5gAEQBgCAmrDCYhK9Tm1iY+TdGfsp+0qEGPnEFs/eo=; b=o9zQ3zbQu2+wfGBoEvpj4OgbeUwLYRa4kIEAW6qrc6KWnZ+bnlepBwJi+KPnD9brW8 W6HctAa1qNHty+ikphF+DQNf4O5Tbs7ADBrHpySealG1ASGc/AQBK5f071Jentf0Qj0P Sjc3Vb6efTdgiHlC8mc3gugxNHrZEZtdUJXdtiuGvuCN+QRWaYwxiWhc9NbZnPQYzrxq zbUPG+lwCZl1ErhgZAJwcqEwZLhVGTMbzWmasdfUuAxXOQNjkq8yQ1J7trkpWXOKxYfT Yyq3YYvNwva5pLxxQVJmKBJKwGAEdOeg6bv3jnMGATlspbhIXQjkLSTyvYqPc9W+sF8E O7Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680124175; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=e5gAEQBgCAmrDCYhK9Tm1iY+TdGfsp+0qEGPnEFs/eo=; b=sMU2tNsLggunXrA5SLwhyK9TAyI0zBFUSLj93SWPHIJu+Ei74WVU+siwpj4GFFTW5R dUoNKzLmI9VUpYAqJJSV9uN+ue2vTgLpUlmI6YJqG+OqyaPmxB16tab0EZjuYgdinLVI GI1Pp98z2uUTimXT4VztK3Nq8DHDaXmrcO/YlE7BZr15u5ty7TM4g+Ca46ha6OEuZX2K HobnAoT7tBCLCwYNcVviPXLpwglNsToe/u4G123cq9fXZV1J3TpCcRO9ozuEd3kDoYL2 Ac7KEoMuy9NGNwBAYddZdc8I3Ye9jV6bLFHHsawxR+SSv3sK4q8YzDBWGkDHvVBASnsY y0OA== X-Gm-Message-State: AO0yUKXHuHCaIqz0yM8pwHK87xLQPtW2uyRyibh4hi0Q/CTxnNZYZT0M nTZgJsDzE9OFkZtX61vx4qNOpdiIb3hzgA== X-Google-Smtp-Source: AK7set8gNO9GN5i4rCRUjnzPJUVGnCpJ3CLOe8v7IFXIgxgI2ZYL6CYizlvJhgQCMKgcJgwyYbV1EQ== X-Received: by 2002:a5d:9e53:0:b0:753:13ec:4ba with SMTP id i19-20020a5d9e53000000b0075313ec04bamr16759715ioi.4.1680124174832; Wed, 29 Mar 2023 14:09:34 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id 71-20020a020a4a000000b004040f9898ebsm11009631jaw.148.2023.03.29.14.09.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 14:09:34 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/2] bap: Mark devices to auto-connect Date: Wed, 29 Mar 2023 14:09:31 -0700 Message-Id: <20230329210932.537019-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This makes devices with BAP support to auto-connect once they start advertising. --- profiles/audio/bap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index cfe6854663fa..464f365a93bc 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1352,6 +1352,7 @@ static struct btd_profile bap_profile = { .device_remove = bap_remove, .accept = bap_accept, .disconnect = bap_disconnect, + .auto_connect = true, }; static unsigned int bap_id = 0; From patchwork Wed Mar 29 21:09:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13193225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D6DFC6FD18 for ; Wed, 29 Mar 2023 21:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229677AbjC2VJy (ORCPT ); Wed, 29 Mar 2023 17:09:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbjC2VJh (ORCPT ); Wed, 29 Mar 2023 17:09:37 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC198A2 for ; Wed, 29 Mar 2023 14:09:36 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id k17so7438154iob.1 for ; Wed, 29 Mar 2023 14:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680124176; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Uv/Rss/Bp/HiNBtdFao8ULnALtaK28uPE6m0zgLq7l8=; b=XsUffNeQGTIpqfksaXhy84s3RCJo0woQgap80A7e5t5+ZM9mNUl6PgTM747C5RPZNi tavfK1BVuY9k1GTYmXXeeIMGlh6NL1np2MP4p6dR5ZusjqUTMFpQGtn8J+agbQWyYMI0 FgmqFjBTTU5bxyF5HzoU2fflzxmRaYlaqwCx0y4Oc++SjTPmD6UBB2JTppTh/Up7YJ3J LqePi7dVfzmrZM+m9Jz2eFdi20qdsEy6bZIuId4aEkMP4q8ipO2x3baUHARlLqtJozQ7 TWbR7rZmrMZcAaL2EOy5vkl5Q7z7bM2zAVFMubsWY1tKOoAQK0Pvexlk+Rajs+9NWw3l YBdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680124176; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uv/Rss/Bp/HiNBtdFao8ULnALtaK28uPE6m0zgLq7l8=; b=No5iM0xYu9XZ/OgL3ZqtKUeVKV+YThGFa0RzekRhvdGeIO3741BYQ8L/uE5pNhCeRI PBeDTaNV2Gd+d1Nj+abNYD/1cpGajaILnIz6uzHUWnFH5oJcyJOKeGYF+j9smWANUQBF jYpeYZmJEIKPx7bSWMSORrgWKJHu1ELVzAgHKU0k2FfS6pRq9FCThV+YPuowPXbWFud1 CsL6Fyryu+0YqeVJ/SoGg5Fdya5Wttj4RAWys0qnMglIFmp/rCwIJmtX2yrKK6xnN/oB BmSkx0UuKPdfcz/cZORno64/HJi7iNtahZi8/35ZkoCL/ay25x39E9yYo70+q8BiYMnV e6qQ== X-Gm-Message-State: AAQBX9fDKWoQHiIaSK1yA/6i6ec49TwBfFcfq+hrYw2DY0WvMWQ9qD83 4uvwI8NH2+AnT4DcyRfZ7K5mxSKela6NUQ== X-Google-Smtp-Source: AKy350bD8nBlUsLeAXchklNMZFK4CsPA/1RIOJDf8CBAM3UniMNNPTh+K2GE3VMhSHrAYtqlxvEypQ== X-Received: by 2002:a6b:5d10:0:b0:752:6f1b:63a2 with SMTP id r16-20020a6b5d10000000b007526f1b63a2mr2092143iob.3.1680124176154; Wed, 29 Mar 2023 14:09:36 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id 71-20020a020a4a000000b004040f9898ebsm11009631jaw.148.2023.03.29.14.09.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 14:09:35 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 2/2] device: Fix not setting initiator flag when auto-connecting Date: Wed, 29 Mar 2023 14:09:32 -0700 Message-Id: <20230329210932.537019-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230329210932.537019-1-luiz.dentz@gmail.com> References: <20230329210932.537019-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz If the device is marked as auto-connect the kernel may initiate the connection spontaneously causing new connections to not have set the state->initiator flag properly. --- src/device.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/device.c b/src/device.c index f31f2a097e07..c538742b683f 100644 --- a/src/device.c +++ b/src/device.c @@ -312,9 +312,16 @@ static struct bearer_state *get_state(struct btd_device *dev, bool btd_device_is_initiator(struct btd_device *dev) { - if (dev->le_state.connected) + if (dev->le_state.connected) { + /* Mark as initiator if not set yet and auto-connect flag is + * set and LTK key is for a peripheral. + */ + if (!dev->le_state.initiator && dev->auto_connect && + dev->ltk && !dev->ltk->central) + dev->le_state.initiator = true; + return dev->le_state.initiator; - if (dev->bredr_state.connected) + } if (dev->bredr_state.connected) return dev->bredr_state.initiator; return dev->att_io ? true : false;