From patchwork Tue Dec 15 10:10:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archie Pusaka X-Patchwork-Id: 11974361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 147F4C4361B for ; Tue, 15 Dec 2020 10:12:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4321207CC for ; Tue, 15 Dec 2020 10:12:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727046AbgLOKLk (ORCPT ); Tue, 15 Dec 2020 05:11:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725535AbgLOKL1 (ORCPT ); Tue, 15 Dec 2020 05:11:27 -0500 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76639C0617A6 for ; Tue, 15 Dec 2020 02:10:47 -0800 (PST) Received: by mail-qv1-xf4a.google.com with SMTP id bp20so5379185qvb.20 for ; Tue, 15 Dec 2020 02:10:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=ZcNqNYDWKbKZ8hzaS0DvLFpFlWUMcdBsaXEATtGfxlM=; b=G8oo5Ki7Uk2glVHJ1ZyKcjRa0W0eVdeQKZd6I159XluyiAZPPI4ql7yl9L5meODszN BKUy7O2znPeKX+xhxrr3m6UK8798BJcH830swI5Ms8rC4XUkeVPbP2jQrX/ydGUyN3RA T6dG02XbMbbjOAIzk+/NBa6KAEu/VEk4rp0PKKqEEBQB4638Xyy2Q1oOdod3PyZ4fimQ staosPz6KIN8XJzw9+Y6XDscIcR1ZVh5BwTSCgQFKI0G8VnEGr0u0PfevLg+b7/b6OXT CWzulXQKAj14g8hV0M+Va5ylqUJQCbVAK7ExMqiHmQw8BDM0EAwks3F5fPCR2JPSYuPa FvRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=ZcNqNYDWKbKZ8hzaS0DvLFpFlWUMcdBsaXEATtGfxlM=; b=fjQay8iPONTY+mzK1qlCLloe+XGAuliNABjZKk3pxzh0P8n07zOexCELEU1m/hyniR e4IAJMfMG7dn7jqLOHdUWgzHLzPGZKHa34aUxcfLFYEVWX0w1ezInf4XbSKQLfuSV+kz N77jqkal7q/SoL4nRQPUwuKKS91lc0M30r2n0417E4G+glo7Rj+i5jt+5tNix1JIrSqb 8cibUH8IeocRl1MzKqi4UdHAsTkF0D1DEwl7qv8/dt6WopFx0tA3vAAp4Ll6GnHCrTZ0 5wFC4PwAKe9BjbwVSbCwusF1xegb7WSQu4GqA1TVUTk3zmTFvZacUGhTFsXoBI0SwJ+2 t/Kw== X-Gm-Message-State: AOAM530TCB8td20c1LiVAWmtaU9hpfgnx41cdIWnv+GOhgH5QyPpiz3U Cxj6R4B194BXVWqA+RTSPqt5nQh8YlsEPnNUrZbEEz3DbuDbV1LevzC7px2Gk3hG+/qicSwDRBC 9AWBxV5xCiLHKeR6BLM99W99sR/0eNrj8NlV4jaeiIEjZsnyV1+eHNFcccKuJojd1HpcjHQ8EUQ 6m X-Google-Smtp-Source: ABdhPJykGbGD0bHSVK+3FtU3cxxyeWFlstcDBixD1uAFwYkjh/zF3q8SnU34ZQ7iN1MVba5EgKWD7haYyeDs Sender: "apusaka via sendgmr" X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:b:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a0c:8b60:: with SMTP id d32mr17896955qvc.60.1608027046492; Tue, 15 Dec 2020 02:10:46 -0800 (PST) Date: Tue, 15 Dec 2020 18:10:36 +0800 Message-Id: <20201215181024.Bluez.v2.1.Iab784797733f28413e9de4f0d7fc0d4e1a00d9ef@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.2.684.gfbc64c5ab5-goog Subject: [Bluez PATCH v2 1/2] doc/mgmt-api: Add opcode for adding advertisement monitor with RSSI From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka , Manish Mandlik , Miao-chen Chou , Yun-Hao Chung Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Archie Pusaka This is to leverage the filtering by RSSI feature on those controllers which supports advertisement packet filtering. To avoid changing the existing API and breaking it, a new opcode is required. Reviewed-by: Manish Mandlik Reviewed-by: Miao-chen Chou Reviewed-by: Yun-Hao Chung --- (no changes since v1) doc/mgmt-api.txt | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index 1aa43d6c3c..d5c7169630 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -3800,6 +3800,58 @@ Add Extended Advertising Data Command Busy +Add Advertisement Patterns Monitor With RSSI Threshold Command +============================================================== + + Command Code: 0x0056 + Controller Index: + Command Parameters: Pattern_Count (1 Octet) + RSSI_Data { + High_Threshold (1 Octet) + High_Threshold_Timer (2 Octets) + Low_Threshold (1 Octet) + Low_Threshold_Timer (2 Octets) + Sampling_Period (1 Octet) + } + Pattern1 { + AD_Type (1 Octet) + Offset (1 Octet) + Length (1 Octet) + Value (31 Octets) + } + Pattern2 { } + ... + Return Parameters: Monitor_Handle (2 Octets) + + This command is essentially the same as Add Advertisement Patterns + Monitor Command (0x0052), but with an additional RSSI parameters. + As such, if the kernel supports advertisement filtering, then the + advertisement data will be filtered in accordance with the set + RSSI parameters. Otherwise, it would behave exactly the same as the + Add Advertisement Patterns Monitor Command. + + Devices would be considered "in-range" if the RSSI of the received adv + packets are greater than High_Threshold dBm for High_Threshold_Timer + seconds. Similarly, devices would be considered lost if no received + adv have RSSI greater than Low_Threshold dBm for Low_Threshold_Timer + seconds. Only adv packets of "in-range" device would be propagated. + + The meaning of Sampling_Period is as follows: + 0x00 All adv packets from "in-range" devices would be + propagated. + 0xFF Only the first adv data of "in-range" devices would be + propagated. If the device becomes lost, then the first + data when it is found again will also be propagated. + other Advertisement data would be grouped into 100ms * N + time period. Data in the same group will only be + reported once, with the RSSI value being averaged out. + + Possible errors: Failed + Busy + No Resources + Invalid Parameters + + Command Complete Event ====================== From patchwork Tue Dec 15 10:10:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archie Pusaka X-Patchwork-Id: 11974363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AD49C2BB9A for ; Tue, 15 Dec 2020 10:12:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6F2622203 for ; Tue, 15 Dec 2020 10:12:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726923AbgLOKLv (ORCPT ); Tue, 15 Dec 2020 05:11:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727106AbgLOKLm (ORCPT ); Tue, 15 Dec 2020 05:11:42 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA0C9C0617A7 for ; Tue, 15 Dec 2020 02:11:01 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id g24so13781777pgh.14 for ; Tue, 15 Dec 2020 02:11:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=Z5rgqdUpLFe1Tt9GAbm9e0jGCeMmeJ2XtTKDuzylehU=; b=ViCJxoFZ+t4oBmkKGGiFvr3s/vxaBZhZ5WcqALfU8wAzhkfsB4M5ibdLTcbca/yGZj mubpAG6JShbie0CWXq0ItesMGLyqp08GC0QCe/sadYoJpTpsBKa845r+4c72SG/2F2cx g4O7gtA8vXEuF8MIEO4gn5Xv/ydJpbjfGDNYTzbIFkM8MVisi53RcalpP5wh+ZLEgsiq SjtY87OGT8bOV4RKPhYXUN2/lWXOGF0iRQrci4LknK8Y+WP6FRIAxnMej7Zi8TLJAzDr 4IG3ApXlrzDn62rfg961kv9ml0oEzd/p9XlyiTIMdn2FDKTKJ2b8lYlUdfcDj1thsYz1 JL9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Z5rgqdUpLFe1Tt9GAbm9e0jGCeMmeJ2XtTKDuzylehU=; b=ZvdQACJZThFwquXZaOXMi1QES68/GFx5tvcRrUdd2SnQil4iTmiOxoScj7ytz22x4V VYXee7bH06EhQny3qjtUUbZYwKXGyvqihs5/UQE9CXgelBluFwmOTUxhqHEFefToZ8SJ EqZ6gxeVOOQMhGwZK9W6YICcDo/EdnhZlkezQzgncQIogMPfsjZrQaW8C6yR4ptInnJu Rz92A8NYpJj3z1Lnp0aoIFh+75i8hGR0ou3aAUrxwA8TnC2w2oTNsQ6aJtPSb3jXE2OH Og+sRfEWgZ5vLehNY+ePXcTH3tqXVDswElDNgcY3CGUyx+/qF7WE4R9KJNDkpQwVmYQn P8iQ== X-Gm-Message-State: AOAM5328bZbJDoONgjKjXIo96AQfYtUrXfhkU/AsGZLkNUCBh6mcILjZ R3VpgehXcRft58akcIPFUsp05jh6EAJy3EQhzxplDIDS5K/hpmaUN6jd6o6NqNJtFnNV9ZzQMle qu2cq4J33se1tugwcMRxkMXHDouB5BYRZ3E0CwBcMtqU0cuUKg3jE5Hs80syYkWLv9sdYmfKW7f Xg X-Google-Smtp-Source: ABdhPJwvscs853yZH9ZNF0fhxZHOkoUG7jmUggQ5EkJ2WOthhuW0pB2Lup+IuWApNW42MYzVSP/T7Gqk0nw1 Sender: "apusaka via sendgmr" X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:b:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a17:902:123:b029:dc:27b:3c62 with SMTP id 32-20020a1709020123b02900dc027b3c62mr1937339plb.16.1608027061189; Tue, 15 Dec 2020 02:11:01 -0800 (PST) Date: Tue, 15 Dec 2020 18:10:38 +0800 In-Reply-To: <20201215181024.Bluez.v2.1.Iab784797733f28413e9de4f0d7fc0d4e1a00d9ef@changeid> Message-Id: <20201215181024.Bluez.v2.2.I90bb4b25451e7f726fc2c8771cfe642b16312ce3@changeid> Mime-Version: 1.0 References: <20201215181024.Bluez.v2.1.Iab784797733f28413e9de4f0d7fc0d4e1a00d9ef@changeid> X-Mailer: git-send-email 2.29.2.684.gfbc64c5ab5-goog Subject: [Bluez PATCH v2 2/2] lib/mgmt: Adding Add Adv Patterns Monitor RSSI opcode From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka , Manish Mandlik , Miao-chen Chou , Yun-Hao Chung Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Archie Pusaka The new op is to utilize RSSI in advertisement monitor Reviewed-by: Manish Mandlik Reviewed-by: Miao-chen Chou Reviewed-by: Yun-Hao Chung --- Changes in v2: * Remove the trailing period on the commit title lib/mgmt.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index f37f7e6540..1b8fcc0e10 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -738,6 +738,21 @@ struct mgmt_rp_add_ext_adv_data { uint8_t instance; } __packed; +struct mgmt_adv_rssi_thresholds { + int8_t high_threshold; + uint16_t high_threshold_timeout; + int8_t low_threshold; + uint16_t low_threshold_timeout; + uint8_t sampling_period; +} __packed; + +#define MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI 0x0056 +struct mgmt_cp_add_adv_patterns_monitor_rssi { + uint8_t pattern_count; + struct mgmt_adv_rssi_thresholds rssi; + struct mgmt_adv_pattern patterns[0]; +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { uint16_t opcode;