From patchwork Fri Jun 5 17:48:24 2020 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: 11590309 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9981D913 for ; Fri, 5 Jun 2020 17:48:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C8DE207D8 for ; Fri, 5 Jun 2020 17:48:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W+jlhwt/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727024AbgFERs3 (ORCPT ); Fri, 5 Jun 2020 13:48:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726959AbgFERs3 (ORCPT ); Fri, 5 Jun 2020 13:48:29 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBEE3C08C5C2 for ; Fri, 5 Jun 2020 10:48:28 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d8so815158plo.12 for ; Fri, 05 Jun 2020 10:48:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=9wnUBnIGiHnmupdesTjLijqyj8kpX2av7C0AkM6kHts=; b=W+jlhwt/R96V7vzukFGj082JvPvOIjRRys5jmwV7SWkrw4+zcyseWOgq7HAQsdDNAS 1TU3+qUbfy2eYq8MnYrrRVsr4Df2SUyYN+EBUQ7eowGdAe1KtDaVbbSeyczJZY1HzzYF prJt1UZ1ZrOVdP6f4Zxpo/j09zWmCchSasnjesbYZaSoYhfPAeaXpgryOI+7zKiZRbos /JjpgWZH0+dmA4eP6aptbSRQJ5AEQkgWalA+EI05y/0lkgk+eaqeKsM1K9bVd5U5crk7 uYfbR4GlpT/haVL1HgYdN6rqHffbDe4Xz+YdKyM2UxqJDdRrTuSsTB7N6vqjc9OT0BYT RdXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=9wnUBnIGiHnmupdesTjLijqyj8kpX2av7C0AkM6kHts=; b=D6I6xGrRcDRMO9dGzZOwU851oZRXvOt/BqKd4qWXuyGLvq5nx2Khz6Kv1tv9S1EQ95 an1K/lrKe90h9gUyfQf4a6NWEzL3z4zMiQ2OLeNAx8SGI8A2pbb+j+MpLuhaAjb5s2lK 8tA5rR4mH/DRNPoZiiRKdsjIgbB/FeOQPUVkZqey/W8OcfBIv8JsLNB68v0bohV0WkAY sHpXKVDguEc6dAsHrVaIlE9nTrFmzLsVzQfvaB6dtzn8L5pqhXM1UqIqUSEH73Q3Xhfs m1sfPIaKWSJI5o4k7gmaqBD3AMr26qoqz6GgnYX7l+PSe5qUmGk6kp4cirixTiwe9XAH Dpzw== X-Gm-Message-State: AOAM532xNra8CQrXV95g4zRwM/fZuCIcmyZKUTy1DT30LB2lYjXAHlns A2tKRYu5cK0XoR0zP/WWocCjrZP3 X-Google-Smtp-Source: ABdhPJw0Ql6MnV3V7gF5cm065wD9dhw6gFXHoo0iBijUxW3EQhuUJTFIvqpOFlQrseOlv3f/NIVptg== X-Received: by 2002:a17:90a:714c:: with SMTP id g12mr4513131pjs.31.1591379307302; Fri, 05 Jun 2020 10:48:27 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id 128sm217173pfd.114.2020.06.05.10.48.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:48:26 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/2] shared/ad: Add defines for possible flags Date: Fri, 5 Jun 2020 10:48:24 -0700 Message-Id: <20200605174825.717902-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.25.3 MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds defines for limited disverable, general discoveral and BR/EDR not supported. --- src/advertising.c | 9 +++++---- src/shared/ad.h | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/advertising.c b/src/advertising.c index 829c481f6..4c91586c2 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -673,7 +673,7 @@ static bool set_flags(struct btd_adv_client *client, uint8_t flags) /* Set BR/EDR Not Supported for LE only */ if (!btd_adapter_get_bredr(client->manager->adapter)) - flags |= 0x04; + flags |= BT_AD_FLAG_NO_BREDR; if (!bt_ad_add_flags(client->data, &flags, 1)) return false; @@ -700,8 +700,8 @@ static bool parse_discoverable(DBusMessageIter *iter, if (discoverable) { /* Set BR/EDR Not Supported if adapter is no discoverable */ if (!btd_adapter_get_discoverable(client->manager->adapter)) - flags = 0x04; - flags |= 0x02; + flags = BT_AD_FLAG_NO_BREDR; + flags |= BT_AD_FLAG_GENERAL; } else flags = 0x00; @@ -1065,7 +1065,8 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client) } /* Set Limited Discoverable if DiscoverableTimeout is set */ - if (client->disc_to_id && !set_flags(client, 0x01)) { + if (client->disc_to_id && + !set_flags(client, BT_AD_FLAG_LIMITED)) { error("Failed to set Limited Discoverable Flag"); goto fail; } diff --git a/src/shared/ad.h b/src/shared/ad.h index a31df0fe5..19aa1d035 100644 --- a/src/shared/ad.h +++ b/src/shared/ad.h @@ -71,6 +71,11 @@ #define BT_AD_3D_INFO_DATA 0x3d #define BT_AD_MANUFACTURER_DATA 0xff +/* Low Energy Advertising Flags */ +#define BT_AD_FLAG_LIMITED 0x01 /* Limited Discoverable */ +#define BT_AD_FLAG_GENERAL 0x02 /* General Discoverable */ +#define BT_AD_FLAG_NO_BREDR 0x04 /* BR/EDR not supported */ + typedef void (*bt_ad_func_t)(void *data, void *user_data); struct bt_ad; From patchwork Fri Jun 5 17:48:25 2020 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: 11590311 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54926739 for ; Fri, 5 Jun 2020 17:48:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38D9B207F7 for ; Fri, 5 Jun 2020 17:48:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Synz8syj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727843AbgFERsa (ORCPT ); Fri, 5 Jun 2020 13:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727797AbgFERsa (ORCPT ); Fri, 5 Jun 2020 13:48:30 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7411AC08C5C2 for ; Fri, 5 Jun 2020 10:48:29 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id t16so3990957plo.7 for ; Fri, 05 Jun 2020 10:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=mnS5X/8c1lwJj8VOPXZd1EctHVYAJejNY9LVjUwL9ww=; b=Synz8syjeJAkR2B4sunKC1HXwd/OAAfUrzMpPf3y2wOdSgcqLGcyFHe6zwwO1uJlu2 Iu+TYL5rhPuJyQdnCoqYR0SwXI+F6IE71CUq6agZ2vS3KAJB6vytpLNfb+kt/7+9Rziq AlFLcYjBhfXJOH0T9K5DYZVjH4KzY1J2Ak6FIqgsgJMXoPaTx6Sb6JwHQxeJFj4ABMBH TrIYCjXBxqNNFWgPJXoHuSS45rAqQkfhmKZl13bm++ZG6LWog0jJNCDkReCmXLo0i8E/ 6lMiMPy+UEuiRLZD/3coGqXVYovojCe9Cv+fYioSg4A/qNL6k+3sfMPotI/MjuYd0gwu uJ/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mnS5X/8c1lwJj8VOPXZd1EctHVYAJejNY9LVjUwL9ww=; b=S/caEZEewq0ttsaejP8jt1ws57aY4Xnk5KR6N0emsfg8B65CUg3TEuJRKskAQ3X4eE VldDK8zBe5RbgKatqPtW6R0bKkU5UX4e9KIXid2ycqR2BzeERjQUTcpJ4WYYWhnpZsCW 1Ep+g1lBIKgQCyoWKwlnD32WBLNXkx/5fnDPSu2hpYIJS9k6UJXCU8T0STvCg1E6ly8o L5nVyd9Y4RQQv0pASqmyO+AMLRlUR2jaCUwhK5SiIiJqlAAjdF/bdy/9zb9cf43hNgeP 8+BeGnyPCDLOGyObmWGWs8ABvtLBu8gdJGlTPelhZUFIqiFhsSNhkXTmLpyV4zaqXuyF pReA== X-Gm-Message-State: AOAM530yTxRKETrfsA04ZqmrG9JHLgaTRhOugQHl3zjUb2RfyFi1/yfV 7w1Uw8GbXzVxJKz/CUGr1U6xbtmN X-Google-Smtp-Source: ABdhPJxFCRob+cbXQ8hnmkoTxOyiAWE/wma//GlLAUFwbRNKcO29EP+O2IBMb6MfsOfvJ78lKY1IyA== X-Received: by 2002:a17:902:d688:: with SMTP id v8mr11268904ply.215.1591379308597; Fri, 05 Jun 2020 10:48:28 -0700 (PDT) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id 128sm217173pfd.114.2020.06.05.10.48.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 10:48:27 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 2/2] advertising: Fix reseting NO_BREDR flag Date: Fri, 5 Jun 2020 10:48:25 -0700 Message-Id: <20200605174825.717902-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200605174825.717902-1-luiz.dentz@gmail.com> References: <20200605174825.717902-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz When setting BT_AD_FLAG_LIMITED it was actually overwritting BT_AD_FLAG_NO_BREDR as well so this moves the logic of detecting if the instance needs to set BT_AD_FLAG_NO_BREDR to set_flags so it is always updated when attempting to set any flags. --- src/advertising.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/advertising.c b/src/advertising.c index 4c91586c2..076d591b6 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -675,6 +675,13 @@ static bool set_flags(struct btd_adv_client *client, uint8_t flags) if (!btd_adapter_get_bredr(client->manager->adapter)) flags |= BT_AD_FLAG_NO_BREDR; + /* Set BR/EDR Not Supported if adapter is not discoverable but the + * instance is. + */ + if ((flags & (BT_AD_FLAG_GENERAL | BT_AD_FLAG_LIMITED)) && + !btd_adapter_get_discoverable(client->manager->adapter)) + flags |= BT_AD_FLAG_NO_BREDR; + if (!bt_ad_add_flags(client->data, &flags, 1)) return false; @@ -697,12 +704,9 @@ static bool parse_discoverable(DBusMessageIter *iter, dbus_message_iter_get_basic(iter, &discoverable); - if (discoverable) { - /* Set BR/EDR Not Supported if adapter is no discoverable */ - if (!btd_adapter_get_discoverable(client->manager->adapter)) - flags = BT_AD_FLAG_NO_BREDR; - flags |= BT_AD_FLAG_GENERAL; - } else + if (discoverable) + flags = BT_AD_FLAG_GENERAL; + else flags = 0x00; if (!set_flags(client , flags))