Important: Please read the Qt Code of Conduct -

Android BLE services not discovered

  • Hi,
    I have Lenovo tab E8 tablet with Android 7.0 and I connect to a BLE device from my Qt 5.11.2 app. After succesfull connection I discover services. However, everytime only Generic access service is discovered (my BLE device contains 5 services).

    D BluetoothGatt: connect() - device: CC:C6:2F:F7:55:3D, auto: false
    D BluetoothGatt: registerApp()
    D BluetoothGatt: registerApp() - UUID=d483db22-5289-457f-8c9b-6e6d82f13428
    D BluetoothGatt: onClientRegistered() - status=0 clientIf=6
    W QtBluetoothGatt: Using Android v23 BluetoothDevice.connectGatt()
    D BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=CC:C6:2F:F7:55:3D
    D BluetoothDevice: getBondState: state = 12
    D BluetoothGatt: discoverServices() - device: CC:C6:2F:F7:55:3D
    D BluetoothGatt: onSearchComplete() = Device=CC:C6:2F:F7:55:3D Status=0 // here only Generic Access service is discovered
    D BluetoothGatt: configureMTU() - device: CC:C6:2F:F7:55:3D mtu: 512
    W QtBluetoothGatt: MTU change initiated
    D BluetoothGatt: onConfigureMTU() - Device=CC:C6:2F:F7:55:3D mtu=247 status=0
    W QtBluetoothGatt: MTU changed to 247

    I also tried 3rd party app - Nordic's nRF Connect for Android - it also discoveres only Generic Access service. I'm not sure, but I think the problem is related to the MTU change...

    I tried also on some other Android devices and also on different platforms and communication with my BLE device works there.

  • I discovered that the issue is related to the fact that I request pairing from my Qt app by calling (local->requestPairing(_controller->remoteAddress(), QBluetoothLocalDevice::Paired)). After that, I can never discover services of my BLE.

    However, If I bond my BLE device using tablet's Bluetooth settings page or using 3rd app (nRF Connect for Android), that I can connect and discover all services of my BLE device.

    Anyone can help how to perform pairing with BLE device in Qt app?

  • Moderators

    hi @MartinD
    have you checked the documentation?

    it has a qml and cpp based BluetoothLE scanner/desicovery example

    they are ready to compile, and you should be able to find them in QtCreator(if you use it)

    Should get you pretty far

  • @J-Hilk Hi, but is there any example how to pair/bond BLE device in Qt?

    I have no problems with scanner or discovery on any of my Android devices.

  • Moderators

    @MartinD define pairing

    If you mean,

    discover your device as available
    connect to it and identify the services

    than yes, those 2 examples will exactly do that

  • @J-Hilk Pairing and bonding is well defined in Bluetooth standard. Bonding means securing connection and storing the keys used to secure the connection permanently on both sides so they can be reused later.

Log in to reply