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

Bluetooth pairing with low energy device

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2: Important P2: Important
    • None
    • 5.12, 5.13
    • None
    • Android

      I'm trying to connect an android smatphone (central role) where my application run, to a Bluetooth low energy device (peripheral role).
      When I call requestPairing method from my code, the QBluetoothLocalDevice::PairingError signal occurs immediately. However the OS panel to pair the device is shown but connection is closed and operation is aborted, so no pairing is possible.
      Here my code, where "target" is a QBluetoothDeviceInfo* from a list of devices discovered by QBluetoothDeviceDiscoveryAgent

      bleController = new QLowEnergyController(*target);
      myAdapter = new QBluetoothLocalDevice();
      qDebug() << "Pairing Status is " << myAdapter->pairingStatus(target->address());
      if (myAdapter->pairingStatus(target->address()) != QBluetoothLocalDevice::Paired) {
          connect(myAdapter,SIGNAL(error(QBluetoothLocalDevice::Error)),this,SLOT(pairingError(QBluetoothLocalDevice::Error)));
         connect(myAdapter,SIGNAL(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)),this,SLOT(pairingSuccess(QBluetoothAddress,QBluetoothLocalDevice::Pairing)));
          
      connect(myAdapter,SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)),this,SLOT(modeStateChanged(QBluetoothLocalDevice::HostMode)));
          myAdapter->requestPairing(target->address(),QBluetoothLocalDevice::Paired);
      }
      else {
          bleController->connectToDevice();
      }
      

       

      and here my log messages

       

      D libBleBonding.so: Pairing Status is  QBluetoothLocalDevice::Unpaired
      I BluetoothDevice: createBond() for device D9:A5:56:7F:EB:EC called by pid: 17396 tid: 17412
      D libBleBonding.so: paring error  QBluetoothLocalDevice::PairingError QLowEnergyController::UnconnectedState QBluetoothLocalDevice::Unpaired

       

      I tested same code with QT 5.9.8 and it works well.
      I tried to bond my target device by android settings menu, and here, operative system ask me passkey and the operation go to conclude properly.
      In these conditions pairing seems impossibe. Rest of my code needs QT >= 5.12, is there a work around to pair a device?

       

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

            ablasche Alex Blasche
            qtbug-44371 Dario Faggin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes