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. Low Energy Bluetooth: Notifications not working

Low Energy Bluetooth: Notifications not working

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 2.0k 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.
  • N Offline
    N Offline
    nowayback
    wrote on last edited by
    #1

    I am trying to connect to a TI CC2540-based Bluetooth development board ("Beetle BLE"). It sets up a serial bridge to a microcontrolling unit. For this purpose, one single characteristic is used: when writing data to this characteristic, it is transmitted to the MCU, while data coming from the MCU is transferred using characteristic notifications (Polling / reading the characteristic is not really supported and would not make that much sense anyway).

    The only descriptor this characteristic comes with is a QBluetoothUuid::CharacteristicUserDescription (0x2901) descriptor. There is no QBluetoothUuid::ClientCharacteristicConfiguration (0x2902) descriptor to enable notifications, as notifications are enabled by default. For example, when using a MCU firmware which outputs data every 1sec, the output of gatttool is:

    $ gatttool -b 64:CF:D9:35:A0:CE -I
    [64:CF:D9:35:A0:CE][LE]> connect
    Attempting to connect to 64:CF:D9:35:A0:CE
    Connection successful
    Notification handle = 0x0025 value: 61 6c 69 76 65 0d 0a
    Notification handle = 0x0025 value: 61 6c 69 76 65 0d 0a
    Notification handle = 0x0025 value: 61 6c 69 76 65 0d 0a
    [64:CF:D9:35:A0:CE][LE]> quit

    The Android demo application also seems to just install notification callback handlers and everything is fine.

    My problem is, that Qt does not receive these notifications at all.
    Using Qt, I can send data to the MCU using the respective characteristic without any issues

    service->writeCharacteristic(..., "test");
    

    , but the notification slot is never called:

    connect(service, SIGNAL(characteristicChanged(const QLowEnergyCharacteristic &, const QByteArray &)),
    this, SLOT(service_characteristicChanged(const QLowEnergyCharacteristic &, const QByteArray &)));
    

    . I used the heartlistener example project as reference, but even rewriting the complete code did not help.

    Android- and PC-based Low Energy tools have no problems receiving them. I activated the qt.bluetooth.bluez logging filter but could not see any hints that there are receipted notifications at all.

    It seems I am not the only one with this problem.

    I have tested:

    • RPi 3B+, Qt 5.9.1 and 5.11.2, onboard Bluetooth device
    • RPi 3B+, Qt 5.9.1 and 5.11.2, USB BLE stick
    • Ubuntu, Qt 5.11.3, onboard Qualcomm BLE
      with all showing the same issue. I always used the bluez backend, I have not been able to test WinRT and Android.

    I even tried to write 0x0100 to the non-existing 0x2902 descripter in case Qt needs this to enable notifications internally, but not surprisingly this did not help. I have also not found any clues in the QtConnectivity source.

    Is there something I missed? How can I narrow down the cause of the problem?

    Thanks.

    1 Reply Last reply
    2
    • N Offline
      N Offline
      nowayback
      wrote on last edited by
      #2

      After several desperate tries, I could finally solve my issue: I downgraded Qt from 5.11.3 down to 5.7.1, and my code is working perfectly there (without any changes).

      I'm slightly annoyed at myself that I actually tried to downgrade Qt before, but I only downgraded to 5.9.1, which was not sufficient.

      chrizbeeC 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        That looks like a regression. Did you already took a look at the bug report system ?

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

        1 Reply Last reply
        0
        • N nowayback

          After several desperate tries, I could finally solve my issue: I downgraded Qt from 5.11.3 down to 5.7.1, and my code is working perfectly there (without any changes).

          I'm slightly annoyed at myself that I actually tried to downgrade Qt before, but I only downgraded to 5.9.1, which was not sufficient.

          chrizbeeC Offline
          chrizbeeC Offline
          chrizbee
          wrote on last edited by
          #4

          @nowayback Almost two years later I had the exact same problem.
          Instead of downgrading Qt you can run your app like this.

          BLUETOOTH_FORCE_DBUS_LE_VERSION=5.41 /path/to/YourApplication
          

          The version number should be anything below 5.41 to use the old GATT stack implementation. For further information see this post.

          1 Reply Last reply
          2
          • S Offline
            S Offline
            sandro4912
            wrote on last edited by
            #5

            I also run now in this issue using Qt 5.15.

            I tried to send a command to a thermostate and expected an response from it. After using the workaround menthioned above everything works.

            Is there a plan to fix this or is it maybe already fixed in Qt > 6 ?

            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