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. hrChar always invalid! Is somebody can help me?
Qt 6.12 LTS is out! See what's new in the release blog

hrChar always invalid! Is somebody can help me?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 232 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.
  • Z Offline
    Z Offline
    Zhang_Yubiao
    wrote on last edited by
    #1

    if(m_service)
    {
    // 服务对象创建成功后,坚挺服务状态变化,如果状态变成已发现,则进行后续服务下特征对象获取
    connect(m_service,&QLowEnergyService::stateChanged, this, this
    {
    qDebug() << "service state change" << m_service->state() << ",||||||----";

                            //发现服务, 建立characteristic对象实例
                            if(m_service->state() == QLowEnergyService::ServiceDiscovered)
                            {
                                QLowEnergyCharacteristic hrChar = m_service->characteristic(QBluetoothUuid(QUuid("6e400003-b5a3-f393-e0a9-e50e24dcca9e")));
    
    
                                if(!hrChar.isValid())
                                {
                                    qDebug() << "characteristic 6e400003-b5a3-f393-e0a9-e50e24dcca9e error:::";
                                }
                                // 设置特征对象可用
                                //enable the chracteristic notification by write 0x01 to client characteristic configuration
                                QLowEnergyDescriptor m_notificationDesc = hrChar.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
                                if (m_notificationDesc.isValid())
                                {
                                    if(hrChar.properties() & QLowEnergyCharacteristic::Notify) {
                                         qDebug() << "abcdef";
                                    }
                                    m_service->writeDescriptor(m_notificationDesc, QByteArray::fromHex("0100"));
                                }
                            }
                        });
    
    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