Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-112382

Manufacturer ID and Service Uuid Filtering support in QBluetoothServiceDiscoveryAgent

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4.3
    • None
    • All
    • 21
    • Foundation PM Staging

    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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              cnn Qt Core & Network
              taytoo Mike Flanigan
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes