不会发出Qt和Android FeatureChanged [英] Qt and Android characteristicChanged is not emitted

查看:146
本文介绍了不会发出Qt和Android FeatureChanged的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android平台上测试我的应用程序时遇到问题.我在x86体系结构上有功能性的应用程序.该应用程序可以连接到Bluetooth LowEnergy设备并与其通信. BT设备是HM-10模块-串行线.

I have a problem with testing my application on Android platform. I have functional application on x86 architecture. This application can connect to Bluetooth LowEnergy device and communicate with it. BT device is HM-10 module - serial line.

但是,当我尝试使用相同的应用程序但仅针对Android进行编译时,我无法接收任何数据.另一方面,我可以在远程设备上看到来自移动终端的所有数据都已发送.

But when I try the same application, but just compiled for Android, I'm not able to receive any data back. On the other hand I can see on remote device that all data from mobile terminal are sent.

我怀疑可能的问题是未发出信号QLowEnergyService :: characteristicChanged.在文档 http://doc.qt.io/qt-5/qlowenergyservice.html 写道您应该注册更改,但是至少在PC上它是自动完成的.

What I suspect as a possible problem is that signal QLowEnergyService::characteristicChanged is not emitted. In the documentation http://doc.qt.io/qt-5/qlowenergyservice.html is written that you should register for changes, but at least on PC it is done automatically somehow.

有人可以帮助我吗?

推荐答案

您必须做一些魔术

QLowEnergyDescriptor notification = _characteristic.descriptor(
    QBluetoothUuid::ClientCharacteristicConfiguration);

if (!notification.isValid()) {
  qDebug() >> "QLowEnergyDescriptor not valid";
}

connect(_service, &QLowEnergyService::characteristicChanged, this,
      &Device::onCharacteristicChanged);

_service->writeDescriptor(notification, QByteArray::fromHex("0100"));

这篇关于不会发出Qt和Android FeatureChanged的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆