From patchwork Wed Apr 13 20:54:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 560897 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 4A83DC433F5 for ; Wed, 13 Apr 2022 20:54:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237890AbiDMU5U (ORCPT ); Wed, 13 Apr 2022 16:57:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236230AbiDMU5S (ORCPT ); Wed, 13 Apr 2022 16:57:18 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED40667D37 for ; Wed, 13 Apr 2022 13:54:56 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2ebf1d99068so26637937b3.9 for ; Wed, 13 Apr 2022 13:54:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=1yL2+Y4GUqxYFta3/wv1O/TmKK0ceZlQg2jRfPzCsPM=; b=mGdJblY7xI+xg2PwT2tU6eFdZvuELBEL4zrx2BtaLnSxdMtJtZsha+jg2iawXhTOtN NSXhgTYQHFjXHowmiNf6LIEli8qgkH0mkBfaLki+qTNcMceBXczCv8lFp42zc+LYuxmE jr26A/JK9naMs1qtRiPAjHP/sypbla06D16YiIWzFFGDIPJkzCA9suYm/v3Cu5ju78pA t54+R818sVFUaifLj/xiIpSc2QNF47TX93QoGfWOSMwcmaCw1hsmHWscSECmLSSHG+Kj 61ynzayOToAigORMjoxBiC2IxXhLnzay0bPhJYxZ7UhdE9esOWbrEuvC50fcuX2ZnBSM /FTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=1yL2+Y4GUqxYFta3/wv1O/TmKK0ceZlQg2jRfPzCsPM=; b=pcLd7KI5pQGGfrGlUKJUmxG0slrcqzo6fC1A+RViVcpdY89WL7myCPV3+USLAE/3OC JqcI6syn4XOe28IRqtKAqWL/yLKSQMw8vIgwC5VrF9yGp5VwlEYVZCdLun6KikyJFobE dgU4qfUFviSVybvCM8ZVN7xZgzQkTBGAc34DXT+jJsZoQ/5ifGelhoZBYo6tQ4SsQkc9 H1f7nhV5Eh70V0wJ31ATSf+HCS1utrCZB+MkPaAEYVVUWkIrD0t5bYILMN3yEUh+vQ3C VaCJIZCsZduV+cB1FErrijX7kTab9uk+cY5jL2+ZMnVFdH784EBp/WG0AJx5EqUh1PwP xdOA== X-Gm-Message-State: AOAM531wUo4IUKsQUUYkA72evwQ4D/4UaMvnJdpRkHs6qmAalmqO9O4U f4nFboxsf0YgEMALtbfJ1L7ZmBl+Asu3Tg== X-Google-Smtp-Source: ABdhPJwG3Nht98Rrmp+FuerPpOvVqGWoYT6K/hpuez/uewnvsRix8uQVd+TCBfLRCCl1ZoZXTiPcJQScRTVeNQ== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:2620:46aa:79ff:778d]) (user=mmandlik job=sendgmr) by 2002:a25:2d63:0:b0:641:acd5:4316 with SMTP id s35-20020a252d63000000b00641acd54316mr622786ybe.388.1649883296064; Wed, 13 Apr 2022 13:54:56 -0700 (PDT) Date: Wed, 13 Apr 2022 13:54:41 -0700 Message-Id: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [BlueZ PATCH v2 1/9] adv_monitor: Disable RSSIHighTimeout for SW based filtering From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik , Miao-chen Chou Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Controller offloading does not support High RSSI Timeout. Disable High RSSI Timeout for SW based filtering as well to provide a consistent behavior between SW based and controller based monitoring. Reviewed-by: Miao-chen Chou --- (no changes since v1) doc/advertisement-monitor-api.txt | 5 +++++ src/adv_monitor.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index 9189f2cce..942d44b2f 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -79,6 +79,11 @@ Properties string Type [read-only] in-range (found). Valid range is 1 to 300 (seconds), while 0 indicates unset. + NOTE: Controller offloading does not support High RSSI + Timeout. So, to provide a consistent behavior between + SW based and controller based monitoring, this property + has been disabled and deprecated. + Uint16 RSSISamplingPeriod [read-only, optional] Grouping rules on how to propagate the received diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 33f4d9619..a1778248f 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -860,6 +860,12 @@ static bool parse_rssi_and_timeout(struct adv_monitor *monitor, monitor->rssi.low_rssi_timeout = l_rssi_timeout; monitor->rssi.sampling_period = sampling_period; + /* Controller offloading does not support High RSSI Timeout. Disable + * High RSSI Timeout for SW based filtering to provide a consistent + * behavior between SW based and controller based monitoring. + */ + monitor->rssi.high_rssi_timeout = ADV_MONITOR_UNSET_TIMEOUT; + done: DBG("Adv Monitor at %s initiated with high RSSI threshold %d, high " "RSSI threshold timeout %d, low RSSI threshold %d, low RSSI " From patchwork Wed Apr 13 20:54:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 562668 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 DA584C433F5 for ; Wed, 13 Apr 2022 20:55:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238189AbiDMU5W (ORCPT ); Wed, 13 Apr 2022 16:57:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237910AbiDMU5V (ORCPT ); Wed, 13 Apr 2022 16:57:21 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59FD367D37 for ; Wed, 13 Apr 2022 13:54:59 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id b12-20020a056902030c00b0061d720e274aso2644246ybs.20 for ; Wed, 13 Apr 2022 13:54:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=NFvbHB/8fDYayZz14ZUldq7zRC0WFipDioxr1FFGnc8=; b=JXmR7tv9dLzUL1FVQOJ37L20K9fHt6LSyBAAiUKF0/sskbZKmLouTTS0VuhV5XhF7R /Rd7q3GT7gzh5T6A5VQ0izaFLVfCh6nL1pU6LbjiiWcqOWjs6Z1YUl6zvMgxA2aF5ZiB p8p3HsMumKCbqw7OZF23Mx5wH7iNjU0sI+e+YXBpxWk6PnsL4P9W9Kw+q3L+exgjNpTx eZNFpl9D9NB3KCA3dwcPJrFFPvPFGmd9kzl5/C9Y/wIUTk/nblzzc3CjSYL001Qa7gs9 Y4h1DpXnvBfbDvbnnhDVq2uDO+b3CfaLALCEOCNF2D6pK3VTwsn+TncC9W+6qlvE4IB+ ckiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=NFvbHB/8fDYayZz14ZUldq7zRC0WFipDioxr1FFGnc8=; b=XmxtY7qVqRgIimHjqFR8MHrFUdeWmisBz2FnaQXRcI0urkK64Iaz0ZE17hL0IVnwzd RFu95BR4EFblVGNboFKHmCI6n7y+aW6z5Mv7rJqAJqqbIGuKnb/c3m/Q9uhGLhwXtn23 VOKqJafWsEQDVB+OLveMHXiAU4YXvaHiSqJzzz9N3ZpLQyp8QEMUb7SBQstFOaCBp3Z2 aPaI5hQ4tWJaF2QHIbbXm1nq5SzbfNs6EpjLzp7CKMlkqwBubBLnYeiHqQ5uopob++o4 gO01KELlpq2UXhR11C8rrf8TTLQQDLcklch6GyGLdvFEOU8Nc8Vbmy3PFJpYVD5Tm427 VE0Q== X-Gm-Message-State: AOAM531IdWevbrEB4z6RtEBJGsFBia/lPU3dGYEeNoBWMTVhYjMggyjl bfkH7EvkvhD2sA9YRlRE7nOe21Sm/aUpvg== X-Google-Smtp-Source: ABdhPJxkZw77sbJjngsiHKUP08bzpX2BBwJQpk7L/YPvQkpnTYXmymi8/8BYuZ9ibUtbEj7ArqZv7pkJTqo7RA== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:2620:46aa:79ff:778d]) (user=mmandlik job=sendgmr) by 2002:a25:8c01:0:b0:634:712d:3def with SMTP id k1-20020a258c01000000b00634712d3defmr643817ybl.343.1649883298631; Wed, 13 Apr 2022 13:54:58 -0700 (PDT) Date: Wed, 13 Apr 2022 13:54:42 -0700 In-Reply-To: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> Message-Id: <20220413135223.BlueZ.v2.2.Ie337efd4e92e6cbbf47503c29b67384327d91c73@changeid> Mime-Version: 1.0 References: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [BlueZ PATCH v2 2/9] adv_monitor: Don't send DeviceFound for already found devices From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik , Miao-chen Chou Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When monitors with same patterns are merged, BlueZ removes the existing monitor from the kernel and re-registers it with updated/merged RSSI parameters. The controller then triggers a new Device Found event for the device that matches the updated monitor. Don't notify the D-Bus client again with another DeviceFound for that device. Reviewed-by: Miao-chen Chou --- (no changes since v1) src/adv_monitor.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index a1778248f..a7763df10 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -188,6 +188,11 @@ static void merged_pattern_send_add( static void merged_pattern_send_remove( struct adv_monitor_merged_pattern *merged_pattern); +static bool monitor_device_match(const void *a, const void *b); +static struct adv_monitor_device *monitor_device_create( + struct adv_monitor *monitor, + struct btd_device *device); + const struct adv_monitor_type { enum monitor_type type; const char *name; @@ -1555,8 +1560,26 @@ static void notify_device_found_per_monitor(void *data, void *user_data) { struct adv_monitor *monitor = data; struct monitored_device_info *info = user_data; + struct adv_monitor_device *dev = NULL; + uint16_t adapter_id = monitor->app->manager->adapter_id; if (monitor->merged_pattern->monitor_handle == info->monitor_handle) { + dev = queue_find(monitor->devices, monitor_device_match, + info->device); + if (!dev) { + dev = monitor_device_create(monitor, info->device); + if (!dev) { + btd_error(adapter_id, "Failed to create " + "Adv Monitor device object."); + return; + } + } + + if (dev->found) + return; + + dev->found = true; + DBG("Calling DeviceFound() on Adv Monitor of owner %s " "at path %s", monitor->app->owner, monitor->path); @@ -1652,8 +1675,25 @@ static void notify_device_lost_per_monitor(void *data, void *user_data) { struct adv_monitor *monitor = data; struct monitored_device_info *info = user_data; + struct adv_monitor_device *dev = NULL; + uint16_t adapter_id = monitor->app->manager->adapter_id; if (monitor->merged_pattern->monitor_handle == info->monitor_handle) { + dev = queue_find(monitor->devices, monitor_device_match, + info->device); + if (!dev) { + btd_error(adapter_id, "Adv Monitor device object " + "not found."); + return; + } + + if (!dev->found) { + btd_error(adapter_id, "Device not tracked."); + return; + } + + dev->found = false; + DBG("Calling DeviceLost() on Adv Monitor of owner %s " "at path %s", monitor->app->owner, monitor->path); From patchwork Wed Apr 13 20:54:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 560896 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 D1150C433EF for ; Wed, 13 Apr 2022 20:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238669AbiDMU5Z (ORCPT ); Wed, 13 Apr 2022 16:57:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237910AbiDMU5X (ORCPT ); Wed, 13 Apr 2022 16:57:23 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBDEF55BEA for ; Wed, 13 Apr 2022 13:55:01 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2ec08c1dd2dso26249087b3.20 for ; Wed, 13 Apr 2022 13:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xWK0YHOGJv6pMBeiWUrPqa8co5ypF3AZhZlrNIFGl8s=; b=Zv4mgHJKAUoN290A0tMeH3nMjTefK74/4A6oWPrDt8Sw4FWprkc1Uk2J9knt96E5iT rxVWah42f/PkWALrP8cynxMmfIlN6hvwmVxrEaiF/QZcB+1hIBaAF1J8XvhBUnngbPnN DMcMP3f505Sefu5H65MbcdKsPizqhoWu9U0h51iUMldVySHdzsvgxxZR+hOyWZasaZKx JkC0lTjQLhtEqFF04aYU+MVKzViW4vtnnS8RDYS/3wP4Qa7AKrgLQbgJ+5d/vHxd+poT AUHFw4ZWsMKjb0ClaEdVnIpRN9IODcdKGOvIiT2zTQflxoY5salG+udQ6gh+6+W2fzB1 sJ8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xWK0YHOGJv6pMBeiWUrPqa8co5ypF3AZhZlrNIFGl8s=; b=A8hX9Vol4/hNZK4n64n69jbLfwbqZy1uv6+ocst3xqBQ2qAw6n7U6U8iiz//su6OaS cE4j2gkq9hr6iOkP/NmmDVrz4j9SQzgoaUqc2i3PEbY6tqWnYFC/1vTD9x1jjakkdtBu KC4evSsk9F0tlRdAQMfJC4Eijrm70qaHQS2ltX4jPF8Wmp+0seesRezwI1GsIJSVsGGu E09Q+RIa/A6XxxLyFYZ3mYPR1bA7nMVodqeWUG73lfN2hoyt8FIoiyo5xiBzOLcfB21F VEWdM9tDmgqZKylhWZf8xp/LEzfmyHuyHov8Vs7ZscddVo12TEWJ9DjaRDiY+3HymfuW X9vQ== X-Gm-Message-State: AOAM530LJk8Vt3tnlG9nW4Tn/kGw+lIjjCKmRpm1sjwXooMtQwKJDQNv 1gNvoOiZ1bW0fcEKxDO81aXQMztZV1r3aQ== X-Google-Smtp-Source: ABdhPJzqhDDekGpCrGY1YxnIkb46CE4TX1twmpg4pHGL25rov3TNCPKFBnKfUcWtkSNPi8bfYK8MVMsD7pk2Gw== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:2620:46aa:79ff:778d]) (user=mmandlik job=sendgmr) by 2002:a25:32c3:0:b0:641:4d40:3065 with SMTP id y186-20020a2532c3000000b006414d403065mr635084yby.403.1649883301130; Wed, 13 Apr 2022 13:55:01 -0700 (PDT) Date: Wed, 13 Apr 2022 13:54:43 -0700 In-Reply-To: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> Message-Id: <20220413135223.BlueZ.v2.3.Icb5e0b991a133d9b8a91a23f1c9b2ca41e151a27@changeid> Mime-Version: 1.0 References: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [BlueZ PATCH v2 3/9] adv_monitor: Clear tracked devices on resume From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik , Miao-chen Chou Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Clear any tracked devices on system resume. Matched devices will be found again if they are in range after resume. Reviewed-by: Miao-chen Chou --- Changes in v2: - Fix compiler error by replacing btd_adv_monitor_offload_supported() with btd_adv_monitor_offload_enabled(). src/adapter.c | 1 + src/adv_monitor.c | 19 +++++++++++++++++++ src/adv_monitor.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 97ce26f8e..2ae8a9ae9 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -9183,6 +9183,7 @@ static void controller_resume_callback(uint16_t index, uint16_t length, info("Controller resume with wake event 0x%x", ev->wake_reason); controller_resume_notify(adapter); + btd_adv_monitor_resume(adapter->adv_monitor_manager); } static void device_blocked_callback(uint16_t index, uint16_t length, diff --git a/src/adv_monitor.c b/src/adv_monitor.c index a7763df10..18ce839e9 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -2248,6 +2248,7 @@ static void clear_device_lost_timer(void *data, void *user_data) if (dev->lost_timer) { timeout_remove(dev->lost_timer); dev->lost_timer = 0; + dev->found = false; monitor = dev->monitor; @@ -2289,3 +2290,21 @@ void btd_adv_monitor_power_down(struct btd_adv_monitor_manager *manager) /* Clear any running DeviceLost timers in case of power down */ queue_foreach(manager->apps, clear_lost_timers_from_app, NULL); } + +/* Handles wake from system suspend scenario */ +void btd_adv_monitor_resume(struct btd_adv_monitor_manager *manager) +{ + if (!manager) { + error("Unexpected NULL btd_adv_monitor_manager object upon " + "system resume"); + return; + } + + /* Clear any tracked devices on system resume. Matched devices will be + * found again if they are in range after resume. (No need to do this if + * the controller based monitoring is supported as the kernel clears all + * monitored devices on resume. + */ + if (!btd_adv_monitor_offload_enabled(manager)) + queue_foreach(manager->apps, clear_lost_timers_from_app, NULL); +} diff --git a/src/adv_monitor.h b/src/adv_monitor.h index c6bb8a68a..3b5b1200a 100644 --- a/src/adv_monitor.h +++ b/src/adv_monitor.h @@ -42,4 +42,6 @@ void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager, void btd_adv_monitor_power_down(struct btd_adv_monitor_manager *manager); +void btd_adv_monitor_resume(struct btd_adv_monitor_manager *manager); + #endif /* __ADV_MONITOR_H */ From patchwork Wed Apr 13 20:54:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 562667 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 9846FC433F5 for ; Wed, 13 Apr 2022 20:55:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238699AbiDMU51 (ORCPT ); Wed, 13 Apr 2022 16:57:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237910AbiDMU50 (ORCPT ); Wed, 13 Apr 2022 16:57:26 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 350A853718 for ; Wed, 13 Apr 2022 13:55:04 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2e642be1a51so25990967b3.21 for ; Wed, 13 Apr 2022 13:55:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=5QHuP0OaOqm2MvcLs33y6b/W3BiqwZkboBia8uB9AUA=; b=h3q3T3AM+ajBi5C/WQRDPdSFRViPIbkpjE1kaEFHChNiTGShVpCvuXk28+rd0tbRwd OH8HcSh86JZ7WfqF3tTx7HZwyhnPNsWY7AT5JqRyEFSeTRFEOEUU5UKm/TpFYL73IG9G jH6MMztu/POxny81xOHMY6VFG9WDdsMF3UQi0de5KIKlI5m7nQNcLykaFvdAk0RtHj6f KvVWKmeO2j5OYww4uLy9FeFuwhcPA68Kl1WSyp2As2f20f4YfgSYnOSqZe6oGPag/7O+ 36oBUGtdJwkl0nQ13CAArl78zmfyRbpNIfYeCS3o2fwtyjMxOgGD0mJbyKAfI+4RKNTJ kvcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=5QHuP0OaOqm2MvcLs33y6b/W3BiqwZkboBia8uB9AUA=; b=yFN0mi8AcUWa3D4iQ5ORL5aJsbS/NGYee4fx0QZMr2sNJqeGgDx8pFEJ0E6dPtOnSW XroeMt1/2kLBifAegFxkxSHiHJWyQvvYIoQatq+0in+WIfNnycGM9+7+lvpjZTpcGs7K oBUp+LLKPJ5KdGeuSh4bju0HmEcfJsFScj/4aBeWOTbziXnEHYzGDFo946jH2cKZrKvj HUuhBah3CWi6xi79C7pVU2sn67m20YB2swYcuKSF3wqxPeUKqIz8BlQxFQp8w8ONTo6Y e9UBbFlovrP94LNp3gS4gTkh0gpATpeyVZsbtJEUOhjj0gWYfAK0ZqNV5+9bPFvVq9PM WpDQ== X-Gm-Message-State: AOAM530wndcEXHxi0efLEwJix6uEGNMh8eJdOpYkx3ofYRvYmZKZVUTx 82yz8NqkMDQC53fgATAid8SHn1DwrsQxqQ== X-Google-Smtp-Source: ABdhPJyrYzQbT91a77NYngH8bf0N87BL8hI9IYWXpz3XEgwcGdD/dUE2qMutQAgPWUTrlH+ifZOlTSmDh/bPIQ== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:2620:46aa:79ff:778d]) (user=mmandlik job=sendgmr) by 2002:a5b:78f:0:b0:63d:936b:1a4 with SMTP id b15-20020a5b078f000000b0063d936b01a4mr687187ybq.29.1649883303495; Wed, 13 Apr 2022 13:55:03 -0700 (PDT) Date: Wed, 13 Apr 2022 13:54:44 -0700 In-Reply-To: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> Message-Id: <20220413135223.BlueZ.v2.4.I81b6c0f613e08fe2cabd5c6b16ed68c2116e359d@changeid> Mime-Version: 1.0 References: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [BlueZ PATCH v2 4/9] adv_monitor: Do not remove the device while monitoring From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik , Miao-chen Chou Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Bluetoothd clears temporary devices if they are not seen for 30 seconds. When controller offloading is enabled and SamplingPeriod is set to 0xFF, the controller sends only one advertisement report per device during the monitoring period. In such a case, don't remove the temporary devices if they are being monitored. Reviewed-by: Miao-chen Chou --- (no changes since v1) src/adv_monitor.c | 4 ++++ src/device.c | 22 +++++++++++++++++++++- src/device.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 18ce839e9..c01f8b154 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -1663,6 +1663,8 @@ static void adv_monitor_device_found_callback(uint16_t index, uint16_t length, return; } + btd_device_set_monitored(info.device, true); + /* Check for matched monitor in all apps */ info.monitor_handle = handle; queue_foreach(manager->apps, notify_device_found_per_app, @@ -1745,6 +1747,8 @@ static void adv_monitor_device_lost_callback(uint16_t index, uint16_t length, /* Check for matched monitor in all apps */ info.monitor_handle = handle; queue_foreach(manager->apps, notify_device_lost_per_app, &info); + + btd_device_set_monitored(info.device, false); } /* Allocates a manager object */ diff --git a/src/device.c b/src/device.c index 3992f9a0c..00d0cc2fb 100644 --- a/src/device.c +++ b/src/device.c @@ -218,6 +218,7 @@ struct btd_device { GSList *services; /* List of btd_service */ GSList *pending; /* Pending services */ GSList *watches; /* List of disconnect_data */ + bool monitored; /* Tracked by Adv Monitor */ bool temporary; bool connectable; unsigned int disconn_timer; @@ -3206,11 +3207,30 @@ static bool device_disappeared(gpointer user_data) dev->temporary_timer = 0; - btd_adapter_remove_device(dev->adapter, dev); + /* Do not remove the device if it is being tracked by an Advertisement + * Monitor. It will be removed when the Advertisement Monitor stops + * tracking that device. + */ + if (!dev->monitored) + btd_adapter_remove_device(dev->adapter, dev); return FALSE; } +void btd_device_set_monitored(struct btd_device *device, bool monitored) +{ + if (!device) + return; + + device->monitored = monitored; + + /* If the device is not being monitored and the temporary_timer has + * already expired, it indicates that the device can be removed. + */ + if (!monitored && device->temporary && !device->temporary_timer) + device_disappeared(device); +} + static void set_temporary_timer(struct btd_device *dev, unsigned int timeout) { clear_temporary_timer(dev); diff --git a/src/device.h b/src/device.h index 071576d6b..0a4103747 100644 --- a/src/device.h +++ b/src/device.h @@ -87,6 +87,7 @@ bool device_is_connectable(struct btd_device *device); bool device_is_paired(struct btd_device *device, uint8_t bdaddr_type); bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type); gboolean device_is_trusted(struct btd_device *device); +void btd_device_set_monitored(struct btd_device *device, bool monitored); void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type); void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type); void btd_device_set_temporary(struct btd_device *device, bool temporary); From patchwork Wed Apr 13 20:54:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 560895 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 8ADFAC433F5 for ; Wed, 13 Apr 2022 20:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238715AbiDMU5b (ORCPT ); Wed, 13 Apr 2022 16:57:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237910AbiDMU52 (ORCPT ); Wed, 13 Apr 2022 16:57:28 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED9C86A42B for ; Wed, 13 Apr 2022 13:55:06 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2d2d45c0df7so26831037b3.1 for ; Wed, 13 Apr 2022 13:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=6LJF+h/akEcwhrcKGG2Skrxic+lav38EsF4kiYAdZbg=; b=ok9u4niOOz0V1a+9YkmZq9LN8Qyv2y9qKc3wKaM9JozM74VJmMbEmQsVNL8SYgRknV hHeJubzVNpf4J6PRnhAicP942B4HDdDTbiRECgwYTdpg612+77ZEwKGtSa4bKylSgu95 Z4bI7KSHqhM+eRu9atMYzQte0ok/XntETEmYOIL7ZlARd2NrCHNnI5J8Ev3nd7oXDzLM VObs3COCVYR3PYXTGvXCn4WLn/RYPzUABUXT4CKDb14QT0Qo3U/b3kVnQsVqFdLXFZxM TrTPaThCOETJt7vlQDUFR398A82ugaRCfwPK6TklAIuqWo9eT+l71dq3EO0JFvE6Hb+F OLqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=6LJF+h/akEcwhrcKGG2Skrxic+lav38EsF4kiYAdZbg=; b=XVuVPy3Boh8mRBi9c19eE0DMRojqUT8iVPCAGQQjleIZBzN5g+r1L7MmaOdlLVEGTN i5efd+0ndQpBX7MxbAcOql0UnoYQQSG3jElxRsZOHqrrdP02tWly2tvlDuxPZnc9P/Ix VC0Eb5XKj8snNWoIRqUukuhgSSJkdGVOO9DllyPw4jVuVmNtZrsVSeDlWEBA6PeaYfvU /fLHW/sOvaK2OxPIx49bRgoCCvFUeXMBHaXZJyd4KxKX4Y8lewDd2HxNyw6PHsALajIs T9f+RiYqNATKpc6iFsdZLiUcf9L0CCmUEuFi+38Sz8tqGJWX58pCIdcDE+VUINow9oYr ClxA== X-Gm-Message-State: AOAM532YSNBJMbnCeTvAjLnaJoxqtD1qkqsvFAHJGOtxrzLBNauDqxNZ T/wgOBnXKGe9L38Ggpe0gmgEeXImxsSA5Q== X-Google-Smtp-Source: ABdhPJyDHPgaBrEu+DCNJmbji2xwRFNzK/BtY3//idNSXOoTs4C3JDmOmSowMQnAhRk27SIscCMjIOqUeTno4Q== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:2620:46aa:79ff:778d]) (user=mmandlik job=sendgmr) by 2002:a81:59d5:0:b0:2ef:4aa0:fdc1 with SMTP id n204-20020a8159d5000000b002ef4aa0fdc1mr661801ywb.113.1649883306144; Wed, 13 Apr 2022 13:55:06 -0700 (PDT) Date: Wed, 13 Apr 2022 13:54:45 -0700 In-Reply-To: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> Message-Id: <20220413135223.BlueZ.v2.5.I53ad1b66c8f8a65e5950354cd20417d812ad9c72@changeid> Mime-Version: 1.0 References: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [BlueZ PATCH v2 5/9] monitor: Display AdvMonitor DeviceFound/Lost events From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik , Miao-chen Chou Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Display information about MGMT_EV_ADV_MONITOR_DEVICE_FOUND and MGMT_EV_ADV_MONITOR_DEVICE_LOST events in the btmon output. Reviewed-by: Miao-chen Chou --- (no changes since v1) monitor/packet.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index b7431b57d..6f615f7ba 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -14103,6 +14103,31 @@ static void mgmt_device_found_evt(const void *data, uint16_t size) print_eir(data + 14, size - 14, false); } +static void mgmt_adv_monitor_device_found_evt(const void *data, uint16_t size) +{ + uint16_t handle = get_le16(data); + uint8_t address_type = get_u8(data + 8); + int8_t rssi = get_s8(data + 9); + uint32_t flags = get_le32(data + 10); + uint16_t data_len = get_le16(data + 14); + + print_field("Handle: %u", handle); + mgmt_print_address(data + 2, address_type); + print_rssi(rssi); + mgmt_print_device_flags(flags); + print_field("Data length: %u", data_len); + print_eir(data + 16, size - 16, false); +} + +static void mgmt_adv_monitor_device_lost_evt(const void *data, uint16_t size) +{ + uint16_t handle = get_le16(data); + uint8_t address_type = get_u8(data + 8); + + print_field("Handle: %u", handle); + mgmt_print_address(data + 2, address_type); +} + static void mgmt_discovering_evt(const void *data, uint16_t size) { uint8_t type = get_u8(data); @@ -14414,6 +14439,10 @@ static const struct mgmt_data mgmt_event_table[] = { mgmt_controller_suspend_evt, 1, true }, { 0x002e, "Controller Resumed", mgmt_controller_resume_evt, 8, true }, + { 0x002f, "Adv Monitor Device Found", + mgmt_adv_monitor_device_found_evt, 16, false }, + { 0x0030, "Adv Monitor Device Lost", + mgmt_adv_monitor_device_lost_evt, 9, true }, { } }; From patchwork Wed Apr 13 20:54:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 562666 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 8F9AFC433FE for ; Wed, 13 Apr 2022 20:55:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238701AbiDMU5u (ORCPT ); Wed, 13 Apr 2022 16:57:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238721AbiDMU5b (ORCPT ); Wed, 13 Apr 2022 16:57:31 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6719D71EEB for ; Wed, 13 Apr 2022 13:55:09 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2ec0490dc1bso26718477b3.5 for ; Wed, 13 Apr 2022 13:55:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=0lBl5MKCkM7Tt+RyKRaq77MJ8KNp3O7zGBlqRNQca14=; b=A7+mMeLUdwcNR3VngEVpWmqNg2t3FS7xPQz3tJysUu/3lHjgEQq7v9/bh65U4pG/Ub ZKy5QjNvEQIN7axzQpIV499GR+zfZC7OziBxRqi0OTXkMBD4HEODv5Zw0425OncVK63Z poQgPsCv/IMWWaL0d2hm71964Y0knVlK35oiosdw0Y4somMYmbT3QEry2IiMFeJEAN07 6VxqbDzRW8Y0nsEW7G/Op758k713/T+ZdVl+hoJd2cIg2dju3QlTlXhrESlG92S7tk3s UZnxWbcFQQG9kbjxq1w6OkkYVdoB7HYs3kMl4iErRdcJ9FKXij6x3zGdIjhxrFsiGzqf RzAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=0lBl5MKCkM7Tt+RyKRaq77MJ8KNp3O7zGBlqRNQca14=; b=6ObiTzoZE4IkLRqqY4/GOceNbateTnON3NdU7bcX4FM9i1+fNcaV+Fwsg/vMPqeyaU W6b3pthKvBenGKFmCEn08Im11mPjb6MnBvW2LVt3900a2k16owaipdOdsUSuNFoHqgrY IDOaWWIUmT5tMv4qfPDB+ML4nDYztSLHmZSoQwqU53CHgnXRTi0SBZZoZ1tPsVFpMzpX UbO/CHmOaSBhlcW8spH1XsFmsPzi5K0/BKOfvNv73Zfy4+SGG8ECqvHt2gbYnzaT/46d NXCssNPEz8Gb804fiNcYQXisqvZxK6Y1w8dpfJykQxWL+QQ8HxztEsU/uL6DJlCbqmPy qZNQ== X-Gm-Message-State: AOAM533Ut2nURlCLho/T+c7OERZWzX/X8WRvXQzcEU0/+N8x6NY3+vhO CklLtNLvyHOP8nlxoBKuwXmalyimv7vnVA== X-Google-Smtp-Source: ABdhPJy5daEXqAA7nbgU9JqPfKkBcdJDXXB3fpspfh14Tv75dUtAvah95R0EE/7h3MGpdyfbl+5m2zjWvM1C9A== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:2620:46aa:79ff:778d]) (user=mmandlik job=sendgmr) by 2002:a25:ced1:0:b0:640:df7f:398 with SMTP id x200-20020a25ced1000000b00640df7f0398mr696044ybe.162.1649883308663; Wed, 13 Apr 2022 13:55:08 -0700 (PDT) Date: Wed, 13 Apr 2022 13:54:46 -0700 In-Reply-To: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> Message-Id: <20220413135223.BlueZ.v2.6.Idb90bd382a52c8c0bc6fb5d936a9d5e5afac1fb5@changeid> Mime-Version: 1.0 References: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [BlueZ PATCH v2 6/9] adv_monitor: Do not merge monitors with non-overlapping RSSI From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik , Miao-chen Chou Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Merging two monitors with different RSSI thresholds is not possible if their RSSI ranges do not overlap. Example: Monitor 1: -40 -80 Result: Merge with updated RSSI Monitor 2: -60 -100 thresholds -60 -100 Monitor 1: -40 -100 Result: Merge with updated RSSI Monitor 2: -60 -80 thresholds -60 -100 Monitor 1: -40 -60 Result: Do not merge Monitor 2: -80 -100 Reviewed-by: Miao-chen Chou --- (no changes since v1) src/adv_monitor.c | 58 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index c01f8b154..d88e1bbbb 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -251,6 +251,46 @@ static void merged_pattern_free(void *data) free(merged_pattern); } +/* Checks if merging monitors with different RSSI Thresh is possible or not */ +static bool merge_is_possible( + struct adv_monitor_merged_pattern *existing_pattern, + struct adv_monitor *monitor) +{ + const struct queue_entry *q_entry; + struct adv_monitor *q_data; + + /* Merging two monitors with different RSSI thresholds is not possible + * if their RSSI ranges do not overlap. + */ + + q_entry = queue_get_entries(existing_pattern->monitors); + + while (q_entry) { + q_data = q_entry->data; + + if (q_data->rssi.low_rssi >= monitor->rssi.high_rssi || + monitor->rssi.low_rssi >= q_data->rssi.high_rssi) + goto fail; + + q_entry = q_entry->next; + } + + return true; + +fail: + monitor->state = MONITOR_STATE_FAILED; + merged_pattern_free(monitor->merged_pattern); + monitor->merged_pattern = NULL; + + btd_error(monitor->app->manager->adapter_id, + "Adv Monitor at path %s is in conflict with " + "an existing Adv Monitor at path %s", + g_dbus_proxy_get_path(monitor->proxy), + g_dbus_proxy_get_path(q_data->proxy)); + + return false; +} + /* Returns the smaller of the two integers |a| and |b| which is not equal to the * |unset| value. If both are unset, return unset. */ @@ -291,14 +331,9 @@ static void merge_rssi(const struct rssi_parameters *a, */ merged->high_rssi_timeout = 0; - /* Sampling period is not implemented yet in userspace. There is no - * good value if the two values are different, so just choose 0 for - * always reporting, to avoid missing packets. - */ - if (a->sampling_period != b->sampling_period) - merged->sampling_period = 0; - else - merged->sampling_period = a->sampling_period; + merged->sampling_period = get_smaller_not_unset(a->sampling_period, + b->sampling_period, + ADV_MONITOR_UNSET_SAMPLING_PERIOD); } /* Two merged_pattern are considered equal if all the following are true: @@ -1249,6 +1284,13 @@ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) monitor->merged_pattern); merged_pattern_add(monitor->merged_pattern); } else { + if (!merge_is_possible(existing_pattern, monitor)) { + monitor_destroy(monitor); + DBG("Adv Monitor at path %s released due to existing " + "monitor", path); + return; + } + /* Since there is a matching pattern, abandon the one we have */ merged_pattern_free(monitor->merged_pattern); monitor->merged_pattern = existing_pattern; From patchwork Wed Apr 13 20:54:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 560894 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 8E9BCC4332F for ; Wed, 13 Apr 2022 20:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238721AbiDMU5v (ORCPT ); Wed, 13 Apr 2022 16:57:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238740AbiDMU5e (ORCPT ); Wed, 13 Apr 2022 16:57:34 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C48FC71EE6 for ; Wed, 13 Apr 2022 13:55:11 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2ec44c52e7fso26878137b3.3 for ; Wed, 13 Apr 2022 13:55:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=a23uLrJWCTVuPqhHAD1RnUrrvwzZp5GFR9yUk8PVJ9A=; b=QSTqoaRzgdjMdMjTGM9wmgiFAKgneL281psoxWXXgW5MO606dTZp04PHTho617a3RD wm4KnMhvhEMRaxtXfTrWt5PfC9Zsz/csw0U3s8Q9snvviwqopHCphhHSg1WVmq5szF8q jKUgZmYaSoA9g+SduL+b/tYG6DdfGC2sK1+LB6MJV2eD+bWS6mjCAxHIL21RiCEfSRks mkqmfsp+yHqYf0PGOvUrJdkHS1DTS+jUYPlS93PxrJbsqnkDYHhFcx2vwHHyqgO/wRSd IXZS/k6O1xfRbgKeze1NWr1KHijnb4PM8UHxoBwgudpekQeGmrJRp/a82xmEc/apYikH z1vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=a23uLrJWCTVuPqhHAD1RnUrrvwzZp5GFR9yUk8PVJ9A=; b=C8KDhXbEMBv/TuZ8wWzxiv/YTiQMiGPbC9sud5dCkHyAkZK3siZsPScWoJAzKL7ABi CavFXwtzZGH5HmY2AZUo3WJVynJcpIqC2P0bkzyoKXwxPhhluRJ35sfqkhFcBxSaWoBx fnZN3eZVjaQFHup2u/mCmb9agHdVJevQT8SzJYU19KmjaIeB5JiUXMCGqzBwC1yv9jV1 ON2IzMoJbI9Kf/jCi2ihT4iAZavG5GwXbJIhPK3d1Tn/IKzypgg7jVdXrVGxu/cX5ZuE cW+adEwN4bTroi1K3KTxQaIET2hIhUNyJvwq6DyAZivHWbeOYrKBVV1CGkMFeizb3lRy q+fg== X-Gm-Message-State: AOAM532NoPjrrKekNi6CW0z8He8/w7usgHsu/AArGfBj7Qz3pJHhRuiX s/OvOSxW/pm9li8y5W4o7f5FX3Kl4j5xdw== X-Google-Smtp-Source: ABdhPJxdcGbSgcrIHlResa37GO6IqNc7VdnGYiRgpBCqpg73M4+ZxE+FU57hC8J3L1RvBFhCiviQL7Umw0937g== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:2620:46aa:79ff:778d]) (user=mmandlik job=sendgmr) by 2002:a05:6902:1103:b0:641:b707:1b10 with SMTP id o3-20020a056902110300b00641b7071b10mr689277ybu.569.1649883311074; Wed, 13 Apr 2022 13:55:11 -0700 (PDT) Date: Wed, 13 Apr 2022 13:54:47 -0700 In-Reply-To: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> Message-Id: <20220413135223.BlueZ.v2.7.I668ef2477efd8fcdd9c44975c5f7b9f32af966ca@changeid> Mime-Version: 1.0 References: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [BlueZ PATCH v2 7/9] adv_monitor: Add the monitor Release reason From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik , Miao-chen Chou Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Adv Monitor is released for various reasons. For example, incorrect RSSI parameters, incorrect monitor type, non-overlapping RSSI thresholds, etc. Return this release reason along with the Release event for the better visibility to clients. Reviewed-by: Miao-chen Chou --- (no changes since v1) doc/advertisement-monitor-api.txt | 12 ++++++- src/adv_monitor.c | 56 ++++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/doc/advertisement-monitor-api.txt b/doc/advertisement-monitor-api.txt index 942d44b2f..fcbd9c5c2 100644 --- a/doc/advertisement-monitor-api.txt +++ b/doc/advertisement-monitor-api.txt @@ -17,12 +17,22 @@ Service org.bluez Interface org.bluez.AdvertisementMonitor1 [experimental] Object path freely definable -Methods void Release() [noreply] +Methods void Release(Int8 reason) [noreply] This gets called as a signal for a client to perform clean-up when (1)a monitor cannot be activated after it was exposed or (2)a monitor has been deactivated. + Possible reasons: 0 Unknown reason + 1 Invalid monitor type + 2 Invalid RSSI parameter(s) + 3 Invalid pattern(s) + 4 Monitor already exists + 5 Kernel failed to add monitor + 6 Kernel failed to remove monitor + 7 Monitor removed by kernel + 8 App unregistered/destroyed + void Activate() [noreply] After a monitor was exposed, this gets called as a diff --git a/src/adv_monitor.c b/src/adv_monitor.c index d88e1bbbb..9e67d984b 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -90,6 +90,18 @@ enum monitor_state { MONITOR_STATE_RELEASED, /* Dbus Object removed by app */ }; +enum monitor_release_reason { + REASON_UNKNOWN, + REASON_INVALID_TYPE, + REASON_INVALID_RSSI_PARAMS, + REASON_INVALID_PATTERNS, + REASON_ALREADY_EXISTS, + REASON_FAILED_TO_ADD, + REASON_FAILED_TO_REMOVE, + REASON_REMOVED_BY_KERNEL, + REASON_APP_DESTROYED, +}; + enum merged_pattern_state { MERGED_PATTERN_STATE_ADDING, /* Adding pattern to kernel */ MERGED_PATTERN_STATE_REMOVING, /* Removing pattern from kernel */ @@ -113,6 +125,7 @@ struct adv_monitor { char *path; enum monitor_state state; /* MONITOR_STATE_* */ + enum monitor_release_reason release_reason; struct rssi_parameters rssi; /* RSSI parameter for this monitor */ struct adv_monitor_merged_pattern *merged_pattern; @@ -137,6 +150,7 @@ struct adv_monitor_merged_pattern { struct queue *patterns; /* List of bt_ad_pattern objects */ enum merged_pattern_state current_state; /* MERGED_PATTERN_STATE_* */ enum merged_pattern_state next_state; /* MERGED_PATTERN_STATE_* */ + enum monitor_release_reason release_reason; }; /* Some data like last_seen, timer/timeout values need to be maintained @@ -541,6 +555,18 @@ static void monitor_free(struct adv_monitor *monitor) free(monitor); } +/* Includes monitor release reason into the dbus message */ +static void report_release_reason_setup(DBusMessageIter *iter, void *user_data) +{ + const struct adv_monitor *monitor = user_data; + int8_t release_reason = REASON_UNKNOWN; + + if (monitor) + release_reason = monitor->release_reason; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, &release_reason); +} + /* Calls Release() method of the remote Adv Monitor */ static void monitor_release(struct adv_monitor *monitor) { @@ -560,8 +586,9 @@ static void monitor_release(struct adv_monitor *monitor) DBG("Calling Release() on Adv Monitor of owner %s at path %s", monitor->app->owner, monitor->path); - g_dbus_proxy_method_call(monitor->proxy, "Release", NULL, NULL, NULL, - NULL); + g_dbus_proxy_method_call(monitor->proxy, "Release", + report_release_reason_setup, NULL, + monitor, NULL); } /* Removes monitor from the merged_pattern. This would result in removing it @@ -635,13 +662,20 @@ static void monitor_destroy(void *data) static void app_destroy(void *data) { struct adv_monitor_app *app = data; + const struct queue_entry *e; if (!app) return; DBG("Destroy Adv Monitor app %s at path %s", app->owner, app->path); - queue_destroy(app->monitors, monitor_destroy); + for (e = queue_get_entries(app->monitors); e; e = e->next) { + struct adv_monitor *m = e->data; + + m->release_reason = REASON_APP_DESTROYED; + monitor_destroy(m); + } + queue_destroy(app->monitors, NULL); if (app->reg) { app_reply_msg(app, btd_error_failed(app->reg, @@ -793,6 +827,7 @@ static bool parse_monitor_type(struct adv_monitor *monitor, const char *path) } failed: + monitor->release_reason = REASON_INVALID_TYPE; btd_error(adapter_id, "Invalid argument of property Type of the Adv Monitor " "at path %s", path); @@ -919,6 +954,7 @@ done: return true; failed: + monitor->release_reason = REASON_INVALID_RSSI_PARAMS; btd_error(adapter_id, "Invalid argument of RSSI thresholds and timeouts " "of the Adv Monitor at path %s", @@ -1005,6 +1041,7 @@ static bool parse_patterns(struct adv_monitor *monitor, const char *path) return true; failed: + monitor->release_reason = REASON_INVALID_PATTERNS; btd_error(adapter_id, "Invalid argument of property Patterns of the " "Adv Monitor at path %s", path); @@ -1053,6 +1090,7 @@ static void merged_pattern_destroy_monitors( struct adv_monitor *monitor = e->data; monitor->merged_pattern = NULL; + monitor->release_reason = merged_pattern->release_reason; monitor_destroy(monitor); } } @@ -1086,6 +1124,7 @@ static void remove_adv_monitor_cb(uint8_t status, uint16_t length, return; fail: + merged_pattern->release_reason = REASON_FAILED_TO_REMOVE; merged_pattern_destroy_monitors(merged_pattern); merged_pattern_free(merged_pattern); } @@ -1142,6 +1181,7 @@ static void add_adv_patterns_monitor_cb(uint8_t status, uint16_t length, return; fail: + merged_pattern->release_reason = REASON_FAILED_TO_ADD; merged_pattern_destroy_monitors(merged_pattern); merged_pattern_free(merged_pattern); } @@ -1285,6 +1325,7 @@ static void monitor_proxy_added_cb(GDBusProxy *proxy, void *user_data) merged_pattern_add(monitor->merged_pattern); } else { if (!merge_is_possible(existing_pattern, monitor)) { + monitor->release_reason = REASON_ALREADY_EXISTS; monitor_destroy(monitor); DBG("Adv Monitor at path %s released due to existing " "monitor", path); @@ -1551,6 +1592,7 @@ static void remove_merged_pattern(void *data, void *user_data) { struct adv_monitor_merged_pattern *merged_pattern = data; uint16_t *handle = user_data; + const struct queue_entry *e; if (!handle) return; @@ -1562,8 +1604,14 @@ static void remove_merged_pattern(void *data, void *user_data) DBG("Adv monitor with handle:0x%04x removed by kernel", merged_pattern->monitor_handle); + for (e = queue_get_entries(merged_pattern->monitors); e; e = e->next) { + struct adv_monitor *m = e->data; + + m->release_reason = REASON_REMOVED_BY_KERNEL; + monitor_destroy(m); + } queue_foreach(merged_pattern->monitors, monitor_state_removed, NULL); - queue_destroy(merged_pattern->monitors, monitor_destroy); + queue_destroy(merged_pattern->monitors, NULL); merged_pattern_free(merged_pattern); } From patchwork Wed Apr 13 20:54:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 562665 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 05B6DC433EF for ; Wed, 13 Apr 2022 20:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238737AbiDMU5v (ORCPT ); Wed, 13 Apr 2022 16:57:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238756AbiDMU5g (ORCPT ); Wed, 13 Apr 2022 16:57:36 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F7966A42B for ; Wed, 13 Apr 2022 13:55:14 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id j129-20020a252387000000b00641e1faafecso1104086ybj.3 for ; Wed, 13 Apr 2022 13:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ToBf+7mtBanEu81Kg9w4akkrF/i1NSYG5hBhnuGKQfI=; b=nlhzqlMaI53SN8ujbr6O9lAl2xeSnl4iwnVt+K/5nJoRK7vdd34lTEgJWEPtPqVeqa NHg2EE+ScwzlcytKYMrLOnYt03S6//3Lxc+lWLegpNSD95TCIHME/NhiEcowKSXOVYJY N71ek2dSdjGNyx4+OWGb4VhSzrD/blYY4RL+KIapRX7WpoE8StPZhuy1fpP1DbWAYgQa sJ2mXN3Iw+5sAxp2Wxs/3BDuScMiTP0yVsyYPvespuBPNf8oniOyCVwuhhEp/QkiaMRq 2TEkqgggdKLK3NrhEe0tRXJbPuxha2yQ1vQwa0wTvumBdhgjJWtgKvavtaw7yXMKIfus YzOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ToBf+7mtBanEu81Kg9w4akkrF/i1NSYG5hBhnuGKQfI=; b=lCp4lT7Ee4MLWpfqsaKXYVrwHZOP3woFcX9SQAmLLZUz52Lt3b2OCb/DI9yYtTpuFs DUG9PC4bp3nv+q1DNJ8HACHkBiw+VXI46ogUHrpUW0lRW8x10yiVsQom+nPHuUzLVYwc MMw0W/b5nksAbDfhLzBVEebFXWLCKwy9Ap/02dH+00as0ctqdK3Qg6KfDUZjRkzGGejK OCh4CPVjmXfKPK6wybwxkkF9GiBHvGxetdqi9Z9FdeFIWH1NssfoVCAkjs4S+uRGibN3 P5ElLcRpME0TP77HwRDbPLANd48o77rTT8mfNhh9iz1lSvvrVhspwoAb4shy/Ia1KuO+ oPrg== X-Gm-Message-State: AOAM531jqW+LG/FE3AhqLx37leo4IDOayO9ZLZwUpXJvVXKkcyCS/xlv 01hGZcQ1d43UmHqhcKbP4u3yUOiDtEb1TA== X-Google-Smtp-Source: ABdhPJx6imY2z0QJrVBt365Yz44cWodYhKfD538t6pIEzurhHf87S7zjIozfZ7AENN7UH864gpGe8yBHOlRVgw== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:2620:46aa:79ff:778d]) (user=mmandlik job=sendgmr) by 2002:a25:e78a:0:b0:641:dbf0:5027 with SMTP id e132-20020a25e78a000000b00641dbf05027mr653844ybh.242.1649883313691; Wed, 13 Apr 2022 13:55:13 -0700 (PDT) Date: Wed, 13 Apr 2022 13:54:48 -0700 In-Reply-To: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> Message-Id: <20220413135223.BlueZ.v2.8.Ia97a9544495c94781c0391c0ec5a01273a278d18@changeid> Mime-Version: 1.0 References: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [BlueZ PATCH v2 8/9] client: Display the AdvMonitor Release reason From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik , Miao-chen Chou Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Bluetoothd returns the release reason when a monitor is released. Read the release reason received as part of the Release event and print it using the bluetoothctl. Reviewed-by: Miao-chen Chou --- (no changes since v1) client/adv_monitor.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/adv_monitor.c b/client/adv_monitor.c index 792379fc4..6ee9d2b42 100644 --- a/client/adv_monitor.c +++ b/client/adv_monitor.c @@ -72,9 +72,13 @@ static DBusMessage *release_adv_monitor(DBusConnection *conn, DBusMessage *msg, void *user_data) { struct adv_monitor *adv_monitor = user_data; + int8_t release_reason; - bt_shell_printf("Advertisement monitor %d released\n", - adv_monitor->idx); + dbus_message_get_args(msg, NULL, DBUS_TYPE_BYTE, &release_reason, + DBUS_TYPE_INVALID); + bt_shell_printf("Advertisement monitor %d released (reason: %d)\n", + adv_monitor->idx, + release_reason); remove_adv_monitor(adv_monitor, conn); return dbus_message_new_method_return(msg); @@ -117,7 +121,8 @@ static DBusMessage *device_lost_adv_monitor(DBusConnection *conn, } static const GDBusMethodTable adv_monitor_methods[] = { - { GDBUS_ASYNC_METHOD("Release", NULL, NULL, release_adv_monitor) }, + { GDBUS_ASYNC_METHOD("Release", GDBUS_ARGS({"reason", "y"}), + NULL, release_adv_monitor) }, { GDBUS_ASYNC_METHOD("Activate", NULL, NULL, activate_adv_monitor) }, { GDBUS_ASYNC_METHOD("DeviceFound", GDBUS_ARGS({ "device", "o" }), NULL, device_found_adv_monitor) }, From patchwork Wed Apr 13 20:54:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 560893 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 06000C433EF for ; Wed, 13 Apr 2022 20:55:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238754AbiDMU5y (ORCPT ); Wed, 13 Apr 2022 16:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238768AbiDMU5i (ORCPT ); Wed, 13 Apr 2022 16:57:38 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B82DE53718 for ; Wed, 13 Apr 2022 13:55:16 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id h82-20020a25d055000000b00641d2fd5f3fso2311807ybg.11 for ; Wed, 13 Apr 2022 13:55:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=uTiLus5wZpzBdaNIG2x/m/7MW6CIV6AQUuw8YBGtDQw=; b=FWPkBjV2Hd8Ey8qh9GRVLYp2U2G8Sc0AmfQjJjbmMOIYanak+NWYR08ZZYEP6yevg6 g1QNI/BYuGlZtRiNuhfe4Z3s/WqwpuTxdLI0TzC4KUE7N03hwulMzBJP0nsV9Ofhjl6Q h/DyPkD1BuDHz2ImZejzZ4kUYtDYwVM5I4toS44qGlbSVeiwBj/AdC41n1ixDgzzsj7N p8+pjZXAfU16kaZi+9CZH7IvvDhLdMvq8Z6ueMJWGxlG8bH8obF1potE6Nbv56Hzs8yT JEZtMZ74TAllbgUfHbNV4J8RtztTGUjm8sL4VSXuisX5dTTRb44CbTs6yh7VtIIVMXks vMqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=uTiLus5wZpzBdaNIG2x/m/7MW6CIV6AQUuw8YBGtDQw=; b=Q8AEttG8k5RLW8f/Akr34UYtO8xMzXZE2JT62irbOCjXC1MzKx2yhxPJGIY6orfpzw GsbkQgLmavIe3nOljMKnLkrHWr7w7sejcsYPR9b6dYp4E82WS0tLX+fAgRqPJV63mRt7 PEBiuYbYI5mM5tNbi9UNSyzPcvJHwp88EKZ+7NeISUjaMrMNfVhEh7/Oj9ctm8QOCmr9 vsHL5avLATqYb5SDaEvWPKkugK1Z0tZQXC5XgX47+3VC+HkdR75vVCglXb9rGM9YN4Hq rG+xQPTdZlmFGC3CKvyotANLUdliqF2prydywDltwBpJMDMvPN6sxiOsmsNlT0iooRsN 8qIA== X-Gm-Message-State: AOAM532u48a3fnv0DLY2PvKwnpJhd5n9giz8HcEsnGscwNjvyqjEPjJU 3mwIxkVB37ddrWO7qZKAELZVpDR3mQOVow== X-Google-Smtp-Source: ABdhPJyvmtPFaBrweGdzFv6byuR+gsqwj2g7Yihka+3TcnT86NwfSKG7hVGc1IKWoWwt+iQ5tG3nBm/TesoDSQ== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:2620:46aa:79ff:778d]) (user=mmandlik job=sendgmr) by 2002:a25:fd5:0:b0:641:185f:1d14 with SMTP id 204-20020a250fd5000000b00641185f1d14mr716720ybp.568.1649883315981; Wed, 13 Apr 2022 13:55:15 -0700 (PDT) Date: Wed, 13 Apr 2022 13:54:49 -0700 In-Reply-To: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> Message-Id: <20220413135223.BlueZ.v2.9.I6c034497f366eccbb78925ad107ce957f81d97b1@changeid> Mime-Version: 1.0 References: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [BlueZ PATCH v2 9/9] test: Display the AdvMonitor Release reason From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik , Miao-chen Chou Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Bluetoothd returns the release reason when a monitor is released. Read the release reason received as part of the Release event and print it using the example python app. Reviewed-by: Miao-chen Chou --- (no changes since v1) test/example-adv-monitor | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/example-adv-monitor b/test/example-adv-monitor index a405fc7b0..b01114c6b 100644 --- a/test/example-adv-monitor +++ b/test/example-adv-monitor @@ -117,10 +117,11 @@ class AdvMonitor(dbus.service.Object): @dbus.service.method(ADV_MONITOR_IFACE, - in_signature='', + in_signature='y', out_signature='') - def Release(self): - print('{}: Monitor Released'.format(self.path)) + def Release(self, reason): + print('{}: Monitor Released (reason: {})'.format(self.path, + format(reason, 'd'))) @dbus.service.method(ADV_MONITOR_IFACE, @@ -352,7 +353,10 @@ def test(bus, mainloop, advmon_mgr, app_id): # Run until user hits the 'Enter' key. If any peer device is advertising # during this time, DeviceFound() should get triggered for monitors # matching the advertisements. - raw_input('Press "Enter" key to quit...\n') + try: + raw_input('Press "Enter" key to quit...\n') # python2 + except: + input('Press "Enter" key to quit...\n') # python3 # Remove a monitor. DeviceFound() for this monitor should not get # triggered any more.