BLE remote device authorisation request not being exposed in QT Bluetooth stack
-
Hi all
I'm trying to use BLE via Qt on an embedded device running linux..
QT version is 5.15.2 build from the poky Dunfell branch.The issue I presently have is that I cannot find a way to authenticate with the BT BLE HeartRate monitor I am trying to use from within Qt.
If I try and connect through the terminal using the interactive bluetoothctl I am notified of a authorization request and after typing "yes" the devices are paired and can communicate successfully. Once I have done this it also means that they can work together in my Qt app.
This looks like:Attempting to connect to 08:6B:D7:1F:D3:1B [CHG] Device 08:6B:D7:1F:D3:1B Connected: yes Connection successful Request authorization [agent] Accept pairing (yes/no): yes [CHG] Device 08:6B:D7:1F:D3:1B Paired: yes [CHG] Device 08:6B:D7:1F:D3:1B Appearance: 0x420c [CHG] Device 08:6B:D7:1F:D3:1B ServicesResolved: yes
However if I try to connect to a "fresh" device in my Qt app I am presented with Invalid Services and Errors shortly after they have been discovered
Inspecting the syslog the bonding attempt fails at the bluez layer with the error Authentication Failed (5)
Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:bonding_attempt_complete() hci0 bdaddr 08:6B:D7:1F:D3:1B type 1 status 0x5 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/device.c:device_bonding_complete() bonding (nil) status 0x05 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/device.c:btd_device_set_temporary() temporary 1 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/device.c:device_bonding_failed() status 5 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:resume_discovery() Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:dev_disconnected() Device 08:6B:D7:1F:D3:1B disconnected, reason 0 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:adapter_remove_connection() Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/plugins/policy.c:disconnect_cb() reason 0 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:bonding_attempt_complete() hci0 bdaddr 08:6B:D7:1F:D3:1B type 1 status 0xe Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/device.c:device_bonding_complete() bonding (nil) status 0x0e Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/device.c:device_bonding_failed() status 14 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:resume_discovery() Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/profiles/gap/gas.c:read_device_name_cb() Reading device name failed with ATT errror: 14 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/profiles/gap/gas.c:read_appearance_cb() Reading appearance failed with ATT error: 14 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/profiles/battery/battery.c:read_initial_battery_level_cb() Reading battery level failed with ATT errror: 14
Looking through the QT classes in the bluetooth stack I cannot see a hook to pick up the authorization request that I see when using bluetoothctl.
Have I missed a signal that notifies me that the device is expecting acknowledged?
Is this something that I need to configure the Bluez installation to handle under the covers?I would be grateful for any suggestions as to how to get this working that don't involve always having access to a terminal and keyboard.
Thanks for any help
-r -
Hi all
I'm trying to use BLE via Qt on an embedded device running linux..
QT version is 5.15.2 build from the poky Dunfell branch.The issue I presently have is that I cannot find a way to authenticate with the BT BLE HeartRate monitor I am trying to use from within Qt.
If I try and connect through the terminal using the interactive bluetoothctl I am notified of a authorization request and after typing "yes" the devices are paired and can communicate successfully. Once I have done this it also means that they can work together in my Qt app.
This looks like:Attempting to connect to 08:6B:D7:1F:D3:1B [CHG] Device 08:6B:D7:1F:D3:1B Connected: yes Connection successful Request authorization [agent] Accept pairing (yes/no): yes [CHG] Device 08:6B:D7:1F:D3:1B Paired: yes [CHG] Device 08:6B:D7:1F:D3:1B Appearance: 0x420c [CHG] Device 08:6B:D7:1F:D3:1B ServicesResolved: yes
However if I try to connect to a "fresh" device in my Qt app I am presented with Invalid Services and Errors shortly after they have been discovered
Inspecting the syslog the bonding attempt fails at the bluez layer with the error Authentication Failed (5)
Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:bonding_attempt_complete() hci0 bdaddr 08:6B:D7:1F:D3:1B type 1 status 0x5 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/device.c:device_bonding_complete() bonding (nil) status 0x05 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/device.c:btd_device_set_temporary() temporary 1 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/device.c:device_bonding_failed() status 5 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:resume_discovery() Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:dev_disconnected() Device 08:6B:D7:1F:D3:1B disconnected, reason 0 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:adapter_remove_connection() Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/plugins/policy.c:disconnect_cb() reason 0 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:bonding_attempt_complete() hci0 bdaddr 08:6B:D7:1F:D3:1B type 1 status 0xe Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/device.c:device_bonding_complete() bonding (nil) status 0x0e Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/device.c:device_bonding_failed() status 14 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/src/adapter.c:resume_discovery() Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/profiles/gap/gas.c:read_device_name_cb() Reading device name failed with ATT errror: 14 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/profiles/gap/gas.c:read_appearance_cb() Reading appearance failed with ATT error: 14 Jun 30 10:29:04 bluetoothd[353]: ../bluez-5.55/profiles/battery/battery.c:read_initial_battery_level_cb() Reading battery level failed with ATT errror: 14
Looking through the QT classes in the bluetooth stack I cannot see a hook to pick up the authorization request that I see when using bluetoothctl.
Have I missed a signal that notifies me that the device is expecting acknowledged?
Is this something that I need to configure the Bluez installation to handle under the covers?I would be grateful for any suggestions as to how to get this working that don't involve always having access to a terminal and keyboard.
Thanks for any help
-r@rmcaleer just noticed: my issue about pairing/bonding on Android / iOS seems not to be the same, but similar to your problem under linux
-
@rmcaleer there is no SIGNAL you'll get from Qt - all should be handeled 'by magic' and the peripheral has to initiate this.
In my case - with JustWorks Encryption - the reason was 'inside' of the peripheral I wanted to connect/bond with and no popup comes up. Finally the peripheral only had 8 slots to manage paired devices and these slots were used, so no new connection/pairing works. unfortunately this was not mentioned in the docs.
as soon as I did a hard reset of the peripheral all works as expected and users on Android or iOS got the popup where the OS asked if device should be paired.
So on Android and iOS I can confirm that Qt works well with JustWorks-Pairing/Bonding