linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miao-chen Chou <mcchou@chromium.org>
To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>
Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
	Howard Chung <howardchung@google.com>,
	chromeos-bluetooth-upstreaming@chromium.org,
	Alain Michaud <alainm@chromium.org>,
	Marcel Holtmann <marcel@holtmann.org>,
	Manish Mandlik <mmandlik@chromium.org>,
	Miao-chen Chou <mcchou@chromium.org>
Subject: [BlueZ PATCH v6 3/6] adapter: Clear all Adv monitors upon bring-up
Date: Tue,  6 Oct 2020 17:14:10 -0700	[thread overview]
Message-ID: <20201006171333.BlueZ.v6.3.Id6bfe7838831ae01fddc8605689dd77b51673960@changeid> (raw)
In-Reply-To: <20201006171333.BlueZ.v6.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid>

This clears all Adv monitors upon daemon bring-up by issuing
MGMT_OP_REMOVE_ADV_MONITOR command with monitor_handle 0.

The following test was performed:
- Add an Adv Monitor using btmgmt, restart bluetoothd and observe the
monitor got removed.

Reviewed-by: Alain Michaud <alainm@chromium.org>
Reviewed-by: Manish Mandlik <mmandlik@chromium.org>
Reviewed-by: Howard Chung <howardchung@google.com>
---

(no changes since v1)

 src/adapter.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index fdd9b3808..c7179fc2e 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -9500,6 +9500,43 @@ failed:
 	btd_adapter_unref(adapter);
 }
 
+static void reset_adv_monitors_complete(uint8_t status, uint16_t length,
+					const void *param, void *user_data)
+{
+	const struct mgmt_rp_remove_adv_monitor *rp = param;
+
+	if (status != MGMT_STATUS_SUCCESS) {
+		error("Failed to reset Adv Monitors: %s (0x%02x)",
+			mgmt_errstr(status), status);
+		return;
+	}
+
+	if (length < sizeof(*rp)) {
+		error("Wrong size of remove Adv Monitor response for reset "
+			"all Adv Monitors");
+		return;
+	}
+
+	DBG("Removed all Adv Monitors");
+}
+
+static void reset_adv_monitors(uint16_t index)
+{
+	struct mgmt_cp_remove_adv_monitor cp;
+
+	DBG("sending remove Adv Monitor command with handle 0");
+
+	/* Handle 0 indicates to remove all */
+	cp.monitor_handle = 0;
+	if (mgmt_send(mgmt_master, MGMT_OP_REMOVE_ADV_MONITOR, index,
+			sizeof(cp), &cp, reset_adv_monitors_complete, NULL,
+			NULL) > 0) {
+		return;
+	}
+
+	error("Failed to reset Adv Monitors");
+}
+
 static void index_added(uint16_t index, uint16_t length, const void *param,
 							void *user_data)
 {
@@ -9514,6 +9551,8 @@ static void index_added(uint16_t index, uint16_t length, const void *param,
 		return;
 	}
 
+	reset_adv_monitors(index);
+
 	adapter = btd_adapter_new(index);
 	if (!adapter) {
 		btd_error(index,
-- 
2.26.2


  parent reply	other threads:[~2020-10-07  0:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07  0:14 [BlueZ PATCH v6 1/6] adv_monitor: Implement RSSI Filter logic for background scanning Miao-chen Chou
2020-10-07  0:14 ` [BlueZ PATCH v6 2/6] adv_monitor: Implement Adv matching based on stored monitors Miao-chen Chou
2020-10-07  6:21   ` Luiz Augusto von Dentz
2020-10-12 21:21     ` Miao-chen Chou
2020-10-13 23:45       ` Luiz Augusto von Dentz
2020-10-07  0:14 ` Miao-chen Chou [this message]
2020-10-07  0:14 ` [BlueZ PATCH v6 4/6] adv_monitor: Implement Add Adv Patterns Monitor cmd handler Miao-chen Chou
2020-10-07  6:26   ` Luiz Augusto von Dentz
2020-10-12 21:35     ` Miao-chen Chou
2020-10-07  0:14 ` [BlueZ PATCH v6 5/6] adv_monitor: Fix return type of RegisterMonitor() method Miao-chen Chou
2020-10-07  0:14 ` [BlueZ PATCH v6 6/6] adv_monitor: Issue Remove Adv Monitor mgmt call Miao-chen Chou
2020-10-07  1:13 ` [BlueZ,v6,1/6] adv_monitor: Implement RSSI Filter logic for background scanning bluez.test.bot
2020-10-07  6:07 ` [BlueZ PATCH v6 1/6] " Luiz Augusto von Dentz
2020-10-12 21:21   ` Miao-chen Chou
2020-10-13 23:17     ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201006171333.BlueZ.v6.3.Id6bfe7838831ae01fddc8605689dd77b51673960@changeid \
    --to=mcchou@chromium.org \
    --cc=alainm@chromium.org \
    --cc=chromeos-bluetooth-upstreaming@chromium.org \
    --cc=howardchung@google.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.von.dentz@intel.com \
    --cc=marcel@holtmann.org \
    --cc=mmandlik@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).