Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.4.3
-
None
-
-
21
-
Foundation PM Prioritized
Description
The scenario is that as a developer I'm only interested in advertisements related to my app/software's Bluetooth service (uuid) OR as a Company with multiple BLE devices/apps, I'd likely only be interested in advertisements of my devices (Manufacturer ID).
Qt's current implementation does more than just forward advertisement to application - Qt actually tries to lookup each device (BluetoothLEDevice::FromBluetoothAddressAsync) - this results in significant cpu usage. Now consider, if unnecessary advertisements can be filtered out at Qt-framework level. This means no cpu usage in resolving each BLE device in advertisements and no cpu usage in tracking device updates. It will be much more useful and efficient.
Obviously, anyone who wants to receive all advertisements can simply choose not to set any filters, so this class will still work for general purpose scanning.
Recommended Functions to be added to QBluetoothServiceDiscoveryAgent class:
//Manufacturer ID filters can be added to a QSet<quint32> addManufacturerFilter(quint16 manufacturerId); removeManufacturerFilter(quint16 manufacturerId); clearManufacturerFilters(); //Service uuid filters can be added to a QSet<GUID> addServiceFilter(GUID uuid); removeServiceFilter(GUID uuid); clearServiceFilters();
Filtering will happen when underlying platform generates advertisement event. For example on windows, it happens in subscribeToEvents() function in AdvertisementWatcherWrapper. Basically, in that code data from underlying platform advertisement event is used to emit advertisementDataRecieved signal. In subscribeToEvents(), simple logic can be added to see if advertisementDataReceived signal needs to be emitted at all.
Example:
if (manufacturerFilters.count() != 0 && manufacturerFilters.contains(manufacturerId) == false) return; //Unwanted advertisement, no further processing needed if (serviceFilters.count() != 0 && serviceFilters.contains(serviceUuid) == false) return; //Unwanted advertisement, no further processing needed
Attachments
Issue Links
- relates to
-
QTBUG-112771 [Bluetooth] Conditionally disable detailed service discovery during device discovery on Windows
- Reported
- resulted from
-
QTBUG-111116 QT BLE scanner example causes high cpu usage
- Closed