diff mbox series

[BlueZ,v5,1/6] doc: Introduce the Adv Monitor Device Found/Lost events

Message ID 20211117110627.BlueZ.v5.1.I7f6bdb9282c1e12ffc6c662674678f2b1cb69182@changeid
State New
Headers show
Series [BlueZ,v5,1/6] doc: Introduce the Adv Monitor Device Found/Lost events | expand

Commit Message

Manish Mandlik Nov. 17, 2021, 7:14 p.m. UTC
This patch introduces two new MGMT events
MGMT_EV_ADV_MONITOR_DEVICE_FOUND and MGMT_EV_ADV_MONITOR_DEVICE_LOST to
indicate that the controller has started/stopped tracking a particular
device matching one of the already added Advertisement Monitor.

If the controller offloading support is not available,
MGMT_EV_ADV_MONITOR_DEVICE_FOUND event is also used to report all
advertisements to perform software based filtering whenever we are not
active scanning.

Reviewed-by: Miao-chen Chou <mcchou@google.com>
---
Hello Bt-Maintainers,

Bluetooth Advertisement Monitor API was introduced to support background
scanning and proximity detection based on the application specified RSSI
thresholds and content filters on LE advertisement packets.

To optimize the power consumption, the API offloads the content
filtering and RSSI tracking to the controller if the controller
offloading support is available. However, this monitoring is not
completely offloaded as the bluetoothd also handles RSSI thresholds and
timeouts in order to fulfill high/low thresholds/timeouts filtering with
D-bus clients.

There is further room to achieve better power optimization by supporting
the controller event HCI_VS_MSFT_LE_Monitor_Device_Event to fulfill true
monitor offloading. This is currently not supported as it was originally
desired to minimize the changes to the MGMT interface and reuse the
existing MGMT_EV_DEVICE_FOUND event to pass advertisements to the
bluetoothd and let bluetoothd handle the RSSI thresholds and timeouts in
order to fulfill the D-bus API requirements for the client.

This patch series introduces MGMT events MGMT_EV_ADV_MONITOR_DEVICE_FOUND
and MGMT_EV_ADV_MONITOR_DEVICE_LOST to indicate that the controller has
started/stopped monitoring a particular device.

Please let me know what you think about this or if you have any further
questions.

Thanks,
Manish.

Changes in v5:
- Update the Adv Monitor Device Found event to include fields from the
  existing Device Found event.

Changes in v4:
- Add Advertisement Monitor Device Found event, make Address_Type 0 as
  reserved.

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 | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

Comments

Luiz Augusto von Dentz Nov. 17, 2021, 9:09 p.m. UTC | #1
Hi Manish,

On Wed, Nov 17, 2021 at 11:15 AM Manish Mandlik <mmandlik@google.com> wrote:
>
> Update default Advertisemet Monitor Sampling_Period to 0xFF. It
> indicates that controller will report only one advertisement per
> monitoring period for a device. This will help reduce the power
> consumption drastically.
>
> Reviewed-by: Miao-chen Chou <mcchou@google.com>
> ---
>
> Changes in v5:
> - New patch in the series. Update default Sampling_Period to 0xFF.
>
>  src/main.c    | 2 +-
>  src/main.conf | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/main.c b/src/main.c
> index 5ca8d5644..1f852fdf6 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -932,7 +932,7 @@ static void init_defaults(void)
>         btd_opts.avdtp.session_mode = BT_IO_MODE_BASIC;
>         btd_opts.avdtp.stream_mode = BT_IO_MODE_BASIC;
>
> -       btd_opts.advmon.rssi_sampling_period = 0;
> +       btd_opts.advmon.rssi_sampling_period = 0xFF;
>  }
>
>  static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
> diff --git a/src/main.conf b/src/main.conf
> index e05291d8e..e49259453 100644
> --- a/src/main.conf
> +++ b/src/main.conf
> @@ -260,5 +260,5 @@
>  [AdvMon]
>  # Default RSSI Sampling Period. This is used when a client registers an
>  # advertisement monitor and leaves the RSSISamplingPeriod unset.
> -# Default: 0
> +# Default: 0xFF (Report only one Adv per device during the monitoring period)
>  #RSSISamplingPeriod=0

While at it it would be good to explain what is the unit used here,
also it is common practice to have the default on the commented entry.

> --
> 2.34.0.rc1.387.gb447b232ab-goog
>
Luiz Augusto von Dentz Nov. 19, 2021, 7:40 p.m. UTC | #2
Hi Manish,

On Fri, Nov 19, 2021 at 11:06 AM Manish Mandlik <mmandlik@google.com> wrote:
>
> Hi Luiz,
>
>
> On Wed, Nov 17, 2021 at 4:09 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote:
>>
>> Hi Manish,
>>
>> On Wed, Nov 17, 2021 at 11:15 AM Manish Mandlik <mmandlik@google.com> wrote:
>> >
>> > Update default Advertisemet Monitor Sampling_Period to 0xFF. It
>> > indicates that controller will report only one advertisement per
>> > monitoring period for a device. This will help reduce the power
>> > consumption drastically.
>> >
>> > Reviewed-by: Miao-chen Chou <mcchou@google.com>
>> > ---
>> >
>> > Changes in v5:
>> > - New patch in the series. Update default Sampling_Period to 0xFF.
>> >
>> >  src/main.c    | 2 +-
>> >  src/main.conf | 2 +-
>> >  2 files changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/src/main.c b/src/main.c
>> > index 5ca8d5644..1f852fdf6 100644
>> > --- a/src/main.c
>> > +++ b/src/main.c
>> > @@ -932,7 +932,7 @@ static void init_defaults(void)
>> >         btd_opts.avdtp.session_mode = BT_IO_MODE_BASIC;
>> >         btd_opts.avdtp.stream_mode = BT_IO_MODE_BASIC;
>> >
>> > -       btd_opts.advmon.rssi_sampling_period = 0;
>> > +       btd_opts.advmon.rssi_sampling_period = 0xFF;
>> >  }
>> >
>> >  static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
>> > diff --git a/src/main.conf b/src/main.conf
>> > index e05291d8e..e49259453 100644
>> > --- a/src/main.conf
>> > +++ b/src/main.conf
>> > @@ -260,5 +260,5 @@
>> >  [AdvMon]
>> >  # Default RSSI Sampling Period. This is used when a client registers an
>> >  # advertisement monitor and leaves the RSSISamplingPeriod unset.
>> > -# Default: 0
>> > +# Default: 0xFF (Report only one Adv per device during the monitoring period)
>> >  #RSSISamplingPeriod=0
>>
>> While at it it would be good to explain what is the unit used here,
>> also it is common practice to have the default on the commented entry.
>
> Ack. I'll update this in the next revision.
>
>>
>>
>> > --
>> > 2.34.0.rc1.387.gb447b232ab-goog
>> >
>>
>>
>> --
>> Luiz Augusto von Dentz
>
>
> Can you please review the other patches as well and let me know if they look good? I'll send all the required changes in the next revision together.

Other patches look good.
diff mbox series

Patch

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 97d33e30a..8e7b5ef70 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -4910,3 +4910,63 @@  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 Found Event
+========================================
+
+	Event code:		0x002f
+	Controller Index:	<controller_id>
+	Event Parameters:	Monitor_Handle (2 Octets)
+				Address (6 Octets)
+				Address_Type (1 Octet)
+				RSSI (1 Octet)
+				Flags (4 Octets)
+				AD_Data_Length (2 Octets)
+				AD_Data (0-65535 Octets)
+
+	This event indicates that the controller has started tracking a device
+	matching an Advertisement Monitor with handle Monitor_Handle.
+
+	Monitor_Handle 0 indicates that we are not active scanning and this
+	is a subsequent advertisement report for already matched Advertisement
+	Monitor or the controller offloading support is not available so need
+	to report all advertisements for software based filtering.
+
+	The address of the device being tracked will be shared in Address and
+	Address_Type.
+
+	Possible values for the Address_Type parameter:
+		0	Reserved (not in use)
+		1	LE Public
+		2	LE Random
+
+	For the RSSI field a value of 127 indicates that the RSSI is
+	not available. That can happen with Bluetooth 1.1 and earlier
+	controllers or with bad radio conditions.
+
+	This event will be sent to all management sockets.
+
+
+Advertisement Monitor Device Lost Event
+=======================================
+
+	Event code:		0x0030
+	Controller Index:	<controller_id>
+	Event Parameters:	Monitor_Handle (2 Octets)
+				Address (6 Octets)
+				Address_Type (1 Octet)
+
+	This event indicates that the controller has stopped tracking a device
+	that was being tracked by an Advertisement Monitor with the 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	Reserved (not in use)
+		1	LE Public
+		2	LE Random
+
+	This event will be sent to all management sockets.