From patchwork Wed Oct 13 19:00:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 12556647 X-Patchwork-Delegate: luiz.dentz@gmail.com 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 257C7C433EF for ; Wed, 13 Oct 2021 19:00:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BD8E610F9 for ; Wed, 13 Oct 2021 19:00:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239068AbhJMTCz (ORCPT ); Wed, 13 Oct 2021 15:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238996AbhJMTCx (ORCPT ); Wed, 13 Oct 2021 15:02:53 -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 5B9BFC061760 for ; Wed, 13 Oct 2021 12:00:47 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id i21-20020a253b15000000b005b9c0fbba45so4201393yba.20 for ; Wed, 13 Oct 2021 12:00:47 -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=N148upwECZuKBuXLljfToEWTP54GXh5i1JTO1D8BPxM=; b=Tj26+t4WNcTMaDPYA9J9gHQlwhoNG4cMrFQO701c/6F8ylMsHCn77Sw3hqb81WXS/r O/r1YkZqmVLRSUcwAcArPUAacUPKS1C8uD4H+200sH34wjuHsboYGXr3aN8PKK7tLbG8 OkW5Qhjk6f744ZdZU+DkgZBNKM4j6/bEieaGvHfyeuIfVB2sKnchGKmWEl1Jq1u58xnz fJmBd7wj0TfgtNb3Q4Y9/LXNYzJhLFuzUI7lMrspoizQa4Uc1RV+sa959+AVqLhrmysF iMcOqgJd6OsbG6ttF537UZcwKzHq/la5235mPuA7ForIx7OsKlgx4XUgWVZ2OMZdYsbL SaRw== 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=N148upwECZuKBuXLljfToEWTP54GXh5i1JTO1D8BPxM=; b=1XokugDYg5BIH8FbvZIwF7cYW7wrRPTU+r9ovmFZHWZ+r/LmVInP4iZoaH18RsNwge JqwG9B4QerUwB7S1rqOaJDXBw6ahyAdd1qMEZTR4CswyVv0/a0rm1WeCNgbpMdBTP9or b4holCqaSTqsqant5zl1GY3dNV49mO7raxVRjNYM2G+vnOHDzpPeypHPCREY+wnzz39e fNzPwW/bheod9hce7tgKnFvAfHAvWnhjmrsduYIZdi+gJdGoIIXaiXJwpHPHZekfZNaN BHVgPSgCBG36tF+dlT/fNFLLYIVUpQC+6N4/oI+EJDS3UVXQGa/P4zv44Cb3NQvSdQ+p PvpQ== X-Gm-Message-State: AOAM532sNZGIDgK99L/Uo1jhX3Um9nM4cwys3NCwr2NBqdZdmSscAlCC 3USksgbY/u1msQAeYoJiI0fbxBn2JaOxYA== X-Google-Smtp-Source: ABdhPJzcYQum4L1OOWyjQqwYyrkJ3TMH0GiDVssLGSUmkh3GJ7KPdzecJDmtFRYZOdnsVWUOnyqjRxMbjxW4AA== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:9910:f10f:1467:c3f]) (user=mmandlik job=sendgmr) by 2002:a25:2202:: with SMTP id i2mr1216735ybi.223.1634151646527; Wed, 13 Oct 2021 12:00:46 -0700 (PDT) Date: Wed, 13 Oct 2021 12:00:33 -0700 In-Reply-To: <20211013190035.1876237-1-mmandlik@google.com> Message-Id: <20211013115927.BlueZ.v3.1.I7f6bdb9282c1e12ffc6c662674678f2b1cb69182@changeid> Mime-Version: 1.0 References: <20211013190035.1876237-1-mmandlik@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [BlueZ PATCH v3 1/3] doc: Introduce the Adv Monitor Device Lost event From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add a new event 'Adv Monitor Device Lost' to indicate that the controller has stopped tracking a particular device. --- Changes in v3: - Discard changes to the Device Found event and notify bluetoothd only when the controller stops monitoring the device via new Device Lost event. Changes in v2: - Instead of creating a new 'Device Tracking' event, add a flag 'Device Tracked' in the existing 'Device Found' event and add a new 'Device Lost' event to indicate that the controller has stopped tracking that device. doc/mgmt-api.txt | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index 5355fedb0..712bb362d 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 Lost event. Example @@ -4910,3 +4911,26 @@ 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 Lost Event +======================================= + + Event code: 0x002f + Controller Index: + Event Parameters: Monitor_Handle (2 Octets) + Address (6 Octets) + Address_Type (1 Octet) + + This event indicates that the controller has stopped tracking the + device that was being tracked by monitor with handle Monitor_Handle. + + The address of the device being tracked will be shared in Address and + Address_Type. + + Possible values for the Address_Type parameter: + 0 BR/EDR + 1 LE Public + 2 LE Random + + This event will be sent to all management sockets. From patchwork Wed Oct 13 19:00:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 12556649 X-Patchwork-Delegate: luiz.dentz@gmail.com 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 183BDC433FE for ; Wed, 13 Oct 2021 19:00:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E840E6117A for ; Wed, 13 Oct 2021 19:00:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238835AbhJMTC4 (ORCPT ); Wed, 13 Oct 2021 15:02:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238877AbhJMTCy (ORCPT ); Wed, 13 Oct 2021 15:02:54 -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 A37F6C061570 for ; Wed, 13 Oct 2021 12:00:50 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id x16-20020a25b910000000b005b6b7f2f91cso4300926ybj.1 for ; Wed, 13 Oct 2021 12:00:50 -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=zDm/1HXxYpCHGqNcts6L+dNk5vE52gAdZudIn+cmvD0=; b=my/DlLy0Fb9/0ccQsmKEO+9lFdtVvtsfD6TYnPQ+Ys2MjMXoHl1ctbdgtdUVdcu+1Y t+OsRxnjn6w/gc/cT4fnK9JJBhDbdwB62EYAqhhvruCiCpifwme6B0INAFk3pS0els5o Pb0vvM9ZBz3x6RFG8aYj43uHGKh+oKLdrOX7F+CGOFMWxwMJV873K7q2+/w2DPLE86Mi QqtkaanZfBc+4vSW/KafnYiNeEqsp8LVC1WYGF1e2RqUIjgaAjVw0bv560SmYpmzsCVb HCmchxZ3zkCgRXZx1VDE+zS4DYj4tK33qFM9qgsq0DiNf72W7t8DgumQvG544lZbiMSV Td2w== 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=zDm/1HXxYpCHGqNcts6L+dNk5vE52gAdZudIn+cmvD0=; b=H9kouZn5GhusZwdoVi8zZXy+dgN0e+a1gULghLoMGFiIozg0bnVI30abMd20RXjoTm PtogR9mTetxbCMfs9A3JMroF8Z1CAyEWr6lYAFORPBIEpsRcSIrg7/njivf3DSh5I96L m2BUmgPvhqCxdSKmBG8Hu2dI9DnZ+LXRUFUA09OborbrwO8n5YWAhpZykbp9TDsrip93 D2uqLL3dN5Uqa4tML2Xrvx0pS0MYfLnzaMuBbzQM3W5ThdSF5FXQFeNPQkddDNCP+ygm htdOKMzTo2MG13MIJYHdulZSPiIj+41G8075FShjCJ1lvVlgyi4Js2u/AEEz74sajRhf 8K2Q== X-Gm-Message-State: AOAM531KnNkQbMQWNBEzzgDcq2Mqe8SVbhp6MQJws9AEkOdCaWUn9ozZ tg5/QZJnOoF5qE90f08fzuUPqc6Knj9u7w== X-Google-Smtp-Source: ABdhPJypkbpKFStsphuTA8/namsc1NrDLr4k5iXGx1yF4UWdNAsG99BYUCwkh27cqmuf8F0zTtKhfR9B7j23jQ== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:9910:f10f:1467:c3f]) (user=mmandlik job=sendgmr) by 2002:a05:6902:154f:: with SMTP id r15mr1357883ybu.441.1634151649944; Wed, 13 Oct 2021 12:00:49 -0700 (PDT) Date: Wed, 13 Oct 2021 12:00:34 -0700 In-Reply-To: <20211013190035.1876237-1-mmandlik@google.com> Message-Id: <20211013115927.BlueZ.v3.2.Ied4afb8c4c882e573f4a23670fc060cbc3e319c9@changeid> Mime-Version: 1.0 References: <20211013190035.1876237-1-mmandlik@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [BlueZ PATCH v3 2/3] lib: Add definition of the Adv Monitor Device Lost event From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds definition of the new Device Lost event to indicate that the controller has stopped tracking a device. --- Changes in v3: - Discard changes to the Device Found event and notify bluetoothd only when the controller stops monitoring the device via new Device Lost event. Changes in v2: - Instead of creating a new 'Device Tracking' event, add a flag 'Device Tracked' in the existing 'Device Found' event and add a new 'Device Lost' event to indicate that the controller has stopped tracking that device. lib/mgmt.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index 0a6349321..aaeeb297a 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -1014,6 +1014,12 @@ struct mgmt_ev_controller_resume { uint8_t wake_reason; } __packed; +#define MGMT_EV_ADV_MONITOR_DEVICE_LOST 0x002f +struct mgmt_ev_adv_monitor_device_lost { + uint16_t monitor_handle; + struct mgmt_addr_info addr; +} __packed; + static const char *mgmt_op[] = { "<0x0000>", "Read Version", @@ -1152,6 +1158,7 @@ static const char *mgmt_ev[] = { "Advertisement Monitor Removed", "Controller Suspend", "Controller Resume", + "Advertisement Monitor Device Lost", /* 0x002f */ }; static const char *mgmt_status[] = { From patchwork Wed Oct 13 19:00:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Mandlik X-Patchwork-Id: 12556651 X-Patchwork-Delegate: luiz.dentz@gmail.com 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 97D39C433FE for ; Wed, 13 Oct 2021 19:00:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 827FE61139 for ; Wed, 13 Oct 2021 19:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238986AbhJMTC7 (ORCPT ); Wed, 13 Oct 2021 15:02:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239052AbhJMTC5 (ORCPT ); Wed, 13 Oct 2021 15:02:57 -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 F06E4C061570 for ; Wed, 13 Oct 2021 12:00:53 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id s6-20020a254506000000b005b6b6434cd6so4183372yba.9 for ; Wed, 13 Oct 2021 12:00:53 -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=WAc+wmUNd3z1POC6nqUlp3tkcuVAO8550gDEBh9OUhU=; b=bFETv/24UHVPVliIn/ZWlIOU4khpx7ak3zwJps1k56z9v/1V+4D4k/rhLupyNdEKpU AorUCStiD3aI0mqrVdeL04ALQAjWXIV7fGd/5WYX2zShEh5MEztlwzOF00/WS1h8AGcm Ln+PGok5QA1xHZipKMu+pwxLMpqlI45mAuGaSf3QmAYDM1uodQawKz3eHjunWJ5mS5Cs UaIg28+ETNd48jT4D8NXmelXS31k3yoFK+zHJ0X3pQmXnzIT920xDsLWvGgSCXkN9yp+ ERku2psz0i6wt+66bsT3COH9lQ3MTnp+mzv/UTwAU0OpMWAH4gLfHuAdFq2wcLexG/yA J2SQ== 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=WAc+wmUNd3z1POC6nqUlp3tkcuVAO8550gDEBh9OUhU=; b=O/TttB0eUBH4itrUqgXNRQPrWntamwr1hs5dHKTtB6ctn9KZeRcqzyS9p+ptWie+tE SmwCdgvCvco10QM4O4Lj1cQxE88apt5L50FE8QQR7mXY4BDBqQQR4a57Ct23ii+QSZEX K5REhMFfTNf6wHnovnYamu7XpyEz5hRQoTRMuir6rWMOKHzU053HYaxpMUJhrNqcFs+O uOH9JomzVNBriMo4eHECsC/fi0WmnCd2B7s9g1sGv7DKlhBjwcYMmJ35S+LkNfQh+PB0 iB5idXpJ4Zu8DHMFMh0J0MausDpe69TKreAabyAg26RrvUpl8o/Quf3P/SujtGjDP/s5 nLcg== X-Gm-Message-State: AOAM531hJVMr2M+Kzj851ejo+Ji4lIIxYOcG42tP1n9sfME+/mMl0JzE Iomp2N0hwEXmQnNKSe81rerswBFhNjT71A== X-Google-Smtp-Source: ABdhPJz9qMcYCAW6fSz9pVKG0idsGNmOkgxcxVVvxO8y09gGr3sZsjyUpQH/YQ+fShZ4Y9JJUA9PYyI0LI3CrQ== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:9910:f10f:1467:c3f]) (user=mmandlik job=sendgmr) by 2002:a25:cdc7:: with SMTP id d190mr1190216ybf.53.1634151653193; Wed, 13 Oct 2021 12:00:53 -0700 (PDT) Date: Wed, 13 Oct 2021 12:00:35 -0700 In-Reply-To: <20211013190035.1876237-1-mmandlik@google.com> Message-Id: <20211013115927.BlueZ.v3.3.I68039747acc3c63f758278452889d6ed2bfff065@changeid> Mime-Version: 1.0 References: <20211013190035.1876237-1-mmandlik@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [BlueZ PATCH v3 3/3] adv_monitor: Receive the Device Lost event From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.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 Lost 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. --- Changes in v3: - Fix indentation of the adv_monitor_device_lost_callback() name and it's arguments. Changes in v2: - Update function name adv_monitor_tracking_callback() to adv_monitor_device_lost_callback() as it will receive only Device Lost event. src/adv_monitor.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/adv_monitor.c b/src/adv_monitor.c index 715ac5904..385ab26e6 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_device_lost_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_device_lost *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 Device Lost event"); + return; + } + + ba2str(&ev->addr.bdaddr, addr); + DBG("Adv monitor with handle 0x%04x stopped tracking the device %s", + handle, 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_DEVICE_LOST, + manager->adapter_id, adv_monitor_device_lost_callback, + manager, NULL); + return manager; }