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

[REG 5.10->5.11] Simultaneous BLE service detail discovery broken on Darwin

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.12.1
    • 5.11.2, 5.12.0
    • None
    • macOS 10.14.1
      Xcode 10.1
      Qt Creator 4.8.0
      Qt 5.11.2 Commercial
    • iOS/tvOS/watchOS, macOS
    • db0f1f7ab0892c84744608e073fc99999ef28fdd

    Description

      If multiple service characteristic discoveries (QLowEnergyService::discoverDetails) are started on the same BLE device at the same time, only one of them ever completes. The others indicate QLowEnergyService::ServiceState(DiscoveringServices) and never progress beyond that.

      This worked in Qt 5.10.1 and is now broken in Qt 5.11.2. I believe it was introduced by one or both of these change sets:

      https://code.qt.io/cgit/qt/qtconnectivity.git/commit/src/bluetooth/osx/osxbtcentralmanager.mm?id=6e111b1631ca43c6c78edf0cf28b943e62cb2804
      https://code.qt.io/cgit/qt/qtconnectivity.git/commit/src/bluetooth/osx/osxbtcentralmanager.mm?id=b6c0e2af96129c297b87c25796a36c3fbc680269

      The requests for characteristic discovery appear to be dispatched to CBPeripheral correctly and the callback in OSXBTCentralManager below fires for each. However, for all but the last callback to pass through here, the code short circuits through the (service != objectUnderWatch) conditional – which appears to be a bug.

      As a result, discovery completes for only one service and the others never progress. Same thing happens on iOS and macOS.

      - (void)peripheral:(CBPeripheral *)aPeripheral didDiscoverCharacteristicsForService:(CBService *)service
              error:(NSError *)error
      {
          // This method does not change 'managerState', we can have several
          // discoveries active.
          Q_UNUSED(aPeripheral)
      
          if (!notifier) {
              // Detached.
              return;
          }
      
          if (service != objectUnderWatch) {
              // Timed out already?
              return;
          }
      
          [self stopWatchdog];
      
          using namespace OSXBluetooth;
      
          Q_ASSERT_X(managerState != CentralManagerUpdating, Q_FUNC_INFO, "invalid state");
      
          if (error) {
              NSLog(@"%s failed with error: %@", Q_FUNC_INFO, error);
              // We did not discover any characteristics and can not discover descriptors,
              // inform our delegate (it will set a service state also).
              emit notifier->CBManagerError(qt_uuid(service.UUID), QLowEnergyController::UnknownError);
          }
      
          [self readCharacteristics:service];
      }
      

      Attachments

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

        Activity

          People

            tpochep Timur Pocheptsov
            dhess David Hess
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes