hrChar always invalid! Is somebody can help me?
Unsolved
General and Desktop
-
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")); } } });