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 https://doc.qt.io/qt-5/qbluetoothlocaldevice.html#requestPairing (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?
-
I discovered that the issue is related to the fact that I request pairing from my Qt app by calling https://doc.qt.io/qt-5/qbluetoothlocaldevice.html#requestPairing (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?
hi @MartinD
have you checked the documentation?it has a qml and cpp based BluetoothLE scanner/desicovery example
https://doc.qt.io/qt-5/qtbluetooth-scanner-example.html#
https://doc.qt.io/qt-5/qtbluetooth-btscanner-example.html#https://doc.qt.io/qt-5/bluetooth-examples.html
they are ready to compile, and you should be able to find them in QtCreator(if you use it)
Should get you pretty far
-
hi @MartinD
have you checked the documentation?it has a qml and cpp based BluetoothLE scanner/desicovery example
https://doc.qt.io/qt-5/qtbluetooth-scanner-example.html#
https://doc.qt.io/qt-5/qtbluetooth-btscanner-example.html#https://doc.qt.io/qt-5/bluetooth-examples.html
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.
-
@MartinD define pairing
If you mean,
discover your device as available
connect to it and identify the servicesthan yes, those 2 examples will exactly do that