Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3418851pxb; Wed, 13 Oct 2021 05:45:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCDvOI2jBXiAk8gYLuiwPjRFkmmHWn9Q2/+b0q55+yUJ1PAIP6SbuAhW2JmgJ3pWEW80sd X-Received: by 2002:a62:800a:0:b0:447:b73e:6e18 with SMTP id j10-20020a62800a000000b00447b73e6e18mr37966556pfd.28.1634129134987; Wed, 13 Oct 2021 05:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634129134; cv=none; d=google.com; s=arc-20160816; b=Nox/Xlvjge57tIO0sYbA8vzXbXDartBq47hBlDkgkFsC6aHZVIkfTjuH25NQa1LDoU VX2+vAd33bhB+ZlI9V14KDGYawwwsN3h9DVD0Xy6V20yCbwHiTCXOvv6E3ezktyPDWeq faAMPV1FOLbwPz3myLPZrHkdCmDJVJqGEEh1K8vOTqWT/8orDNECimBFitGjh47/xV7v gExYa+g9dPtH03FnL6gn/+Hpx2VZOzKoo8nUoEt4w98nRIIsw8GLAGFCNo/nlbKpY8FK ijNeLPyYo7H1m8y5vk20RNo7Tf/GtkgtFJ9qMcn/bAJFlYEnu68hguoghQtH4bZMhhA8 asMg== 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=7iaQtJpZumerAmlGSXfWt/ljLWop3XfrDNRMtw2mmZw=; b=kUpOIJLEZ1TyIj2sZPKPH87yBEqnp6wlSpfDIBx/elmymgdC98sUmjALA67ogGPc8U ZeT6PX0BYd/+4IAUi/ZIAtiqB8+NA8PrueFYC4owyg0YtckxIkgVuzkDlERd/vC89EPj 8MuaT4zIZs6wjUC8epwqxaKCaTNIyEFS8bL0BaSUPUBFDIxCbkw2y8iGI2yb8WDyQnuj nTlcUlwl+jBGEXWn6ykFP6uOKY82qSrgB44rOlTLJPrFP7R72JUtq0QEDvURjnIRqA7n ShLdbAzfeL92PedxTxp6CNyH+SJSOKPpX43nNZSSgwhemvFr9uv5OXMOki1dFPt4t6of rtgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eHTruHBS; 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 lp3si9900849pjb.80.2021.10.13.05.45.01; Wed, 13 Oct 2021 05:45:34 -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=eHTruHBS; 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 S234432AbhJMMpO (ORCPT + 99 others); Wed, 13 Oct 2021 08:45:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232486AbhJMMpL (ORCPT ); Wed, 13 Oct 2021 08:45:11 -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 1649CC061570 for ; Wed, 13 Oct 2021 05:43:08 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id z2-20020a254c02000000b005b68ef4fe24so2952301yba.11 for ; Wed, 13 Oct 2021 05:43:08 -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=7iaQtJpZumerAmlGSXfWt/ljLWop3XfrDNRMtw2mmZw=; b=eHTruHBS4d+ZSTw4Sw1eCFlR6LRcnvPX3vqiNWR4rgKpUJEn7c7qkiRVI5XbPmZZgQ ulzNOTRcqUV/qpcLGXgBgpQoAKf22bG9NhFEdmDqYNC/sjex7yHudRFsj6/upxJ48GlD nx/LBK+CVg5vpr2h884GpA1lQNNiBEvrAsttYlthsEBD9G9LcLMGbWEa6pyz44QSj89+ AE+CZk2GMvjPvRypB9Qqn4OhOLpfsk3LbtRZvtYAK59i6aHJLs93drNu+7bEHxNOBBGT Qp903yc2yewlSOmIyXURcaL9YtzFch4J6UqactXU0q1KUz4w560GXqLPPZrPr3effMCJ 6Eng== 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=7iaQtJpZumerAmlGSXfWt/ljLWop3XfrDNRMtw2mmZw=; b=tpWN3aW9e4JINOYrx4zpZ0xdYBnTqfaB5Lye3oyFrs4AGYrJp/82q5NhZzExXiD+U6 CuNBxPIO4D0C2qZZ+RuurLrQNYcgnb507aoERONAqYVTzs9zR2hwCcQ22CbDDRNRnZF9 nB+eX8uJD+0cGNK3pQDNqMzQgh2Hdu4x72JQuK6oLhB5dCJbCz+cLWe4TC5/k1vQEYYl tPtwpuy9j8bK1edTupAuHF6AIhf+gz5WxKmflUce/h7hThduoX1n+Q/CCW0ngOzIyD4e jUMPcPVP4Sam5R69HTxNN7H9V9xciR8lU4UfMWGYg+mGsqsxrbzmiZDr04Je+xkzXL0X h/ug== X-Gm-Message-State: AOAM532NOTO97hM4aNsR9W32rZArFcNZBe91KYNlolEneT6efzzop2DF RXoKNuh9XsG1dQylN8+MODoaErw6OdvzEQ== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:f8a0:57c1:fc2b:3837]) (user=mmandlik job=sendgmr) by 2002:a25:a346:: with SMTP id d64mr35906483ybi.414.1634128987331; Wed, 13 Oct 2021 05:43:07 -0700 (PDT) Date: Wed, 13 Oct 2021 05:42:10 -0700 In-Reply-To: <20211013124210.1454876-1-mmandlik@google.com> Message-Id: <20211013053935.BlueZ.v2.3.I68039747acc3c63f758278452889d6ed2bfff065@changeid> Mime-Version: 1.0 References: <20211013124210.1454876-1-mmandlik@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [BlueZ PATCH v2 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 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..13042786c 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