Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1077727rwb; Fri, 28 Jul 2023 04:34:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlHuaQL6yQhwttXUtbo9s9UvCPjZ0/Nd4bbhCPiuFzvs5T4/R7gBqpAMgV6HiKIBQE7EnKwm X-Received: by 2002:a17:902:e807:b0:1b9:e091:8037 with SMTP id u7-20020a170902e80700b001b9e0918037mr1945774plg.30.1690544046729; Fri, 28 Jul 2023 04:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690544046; cv=none; d=google.com; s=arc-20160816; b=bharS/3gYlNPasll7royp6zjmW17InbOHpHiesZWT64D1nPJ12JY4mPfe054rlNBjM Pxi0SxmMB8yj6sY4zBSo6MC82pk/Uh+9xrbq15hfRGxmcg3y288v+D41oxZR7ont1DAi KG0K86h5dt3KFRQI+XmBy90uFa/cE04q4qlHnh94wh9bHST3487fwNYYuCa8fK10e/6j zgKcownsnmkhZsbGIFpkOvcNBhDler+pHq3/OHr6UImawzUh6piaAUswt9NoUfKDpVX0 Hcf6AZNJ7j5pb0zbRZ+Lpq5XrQOWkQ9pk4jjwWWHa0fmHvEzqHB1BU0aw9Vc1CLHiORt A2QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9LTlNM0U4GQn+qLoV44uEkUkueaNxcTTS45n3Q1KHm4=; fh=Jg5b3SlU0kriz7dG9TxlX0lcLkpuhdKAkKJU/Cg3tjc=; b=eVEA5BEPn9PnMJT2XJG/ymLpCsxRdGyDcyz6qewqZEcP88CDccRpzYqoSBU+wiqtff DMFfenyZsXfsVjeeDTokGzVWi6Br3zRBdGiEQRRA9LMOcNtjBNdv072ZE3WoDNQ7imdD r4YF06buKr7Cln+VNdJ5ScRCpCde1GatB5O3mripXxz3jt8vDvE6PqcIVPF2eSi47vHu ol6z1QUhqRzcQForawUH6p+/pFmLzc/UvFGPnqakGI3fO1ZxPSOX78xP7vKB2OcvUajN 9KPRqq5cqtCzpx2fkw+oLL1+rg1pZOs6XWUYZ3fLLgeQPEmRLLumgNLyg5HE+Xf85Ppa pziw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@streamunlimited.com header.s=google header.b="MoQZ7/In"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=streamunlimited.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a16-20020a170902ecd000b001bbaaf979a4si3057912plh.360.2023.07.28.04.33.38; Fri, 28 Jul 2023 04:34:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@streamunlimited.com header.s=google header.b="MoQZ7/In"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=streamunlimited.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236068AbjG1K4W (ORCPT + 99 others); Fri, 28 Jul 2023 06:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236066AbjG1K4V (ORCPT ); Fri, 28 Jul 2023 06:56:21 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AD231BC6 for ; Fri, 28 Jul 2023 03:56:20 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-991c786369cso274408666b.1 for ; Fri, 28 Jul 2023 03:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1690541778; x=1691146578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9LTlNM0U4GQn+qLoV44uEkUkueaNxcTTS45n3Q1KHm4=; b=MoQZ7/In+YXAIXkLppkUOXd5d4xBRx/iprSBU4S+wCgZ8PWr4FYv/J+EJwugT7xpcX 6HX0hc8Q73IEaBUEYGl0G0kkjGuxfjTiUww9tXoJ4WzRyBZXhh7+ow/Bp0l+bbOFmZAJ bx7OgNUD4OV1wrkui3CKma+z+7n6CMfAB7XQw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690541778; x=1691146578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9LTlNM0U4GQn+qLoV44uEkUkueaNxcTTS45n3Q1KHm4=; b=Ebv3WoPdjg2/Jk4djBr8BuBmYxNWLQo4mRqGLiaggcOa3Dn5aPEe07bTZ1RNWBWQK4 y8r8HoB3eYAUf+466lf/9SbQSTaxc4m5KWXmf4w4JKzt6Wx9tZrtYSCOIliixsZ1d7f9 IJS+amy4yivZsKbHgePdLZq7lYcG71rov9YMJ/aSQFsC2+h525/GbmsLbJn8zh8uUFNC aXd6n/J5eSYnwg875qvi0FaCShvl4vc6wL0lJLP/Dhc/GN/PkmoY/5EC6JCLTVv/WkUT vymqWQvDX2mHjxN5DkgFeUU6W0NwRFFK4EnD6xwKQjGk3fypekyaXJvD/fVZxVRpMS/8 XUpg== X-Gm-Message-State: ABy/qLbbAyl1eQZMEpXQq8pOVBkVEVE06dHaV3dlE099QFA7Us6mqj1O w6yljeqZRFfhFbPU5ZwVvzXyJgLAf+czMJvCGVM= X-Received: by 2002:a17:906:189:b0:993:fba5:cdef with SMTP id 9-20020a170906018900b00993fba5cdefmr1469785ejb.8.1690541778206; Fri, 28 Jul 2023 03:56:18 -0700 (PDT) Received: from smi-ubuntu.sueba ([2a01:390:0:101:353d:c2fa:e0df:3251]) by smtp.gmail.com with ESMTPSA id kk9-20020a170907766900b00982cfe1fe5dsm1925370ejc.65.2023.07.28.03.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 03:56:17 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ] advertising: Fix peripheral adverts when Discoverable = false Date: Fri, 28 Jul 2023 12:56:04 +0200 Message-Id: <20230728105604.948472-1-simon.mikuda@streamunlimited.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230728085713.683655-1-simon.mikuda@streamunlimited.com> References: <20230728085713.683655-1-simon.mikuda@streamunlimited.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org There is a problem with this configuration: Type = peripheral, Discoverable = false and Adapter is discoverable In this state device will start advertise discoverable advertisements even when user wanted non-discoverable advertisements. This change will add empty Flags when "Discoverable" parameter is set. --- src/advertising.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/advertising.c b/src/advertising.c index d959bf38f..2c9a5a443 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -727,11 +727,6 @@ fail: static bool set_flags(struct btd_adv_client *client, uint8_t flags) { - if (!flags) { - bt_ad_clear_flags(client->data); - return true; - } - /* Set BR/EDR Not Supported for LE only */ if (!btd_adapter_get_bredr(client->manager->adapter)) flags |= BT_AD_FLAG_NO_BREDR; @@ -1447,7 +1442,8 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client) } } - if (bt_ad_has_flags(client->data)) { + if (bt_ad_get_flags(client->data) & + (BT_AD_FLAG_GENERAL | BT_AD_FLAG_LIMITED)) { /* BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part C * page 2042: * A device in the broadcast mode shall not set the -- 2.34.1