Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. need help to used window10 qt version 5.14.2 qbleutooth characteristicChanged Slot is not running,
Qt 6.12 LTS is out! See what's new in the release blog

need help to used window10 qt version 5.14.2 qbleutooth characteristicChanged Slot is not running,

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 895 Views 1 Watching
  • 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.
  • Q Offline
    Q Offline
    qixin
    wrote on last edited by
    #1

    hi guys,i copy this example to my project,write m_service->writeDescriptor(m_notificationDesc, QByteArray::fromHex("0100")); is ok,
    devices can received.but device notify data is not can trigger characteristicChanged Slot, Hope that the big guys help to answer.Thank you

    In some cases the peripheral generates value updates which the central is interested in receiving. In order for a characteristic to support such notifications it must have the QLowEnergyCharacteristic::Notify or QLowEnergyCharacteristic::Indicate property and a descriptor of type QBluetoothUuid::ClientCharacteristicConfiguration. Provided those conditions are fulfilled notifications can be enabled as shown in the following code segment:

      //PreCondition: service details already discovered
      QLowEnergyCharacteristic batteryLevel = service->characteristic(
                  QBluetoothUuid::BatteryLevel);
      if (!batteryLevel.isValid())
          return;
    
      QLowEnergyDescriptor notification = batteryLevel.descriptor(
                  QBluetoothUuid::ClientCharacteristicConfiguration);
      if (!notification.isValid())
          return;
    
      // establish hook into notifications
      connect(service, SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray)),
              this, SLOT(characteristicChanged(QLowEnergyCharacteristic,QByteArray)));
    
      // enable notification
      service->writeDescriptor(notification, QByteArray::fromHex("0100"));
    
      // disable notification
      //service->writeDescriptor(notification, QByteArray::fromHex("0000"));
    
      // wait until descriptorWritten() signal is emitted
      // to confirm successful write
    

    The example shows a battery level characteristic which updates the central on every value change. The notifications are provided via the characteristicChanged() signal. More details about this mechanism are provided by the Bluetooth Specification.

    1 Reply Last reply
    0
    • Paul ColbyP Offline
      Paul ColbyP Offline
      Paul Colby
      wrote on last edited by
      #2

      Hi @qixin, your code looks right to me, assuming the device you're talking to does indeed support BLE Notify for that characteristic.

      Two things I would try. First, update your connect to use the newer syntax, like:

          connect(service, &QLowEnergyService::characteristicChanged,
                  this, &YourClassName::characteristicChanged);
      

      This will just allow the compiler to catch any argument errors you might have there (though Qt should be logging an warning at runtime, if that was the problem).

      (BTW, you can make that connection as soon as service is constructed if you like, so you don't miss the first characteristicChanged event ;)

      Then, enable the QtBluetooth Logging Categories; something like this:

      QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
      

      That might give you some hints to why its not working.

      Cheers.

      PS. Are you able / willing to tell us what device you're talking to? It might be helpful.

      Q 1 Reply Last reply
      2
      • Q Offline
        Q Offline
        qixin
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qixin
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • Paul ColbyP Paul Colby

            Hi @qixin, your code looks right to me, assuming the device you're talking to does indeed support BLE Notify for that characteristic.

            Two things I would try. First, update your connect to use the newer syntax, like:

                connect(service, &QLowEnergyService::characteristicChanged,
                        this, &YourClassName::characteristicChanged);
            

            This will just allow the compiler to catch any argument errors you might have there (though Qt should be logging an warning at runtime, if that was the problem).

            (BTW, you can make that connection as soon as service is constructed if you like, so you don't miss the first characteristicChanged event ;)

            Then, enable the QtBluetooth Logging Categories; something like this:

            QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
            

            That might give you some hints to why its not working.

            Cheers.

            PS. Are you able / willing to tell us what device you're talking to? It might be helpful.

            Q Offline
            Q Offline
            qixin
            wrote on last edited by
            #5

            hi it connected ble5.0 micro chip.thanks you very much! i used QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); can privide some information to find bug. now it can be used。
            but i find new problem used void QLowEnergyController::connectionUpdated(const QLowEnergyConnectionParameters &newParameters) it can not running slot,seem not find information can solution. can you please some advice? thanks

            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
            • Unsolved