From patchwork Mon Sep 27 20:16:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 12520717 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 002CDC433F5 for ; Mon, 27 Sep 2021 20:17:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA7BA600CC for ; Mon, 27 Sep 2021 20:17:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236886AbhI0USt (ORCPT ); Mon, 27 Sep 2021 16:18:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236763AbhI0USt (ORCPT ); Mon, 27 Sep 2021 16:18:49 -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 D4560C061575 for ; Mon, 27 Sep 2021 13:17:10 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 124-20020a251182000000b005a027223ed9so17549560ybr.13 for ; Mon, 27 Sep 2021 13:17:10 -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=cXX3iSCnNkg1qWcmh4C8N+aEjrcE5o7s94vdqDBfYsE=; b=fuApOPepuodiJbdCIZNvv6UPBRrg9gAv5l0EXksNp30i5ZrvJr8hfl94qfO4JtYFbJ mzJveLmKIJHOOQ5CranZMjkjpmigAUjpEOEode03MMQ4STlv3an+CCFF4SF1+We+X+3m nyct3qWihhPYZui5hixGi4s0SMuxsR54uqzX0lDFiiNV2GTSSaaNwLiNCmb3DsMOZRmF 8br0PDUB29tA0fvksulwTUNy9ew34jQZGCBZLWT4YQ5DkJtzULJQQdsxLY0spaRaI3Lr NSF5nm0f3+dtyIvxne0ujW2xESkDiiVZi9GEfVhSs3JTpbDvJbmB0ZCrmJLGLj7qe7tv IubQ== 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=cXX3iSCnNkg1qWcmh4C8N+aEjrcE5o7s94vdqDBfYsE=; b=Syqy+3L26WldLAltKBG9rPeQVkTxYWnkNdFXx6/tjFrZ6H7+v+hwICuFc8Axc1KRWK nn0ofzmnqXz0sMJpYvpqIJF8ASxTPWKpCzjMoIIo5P+WrgvR3H7GZ6RXUO291UHWUl97 jZR+h2pYl1/H2+rBAtrcWF/rv/cW+CjNnRBZ89VGDZVQX0jMMgpstLl0p7Z/t5xWX+8x X9PXcOK5dgHikjlgK9KLubLfYb5E/ZciC4IVp4q+/O5tW2soFl7SSfmgFc7JtcutXVMJ cWSQo9uHmAfcRa7TL3n1+nS2w79Xd98ol9CwY+tJCfWaGXTq6+8xfDVL/L2tQztfc3JA Lu8A== X-Gm-Message-State: AOAM530e+tsfxAhd34+F+GZeIy/82QR60v42oVeBMq+geWWzAhlUsPyf ART84VGCpYJBcoXGOarN4lO6lCnDN1o0tQ== X-Google-Smtp-Source: ABdhPJx/YcAh7wk3KuiiJOGEiD/mhJ8E2aGwQdQnX0BAr7V7Pi1o/16BcbcGGjzfyGGT2TLJUDd0Dx40r9yOmQ== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:8f29:89eb:dfbc:3b00]) (user=mmandlik job=sendgmr) by 2002:a25:1c86:: with SMTP id c128mr2065372ybc.83.1632773830022; Mon, 27 Sep 2021 13:17:10 -0700 (PDT) Date: Mon, 27 Sep 2021 13:16:55 -0700 In-Reply-To: <20210927201657.593569-1-mmandlik@google.com> Message-Id: <20210927131456.BlueZ.v1.1.I7f6bdb9282c1e12ffc6c662674678f2b1cb69182@changeid> Mime-Version: 1.0 References: <20210927201657.593569-1-mmandlik@google.com> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog Subject: [BlueZ PATCH v1 1/3] doc: Add Advertisement Monitor Device Tracking event From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Manish Mandlik , Miao-chen Chou , Yun-Hao Chung Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds the Advertisement Monitor Device Traching event. This event indicates that the controller has stated/stopped tracking a particular device matching one of the already added Advertisement Monitor. Reviewed-by: Miao-chen Chou Reviewed-by: Yun-Hao Chung --- doc/mgmt-api.txt | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index 5355fedb0..06df3e914 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -107,7 +107,8 @@ Configuration command, Default Runtime Configuration Changed event, Get Device Flags command, Set Device Flags command, Device Flags Changed event, Read Advertisement Monitor Features command, Add Advertisement Patterns Monitor command, Remove Advertisement Monitor command, Advertisement Monitor -Added event and Advertisement Monitor Removed event. +Added event, Advertisement Monitor Removed event and Advertisement Monitor +Device Tracking event. Example @@ -4910,3 +4911,27 @@ Controller Resume Event Address_Type. Otherwise, Address and Address_Type will both be zero. This event will be sent to all management sockets. + + +Advertisement Monitor Device Tracking Event +=========================================== + + Event code: 0x002f + Controller Index: + Event Parameters: Monitor_Handle (2 octets) + Monitor_State (1 octet) + Address (6 octets) + Address_Type (1 octet) + + This event indicates that the controller has started/stopped tracking + a particular device matching the Advertisement Monitor with handle + Monitor_Handle. + + Possible values for the Monitor_State parameter: + 0 The controller has stopped tracking a device + 1 The controller has started tracking a device + + The address of the device being tracked will be shared in Address and + Address_Type. + + This event will be sent to all management sockets. From patchwork Mon Sep 27 20:16:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 12520719 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 964E8C433EF for ; Mon, 27 Sep 2021 20:17:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D39360FF2 for ; Mon, 27 Sep 2021 20:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236804AbhI0USy (ORCPT ); Mon, 27 Sep 2021 16:18:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236889AbhI0USx (ORCPT ); Mon, 27 Sep 2021 16:18:53 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 184ECC061575 for ; Mon, 27 Sep 2021 13:17:15 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id p20-20020a25d814000000b005b6a75a370cso2371778ybg.14 for ; Mon, 27 Sep 2021 13:17:15 -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=9QqyaGF5JbGqnPKRFDn9L/txayGrCgZHqvLhXfmbP9E=; b=ovOC0zNyqsygqy4pfrfqYUif+H9OBv9b3NlGRi07npWH22eNcoubwrpFOvRjavitQG E1ddZeobeG8McmKQd4GpeM2eOPW79DS+Kl99ZD54sBLnTWqW2Up4MIedUPWoLAx3lfdr nR1uTnjBxHaW80gtFVNJKlRkwvYuCq31/rshxKJe+fSlgadOWy9B62iKpNJprhASw3Ji Gt1nAkXSdsgMU8Nn6ABCE2nF7M21pxOmldGr+zpxh3BmItJrkbeN0xXCR+Fl5npExdAv hdeXduGhNKsV3NkpmTVqlhHBUxnlMEcOC91As2Ba+VrRqj/ykzvKA358mZnX9HhKB9Xs vyDw== 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=9QqyaGF5JbGqnPKRFDn9L/txayGrCgZHqvLhXfmbP9E=; b=miKUbBvTx9FJgi4sy0nFiyOfmkYq8F85gTRuw/DBTMEY6JO8fI9jRyozlAHgvBi8s6 RPsNfWXiHqxzBRNewx71+YCE1+54EDoBcimjoMK7JBd/IrZ/gYpc64hYmxPUMANMxbwZ kvsM1j4n+aDeQ3Qq9qn5FRQvsOF8mv9EPmntSchI2SG7RNaqh1EEHzk/6/irlrCtKF9A PlgKKUlrorFzM3653JKZJk5iNSJsEhDfCKM0i+rhJgeF2RFdfwxD9puQCVnI1/zFOk2W by8nYfmMNXUsqeQ3pJOxE2xXhzSqHxzCqwD7lccbEc+rPkfZNsOf+D7vONzutwkWyqwJ MWUg== X-Gm-Message-State: AOAM5320VBcVFqE5fe7LERxW0p3yWYp7hKibxEugO0abKABwJPaqSamF 3HiSvjxTKB2fzCrB8kyYHAQZxUW62xe0cw== X-Google-Smtp-Source: ABdhPJwofqbkkZoO0w6D9cbnsKmVp2d6kAsA1yoYYBolU5RpRfZrHNu5HGJWdOMrLlPF6fOlj9CJviFYL7+jpQ== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:8f29:89eb:dfbc:3b00]) (user=mmandlik job=sendgmr) by 2002:a25:5956:: with SMTP id n83mr2108922ybb.194.1632773834349; Mon, 27 Sep 2021 13:17:14 -0700 (PDT) Date: Mon, 27 Sep 2021 13:16:56 -0700 In-Reply-To: <20210927201657.593569-1-mmandlik@google.com> Message-Id: <20210927131456.BlueZ.v1.2.Ied4afb8c4c882e573f4a23670fc060cbc3e319c9@changeid> Mime-Version: 1.0 References: <20210927201657.593569-1-mmandlik@google.com> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog Subject: [BlueZ PATCH v1 2/3] lib: Add definition of AdvMonitor Tracking event From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Manish Mandlik Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds a definition of the Advertisement Monitor Device Tracking event. --- lib/mgmt.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index 0a6349321..f23041f96 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -1014,6 +1014,13 @@ struct mgmt_ev_controller_resume { uint8_t wake_reason; } __packed; +#define MGMT_EV_ADV_MONITOR_TRACKING 0x002f +struct mgmt_ev_adv_monitor_tracking { + uint16_t monitor_handle; + uint8_t monitor_state; + struct mgmt_addr_info addr; +} __packed; + static const char *mgmt_op[] = { "<0x0000>", "Read Version", @@ -1152,6 +1159,7 @@ static const char *mgmt_ev[] = { "Advertisement Monitor Removed", "Controller Suspend", "Controller Resume", + "Advertisement Monitor Device Tracking", /* 0x002f */ }; static const char *mgmt_status[] = { From patchwork Mon Sep 27 20:16:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 12520721 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCAF0C433EF for ; Mon, 27 Sep 2021 20:17:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98935600CC for ; Mon, 27 Sep 2021 20:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236895AbhI0US6 (ORCPT ); Mon, 27 Sep 2021 16:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236921AbhI0US5 (ORCPT ); Mon, 27 Sep 2021 16:18:57 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8619FC061575 for ; Mon, 27 Sep 2021 13:17:19 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 81-20020a251254000000b005b6220d81efso16160570ybs.12 for ; Mon, 27 Sep 2021 13:17:19 -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=rzTIu1JoB+uKHekR8/Dw77In6oKArKQgMAGVIKHvT64=; b=s2jn2oYi+1Ad+zeEmTxtbT20c5gUTbyaShzfn4zXSK45HWu7K72qcWG/iIbx+gaF0v Ee9lNoPvSbBPcfon0J4XwkDtdUnQsmqydEgn5AuSzr4wOzdn8AVcd+JpkSCF9t+okp+k XIGKEfHwOG72M9Vg/hZLQnZGs7gE1q5LYxqGeqCv02N0pIxmdPnIzt5RSs2cjCRd8q0I tI03/JYQCx6KFbGACu05v9XfTExBohqApvDqe4QZ5Wdrpsmkl/USMpwDEbY7AJp/8dqK H7+qkpxbKPN9evPHqtB1i7jFZZkaURShkCvkj3g/R3gD/GrU6EecujWq9fc5wIACM6LS +Q7g== 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=rzTIu1JoB+uKHekR8/Dw77In6oKArKQgMAGVIKHvT64=; b=g2V1xo3tSvzwAfSRlLShkutg+O5HdRBO8E5MR1tSjcgf+v8xyuLBfmaQeuVTZf6RG1 bfvvRTltmfLh3o1p4wo1yTL8zNmKBSvLlUTWFhQ2aikukkaSOzx0skJgeVUtN/tdJNI5 n4IuB9LgCmYFEqFWV/elTpzW+cy0HIDNxE6sGMl/62zfCE4ZcclvNigjAY+beU4txR33 0pr8G/w9yuXYrryYjfMI1gI0PqoFQNCuq4rO9C2E6ORDJvDllp7EidJFTO71lPBgV+Rt CY1W+L+2bhgSTsqzuatC14Fmb+nn1wgpmGPyfDBr3WieJ9SrqjFkq3DOdCxhDz6BlDs1 f7zQ== X-Gm-Message-State: AOAM532DguIqGH7gBqgjKYTPmVYdKJd4OqrbFC0MdKhGAoMvRGygQD0L PtYPoYnxg8C5qPhnsbm2bLHk7AJX6NXIxQ== X-Google-Smtp-Source: ABdhPJzUA8rkftMPTyZf7bTELOYcop2naNsntYSW0UOX+AQePVgMOMJS1h0538KvzzgVscFXceEGa1FJFvS+0Q== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:8f29:89eb:dfbc:3b00]) (user=mmandlik job=sendgmr) by 2002:a25:5e09:: with SMTP id s9mr2082275ybb.417.1632773838776; Mon, 27 Sep 2021 13:17:18 -0700 (PDT) Date: Mon, 27 Sep 2021 13:16:57 -0700 In-Reply-To: <20210927201657.593569-1-mmandlik@google.com> Message-Id: <20210927131456.BlueZ.v1.3.I68039747acc3c63f758278452889d6ed2bfff065@changeid> Mime-Version: 1.0 References: <20210927201657.593569-1-mmandlik@google.com> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog Subject: [BlueZ PATCH v1 3/3] adv_monitor: Receive Device Tracking event From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Manish Mandlik Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch registers a callback function to receive Advertisement Monitor Device Tracking event. Test performed: - verified by logs that Monitor Device is received from the controller and sent to the bluetoothd when the controller starts/stops monitoring a bluetooth device. --- src/adv_monitor.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 715ac5904..05bd49134 100644 --- a/src/adv_monitor.c +++ b/src/adv_monitor.c @@ -1531,6 +1531,27 @@ static void adv_monitor_removed_callback(uint16_t index, uint16_t length, ev->monitor_handle); } +/* Processes Adv Monitor tracking event from kernel */ +static void adv_monitor_tracking_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + struct btd_adv_monitor_manager *manager = user_data; + const struct mgmt_ev_adv_monitor_tracking *ev = param; + uint16_t handle = le16_to_cpu(ev->monitor_handle); + const uint16_t adapter_id = manager->adapter_id; + char addr[18]; + + if (length < sizeof(*ev)) { + btd_error(adapter_id, + "Wrong size of Adv Monitor Tracking event"); + return; + } + + ba2str(&ev->addr.bdaddr, addr); + DBG("Adv monitor with handle 0x%04x %s tracking device %s", handle, + ev->monitor_state ? "started" : "stopped", addr); +} + /* Allocates a manager object */ static struct btd_adv_monitor_manager *manager_new( struct btd_adapter *adapter, @@ -1555,6 +1576,10 @@ static struct btd_adv_monitor_manager *manager_new( manager->adapter_id, adv_monitor_removed_callback, manager, NULL); + mgmt_register(manager->mgmt, MGMT_EV_ADV_MONITOR_TRACKING, + manager->adapter_id, adv_monitor_tracking_callback, + manager, NULL); + return manager; }