Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3746065pxb; Wed, 13 Oct 2021 12:05:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGavSMo/J+PAPRGEny7V68CZnu0BAp7l3Jqk91rW8XNivK3Zsv6tOXJpyHxNLJgULg0U9j X-Received: by 2002:a17:906:230c:: with SMTP id l12mr1174071eja.52.1634151905521; Wed, 13 Oct 2021 12:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634151905; cv=none; d=google.com; s=arc-20160816; b=xNaO3Fqwd3cjOUZKbDe/fN5C1TUoSQSTem9LOa/V2/wuo+fJ4mxgOkQCQVYkIygRVB cl9AXUVIRKPnbjIROQhzFPn9LPqyRXMt24c/f5p5Hh0/aGYYtJfemnFOqa6WAKAd1NHL 8qg5CTz10fxWRxtR04nGpRYpmhi8NiU2dV8YWaFgAYzajPXL0z++wQAwsxgZLm5Fp0K2 9uf6KICW4L2gTFjX+l9qtQAuK1Cr4HFLWJgbUMixWhqXORKDPT0nDyyw+AWkjT3q5gC3 WpFqWPwNoGiiv9X5OBdPWEniJxHdFAwNzJ0nVy/BjHTt0hnIIDojBcFU85Yf0Dr5Hyv1 crVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=WAc+wmUNd3z1POC6nqUlp3tkcuVAO8550gDEBh9OUhU=; b=Szlpk5hw1qOdRbm+KwJrJ++7R2lsYEztr3z9O/dqOSwzmgPQ4OSV9TH//veQ2C/WiR wHnnVfy9+rALtytoXb4T/mScQnri1WUKODZafQudevsO1Ar3thI2+0fh7Q1sXXXM7AYH 1tqLgpx6MJG6zs59OS9tDbP9+prxs/4n/oILqfaqeIRb/h0vMMg4t86gJKdBTZ+y9ADg wqRJxNKCZhOTuhnTN3Wxel6m7BMiyKYbucqueAUqUBXE87zrTTdqrnxdmvGMWP3kucYF 2KBOHQh1MX3Olqhq5WkxqY0mw1nms3bgo5ExG9cU1lqheBtWU3eQhVbJMq4gbG535TRg O4VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="bFETv/24"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm9si343240edb.491.2021.10.13.12.04.20; Wed, 13 Oct 2021 12:05:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="bFETv/24"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238881AbhJMTC6 (ORCPT + 99 others); Wed, 13 Oct 2021 15:02:58 -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-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 Content-Type: text/plain; charset="UTF-8" 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; } -- 2.33.0.882.g93a45727a2-goog