Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. BLE remote device authorisation request not being exposed in QT Bluetooth stack
QtWS25 Last Chance

BLE remote device authorisation request not being exposed in QT Bluetooth stack

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 326 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rmcaleer
    wrote on 30 Jun 2022, 05:36 last edited by
    #1

    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

    E 1 Reply Last reply 5 Jul 2022, 11:09
    0
    • R rmcaleer
      30 Jun 2022, 05:36

      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

      E Offline
      E Offline
      ekkescorner
      Qt Champions 2016
      wrote on 5 Jul 2022, 11:09 last edited by
      #2

      @rmcaleer just noticed: my issue about pairing/bonding on Android / iOS seems not to be the same, but similar to your problem under linux

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps
      5.15 --> 6.8 https://t1p.de/ekkeChecklist
      QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

      1 Reply Last reply
      0
      • E Offline
        E Offline
        ekkescorner
        Qt Champions 2016
        wrote on 10 Jul 2022, 10:30 last edited by
        #3

        @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

        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
        5.15 --> 6.8 https://t1p.de/ekkeChecklist
        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

        1 Reply Last reply
        1

        3/3

        10 Jul 2022, 10:30

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved