Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Bluetooth Low Energy Notification Bug / Downgrade Qt
QtWS25 Last Chance

Qt Bluetooth Low Energy Notification Bug / Downgrade Qt

Scheduled Pinned Locked Moved Solved General and Desktop
19 Posts 4 Posters 2.6k 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.
  • C Offline
    C Offline
    chrizbee
    wrote on 26 Dec 2020, 11:47 last edited by chrizbee
    #1

    I'm having the exact same problem as @nowayback described in this Post.
    The mentioned "solution" was to downgrade Qt from 5.11.3 (current version on my Raspberry Pi) to 5.7.1.

    Is there a way to downgrade without compiling Qt from source?
    Or better: Has this problem been fixed in newer versions of Qt?

    1 Reply Last reply
    1
    • C Offline
      C Offline
      chrizbee
      wrote on 2 Jan 2021, 11:17 last edited by chrizbee 1 Feb 2021, 11:25
      #17

      I've found a workaround for it:
      If you set the environment variable BLUETOOTH_FORCE_DBUS_LE_VERSION to anything below 5.42, Qt will use the old GATT stack implementation instead of BlueZ DBUS implementation. What I've tested:

      BLUETOOTH_FORCE_DBUS_LE_VERSION=5.41 ./BleTest
      

      I'll close this and keep the bugreport open since it's a missing feature / bug of the new implementation.

      Source: qlowenergycontroller.cpp and bluez5_helper.cpp

      1 Reply Last reply
      2
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 26 Dec 2020, 11:57 last edited by
        #2

        Hi,

        It depends whether you are cross-compiling or building directly on your target.

        As for the issue, I do not know if it was or not reported since there was no answer on the thread.

        You should check the module's release logs to see if there is anything related there. You might be able to rebuild just that module. However, I would recommend using a more recent version anyway. The current LTS is 5.15 and Qt 6 just got released.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        C 2 Replies Last reply 26 Dec 2020, 12:04
        1
        • C Offline
          C Offline
          chrizbee
          wrote on 26 Dec 2020, 12:03 last edited by
          #3
          This post is deleted!
          S 1 Reply Last reply 26 Dec 2020, 12:05
          0
          • S SGaist
            26 Dec 2020, 11:57

            Hi,

            It depends whether you are cross-compiling or building directly on your target.

            As for the issue, I do not know if it was or not reported since there was no answer on the thread.

            You should check the module's release logs to see if there is anything related there. You might be able to rebuild just that module. However, I would recommend using a more recent version anyway. The current LTS is 5.15 and Qt 6 just got released.

            C Offline
            C Offline
            chrizbee
            wrote on 26 Dec 2020, 12:04 last edited by
            #4

            @SGaist
            I'm building directly on my Raspberry Pi 4 since my project is not that large.
            But if I want to use a newer version of Qt I'll have to build it myself, right?
            Or are there any binaries / prebuilt packages to use?

            1 Reply Last reply
            0
            • C chrizbee
              26 Dec 2020, 12:03

              This post is deleted!

              S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 26 Dec 2020, 12:05 last edited by
              #5

              @chrizbee indeed, unless someone has a PPA with packages that can be used on the distribution you use on the Pi.

              Note that you do not need the whole of Qt. Start with qtbase which is mandatory and then only the modules you actually need. It will cut time a lot.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              C 1 Reply Last reply 26 Dec 2020, 12:08
              0
              • S SGaist
                26 Dec 2020, 12:05

                @chrizbee indeed, unless someone has a PPA with packages that can be used on the distribution you use on the Pi.

                Note that you do not need the whole of Qt. Start with qtbase which is mandatory and then only the modules you actually need. It will cut time a lot.

                C Offline
                C Offline
                chrizbee
                wrote on 26 Dec 2020, 12:08 last edited by
                #6

                @SGaist Okay... here we go again...
                I will report back later if the mentioned bug was fixed with newer versions of Qt (testing with 5.15.2).

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 26 Dec 2020, 12:14 last edited by
                  #7

                  Check the bug report system first, this might avoid you long hours of compilation.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  C 1 Reply Last reply 27 Dec 2020, 08:52
                  0
                  • S SGaist
                    26 Dec 2020, 11:57

                    Hi,

                    It depends whether you are cross-compiling or building directly on your target.

                    As for the issue, I do not know if it was or not reported since there was no answer on the thread.

                    You should check the module's release logs to see if there is anything related there. You might be able to rebuild just that module. However, I would recommend using a more recent version anyway. The current LTS is 5.15 and Qt 6 just got released.

                    C Offline
                    C Offline
                    chrizbee
                    wrote on 26 Dec 2020, 13:13 last edited by chrizbee
                    #8

                    @SGaist
                    I've read some of the Connectivity: Bluetooth bugreports which do not yield any solutions...
                    Before building I've tested my code on windows with Qt 5.15.2 which results in the exact same "error".

                    So here's my problem:
                    My BLE device has the address: FF:FF:20:05:B3:E9 (hcitool lescan)
                    With gatttool I am able to subscribe to handle: 0x000e, uuid: 0000ffe1-0000-1000-8000-00805f9b34fb with this command:

                    gatttool -b FF:FF:55:03:9F:52 --char-write-req --handle=0x000e --value=0100 --listen
                    

                    In my application I'm doing the following (pseudocode):

                    agent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
                    // wait for QBluetoothDeviceDiscoveryAgent::deviceDiscovered(info)
                    control = QLowEnergyController::createCentral(info, this);
                    control->connectToDevice();
                    // wait for QLowEnergyController::connected
                    control->discoverServices();
                    // wait for QLowEnergyController::serviceDiscovered(uuid)
                    if (uuid == myUuid) {
                        service = control->createServiceObject(uuid, this);
                        // connect characteristicChanged, stateChanged, error, ...
                        service->discoverDetails();
                    }
                    // wait for QLowEnergyService::stateChanged(state)
                    if (state == QLowEnergyService::ServiceDiscovered) {
                        auto chs = service->characteristics();
                        for (QLowEnergyCharacteristic &c : chs) {
                            auto des = c.descriptors();
                            for (QLowEnergyDescriptor &d : des) {
                                qDebug() << d.name() << d.type() << d.handle() << d.uuid() << d.value();
                            }
                        }
                    

                    Unfortunately I'm not able to write to the descriptor QBluetoothUuid::ClientCharacteristicConfiguration because service->characteristic(myUuid).descriptors().size() is 0 (characteristic has no descriptors).

                    So why can I subscribe to the given uuid / handle with gatttool but not with Qt?

                    1 Reply Last reply
                    0
                    • S SGaist
                      26 Dec 2020, 12:14

                      Check the bug report system first, this might avoid you long hours of compilation.

                      C Offline
                      C Offline
                      chrizbee
                      wrote on 27 Dec 2020, 08:52 last edited by
                      #9

                      @SGaist Or should I create a new post that isn't related to downgrading Qt?

                      1 Reply Last reply
                      0
                      • KH-219DesignK Offline
                        KH-219DesignK Offline
                        KH-219Design
                        wrote on 29 Dec 2020, 19:28 last edited by
                        #10

                        Given both of these:

                        (1) The older post: https://forum.qt.io/topic/98115/low-energy-bluetooth-notifications-not-working

                        And (2) the current issue described here of being unable to convince Qt to attach to notifications because descriptors().size() is zero.

                        ... in my mind this definitely qualifies as a reportable bug at https://bugreports.qt.io

                        I'm half inclined to report it myself, but I don't have the requisite hardware for reproducing and testing this.

                        If I am reading this post (and the other one) correctly, then it looks like there is a valid BLE usage scenario that the Qt BLE code simply fails to account for. And this scenario is roughly described as "my BLE peripheral always sends notifications, despite not providing a 0x2902 descriptor with which to enable them."

                        Do any of these cover it?

                        https://bugreports.qt.io/browse/QTBUG-83363
                        https://bugreports.qt.io/browse/QTBUG-54806
                        https://bugreports.qt.io/browse/QTBUG-89723

                        If not, then please report it. BLE seems to continue to grow in popularity, so getting this working for future users (not to mention your own use case!) would be a great service.

                        www.219design.com
                        Software | Electrical | Mechanical | Product Design

                        C 1 Reply Last reply 30 Dec 2020, 11:39
                        2
                        • KH-219DesignK KH-219Design
                          29 Dec 2020, 19:28

                          Given both of these:

                          (1) The older post: https://forum.qt.io/topic/98115/low-energy-bluetooth-notifications-not-working

                          And (2) the current issue described here of being unable to convince Qt to attach to notifications because descriptors().size() is zero.

                          ... in my mind this definitely qualifies as a reportable bug at https://bugreports.qt.io

                          I'm half inclined to report it myself, but I don't have the requisite hardware for reproducing and testing this.

                          If I am reading this post (and the other one) correctly, then it looks like there is a valid BLE usage scenario that the Qt BLE code simply fails to account for. And this scenario is roughly described as "my BLE peripheral always sends notifications, despite not providing a 0x2902 descriptor with which to enable them."

                          Do any of these cover it?

                          https://bugreports.qt.io/browse/QTBUG-83363
                          https://bugreports.qt.io/browse/QTBUG-54806
                          https://bugreports.qt.io/browse/QTBUG-89723

                          If not, then please report it. BLE seems to continue to grow in popularity, so getting this working for future users (not to mention your own use case!) would be a great service.

                          C Offline
                          C Offline
                          chrizbee
                          wrote on 30 Dec 2020, 11:39 last edited by
                          #11

                          @KH-219Design Your last link is my bugreport :D
                          I'm currently testing other Qt versions to see for which version bump it'll stop working.

                          1 Reply Last reply
                          1
                          • C Offline
                            C Offline
                            chrizbee
                            wrote on 30 Dec 2020, 12:41 last edited by
                            #12

                            Update: The application does not receive any notifications without configuration for Qt versions >= 5.11.0.

                            • Qt 5.10.1: Working
                            • Qt 5.11.0: Not working

                            It's most probably due to this change:
                            [QTBUG-46819] Ported QLowEnergyController central mode to BlueZ's DBus API. The new implementation is used when BlueZ 5.42+ is detected.

                            1 Reply Last reply
                            1
                            • KH-219DesignK Offline
                              KH-219DesignK Offline
                              KH-219Design
                              wrote on 30 Dec 2020, 19:40 last edited by
                              #13

                              Excellent investigation. I am now following that bug ticket. Eager to see where it leads...

                              www.219design.com
                              Software | Electrical | Mechanical | Product Design

                              C 1 Reply Last reply 31 Dec 2020, 13:55
                              0
                              • KH-219DesignK KH-219Design
                                30 Dec 2020, 19:40

                                Excellent investigation. I am now following that bug ticket. Eager to see where it leads...

                                C Offline
                                C Offline
                                chrizbee
                                wrote on 31 Dec 2020, 13:55 last edited by
                                #14

                                @KH-219Design Do you think there is a workaround for the time being?
                                I don't want to build Qt 5.9.9 for my Raspberry Pi...

                                1 Reply Last reply
                                0
                                • KH-219DesignK Offline
                                  KH-219DesignK Offline
                                  KH-219Design
                                  wrote on 1 Jan 2021, 01:29 last edited by
                                  #15

                                  I don't want to rule out the possibility of a workaround, but if I had to make a wager, I would say it is a long shot.

                                  I have never cross-compiled Qt, so I'm not sure if it is tricky to cross-compile for rpi using a linux host. If you don't want to cross-compile, then I would imagine that the main issue with building for rpi is that you would be building on the rpi, and this will take hours.

                                  But hey... if you start now, then in a few hours this can all be over ;)

                                  Other than the idea of it taking a long time, are there other concerns with building from source? I actually do it often (once a month or so) on Linux, and it isn't that bad.

                                  I've posted about the steps before (but this is all for Ubuntu):

                                  https://forum.qt.io/topic/119026/how-much-time-will-it-take-to-build-qt-5-15-x-source-package/10

                                  https://forum.qt.io/topic/114784/definitive-guide-to-building-source-from-downloaded-run-file/33

                                  Whenever I build any large open source project, it seems that the trickiest part is often just getting all the other '*dev' library dependencies installed first, so that the build can find everything and succeed.

                                  If something like this exists on raspbian, then you should be most of the way there:

                                  sudo apt-get build-dep qt5-default
                                  

                                  Another option would be to find someone who maintains rpi binaries for qt. Does no one maintain such a collection?

                                  www.219design.com
                                  Software | Electrical | Mechanical | Product Design

                                  C 1 Reply Last reply 1 Jan 2021, 13:55
                                  0
                                  • KH-219DesignK KH-219Design
                                    1 Jan 2021, 01:29

                                    I don't want to rule out the possibility of a workaround, but if I had to make a wager, I would say it is a long shot.

                                    I have never cross-compiled Qt, so I'm not sure if it is tricky to cross-compile for rpi using a linux host. If you don't want to cross-compile, then I would imagine that the main issue with building for rpi is that you would be building on the rpi, and this will take hours.

                                    But hey... if you start now, then in a few hours this can all be over ;)

                                    Other than the idea of it taking a long time, are there other concerns with building from source? I actually do it often (once a month or so) on Linux, and it isn't that bad.

                                    I've posted about the steps before (but this is all for Ubuntu):

                                    https://forum.qt.io/topic/119026/how-much-time-will-it-take-to-build-qt-5-15-x-source-package/10

                                    https://forum.qt.io/topic/114784/definitive-guide-to-building-source-from-downloaded-run-file/33

                                    Whenever I build any large open source project, it seems that the trickiest part is often just getting all the other '*dev' library dependencies installed first, so that the build can find everything and succeed.

                                    If something like this exists on raspbian, then you should be most of the way there:

                                    sudo apt-get build-dep qt5-default
                                    

                                    Another option would be to find someone who maintains rpi binaries for qt. Does no one maintain such a collection?

                                    C Offline
                                    C Offline
                                    chrizbee
                                    wrote on 1 Jan 2021, 13:55 last edited by
                                    #16

                                    @KH-219Design I've actually built Qt directly on a Raspberry Pi 4 a couple of times. But I don't want to stick to the older version of Qt 5.9.9 if there's a workaround for more recent versions.

                                    [QTBUG-46819] Ported QLowEnergyController central mode to BlueZ's DBus API. The new implementation is used when BlueZ 5.42+ is detected. Earlier versions will continue to use the the previous custom GATT stack. The benefit of this change is improved co-existence with BlueZ which avoids interference between BlueZ and Qt and permits multiple Qt and platform apps being able to share BTLE connections. The custom GATT peripheral role implementation is still used on all BlueZ platforms.

                                    I thought of something like downgrading BlueZ to < 5.42 (see bold text). Might give that a try if possible.

                                    1 Reply Last reply
                                    1
                                    • C Offline
                                      C Offline
                                      chrizbee
                                      wrote on 2 Jan 2021, 11:17 last edited by chrizbee 1 Feb 2021, 11:25
                                      #17

                                      I've found a workaround for it:
                                      If you set the environment variable BLUETOOTH_FORCE_DBUS_LE_VERSION to anything below 5.42, Qt will use the old GATT stack implementation instead of BlueZ DBUS implementation. What I've tested:

                                      BLUETOOTH_FORCE_DBUS_LE_VERSION=5.41 ./BleTest
                                      

                                      I'll close this and keep the bugreport open since it's a missing feature / bug of the new implementation.

                                      Source: qlowenergycontroller.cpp and bluez5_helper.cpp

                                      1 Reply Last reply
                                      2
                                      • N Offline
                                        N Offline
                                        Nishantdawn
                                        wrote on 10 Jun 2024, 08:23 last edited by
                                        #18

                                        Hi I am facing the same issue on Qt 5.15.3 and Qt 6.5.3. I am cross compiling BLE code for Android arm64-v8a device.
                                        How can I force BLUETOOTH_FORCE_DBUS_LE_VERSION on the Android device?

                                        C 1 Reply Last reply 11 Jul 2024, 08:31
                                        0
                                        • N Nishantdawn referenced this topic on 10 Jun 2024, 09:25
                                        • N Nishantdawn
                                          10 Jun 2024, 08:23

                                          Hi I am facing the same issue on Qt 5.15.3 and Qt 6.5.3. I am cross compiling BLE code for Android arm64-v8a device.
                                          How can I force BLUETOOTH_FORCE_DBUS_LE_VERSION on the Android device?

                                          C Offline
                                          C Offline
                                          chrizbee
                                          wrote on 11 Jul 2024, 08:31 last edited by
                                          #19
                                          This post is deleted!
                                          1 Reply Last reply
                                          0

                                          • Login

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