Skip to content

bluezdbus/manager: call advertisement callbacks from InterfacesAdded - #903

Merged
dlech merged 1 commit into
developfrom
bluez-passive-scan-fixes
Jul 26, 2022
Merged

bluezdbus/manager: call advertisement callbacks from InterfacesAdded#903
dlech merged 1 commit into
developfrom
bluez-passive-scan-fixes

Conversation

@dlech

@dlech dlech commented Jul 26, 2022

Copy link
Copy Markdown
Collaborator

We have found that when doing passive scanning, some devices only send
one advertisement and then go to sleep for a while. BlueZ triggers
InterfacesAdded and InterfacesRemoved signals for these devices since
the sleep time is long enough for them to be considered no longer
present.

This caused advertisements to be missed since we were previously just
relying on PropertiesChanged signals with an RSSI change to determine
if a device is actually advertising.

By calling the callbacks on InterfacesAdded signals as well, we can
catch the very first and possibly only advertisement from these sorts
of devices.

@dlech
dlech force-pushed the bluez-passive-scan-fixes branch from c73db3a to 797cb51 Compare July 26, 2022 15:54
We have found that when doing passive scanning, some devices only send
one advertisement and then go to sleep for a while. BlueZ triggers
InterfacesAdded and InterfacesRemoved signals for these devices since
the sleep time is long enough for them to be considered no longer
present.

This caused advertisements to be missed since we were previously just
relying on PropertiesChanged signals with an RSSI change to determine
if a device is actually advertising.

By calling the callbacks on InterfacesAdded signals as well, we can
catch the very first and possibly only advertisement from these sorts
of devices.
@dlech
dlech force-pushed the bluez-passive-scan-fixes branch from 797cb51 to da5ff1f Compare July 26, 2022 15:59
@dlech
dlech merged commit 5aabf0a into develop Jul 26, 2022
@dlech
dlech deleted the bluez-passive-scan-fixes branch July 26, 2022 16:03
dlech added a commit that referenced this pull request Jul 29, 2022
Added
-----

* Added new ``assigned_numbers`` module and ``AdvertisementDataType`` enum.
* Added new ``bluez`` kwarg to ``BleakScanner`` in BlueZ backend.
* Added support for passive scanning in the BlueZ backend. Fixes #606.
* Added option to use cached services, characteristics and descriptors in WinRT backend. Fixes #686.
* Added ``PendingDeprecationWarning`` to use of ``address_type`` as keyword argument. It will be moved into the
  ``winrt`` keyword instead according to #623.
* Added better error message when adapter is not present in BlueZ backend. Fixes #889.

Changed
-------

* Add ``py.typed`` file so mypy discovers Bleak's type annotations.
* UUID descriptions updated to 2022-03-16 assigned numbers document.
* Replace use of deprecated ``asyncio.get_event_loop()`` in Android backend.
* Adjust default timeout for ``read_gatt_char()`` with CoreBluetooth to 10s. Merged #891.
* ``BleakScanner()`` args ``detection_callback`` and ``service_uuids`` are no longer keyword-only.
* ``BleakScanner()`` arg ``scanning_mode`` is no longer Windows-only and is no longer keyword-only.
* All ``BleakScanner()`` instances in BlueZ backend now use common D-Bus object manager.
* Deprecated ``filters`` kwarg in ``BleakScanner`` in BlueZ backend.
* BlueZ version is now checked on first connection instead of import to avoid import side effects. Merged #907.

Fixed
-----

* Documentation fixes.
* On empty characteristic description from WinRT, use the lookup table instead of returning empty string.
* Fixed detection of first advertisement in BlueZ backend. Merged #903.
* Fixed performance issues in BlueZ backend caused by calling "GetManagedObjects" each time a
  ``BleakScanner`` scans or ``BleakClient`` is connected. Fixes #500.
* Fixed not handling "InterfacesRemoved" in ``BleakClient`` in BlueZ backend. Fixes #882.
* Fixed leaking D-Bus socket file descriptors in BlueZ backend. Fixes #805.
@dlech dlech mentioned this pull request Jul 29, 2022
dlech added a commit that referenced this pull request Jul 29, 2022
Added
-----

* Added new ``assigned_numbers`` module and ``AdvertisementDataType`` enum.
* Added new ``bluez`` kwarg to ``BleakScanner`` in BlueZ backend.
* Added support for passive scanning in the BlueZ backend. Fixes #606.
* Added option to use cached services, characteristics and descriptors in WinRT backend. Fixes #686.
* Added ``PendingDeprecationWarning`` to use of ``address_type`` as keyword argument. It will be moved into the
  ``winrt`` keyword instead according to #623.
* Added better error message when adapter is not present in BlueZ backend. Fixes #889.

Changed
-------

* Add ``py.typed`` file so mypy discovers Bleak's type annotations.
* UUID descriptions updated to 2022-03-16 assigned numbers document.
* Replace use of deprecated ``asyncio.get_event_loop()`` in Android backend.
* Adjust default timeout for ``read_gatt_char()`` with CoreBluetooth to 10s. Merged #891.
* ``BleakScanner()`` args ``detection_callback`` and ``service_uuids`` are no longer keyword-only.
* ``BleakScanner()`` arg ``scanning_mode`` is no longer Windows-only and is no longer keyword-only.
* All ``BleakScanner()`` instances in BlueZ backend now use common D-Bus object manager.
* Deprecated ``filters`` kwarg in ``BleakScanner`` in BlueZ backend.
* BlueZ version is now checked on first connection instead of import to avoid import side effects. Merged #907.

Fixed
-----

* Documentation fixes.
* On empty characteristic description from WinRT, use the lookup table instead of returning empty string.
* Fixed detection of first advertisement in BlueZ backend. Merged #903.
* Fixed performance issues in BlueZ backend caused by calling "GetManagedObjects" each time a
  ``BleakScanner`` scans or ``BleakClient`` is connected. Fixes #500.
* Fixed not handling "InterfacesRemoved" in ``BleakClient`` in BlueZ backend. Fixes #882.
* Fixed leaking D-Bus socket file descriptors in BlueZ backend. Fixes #805.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant