我是新的蓝牙低能( BLE )设备开发,我必须开发一个HMI (在Windows 10),能够与BLE设备通信。
为此,我选择用Qtv5.14.2开发我的SW,其中包括用于蓝牙通信的API。
我正处于第一步,那就是我周围的扫描设备。对于这个测试,我周围有一些标准的蓝牙设备,还有一个BLE工具包(北欧nRF52),它可以永久地发布广告。
我的问题是:当我运行我的代码时,我可以在周围找到标准的蓝牙设备,而不是BLE设备。(有了另一款应用程序,我就能找到所有的东西。)
下面是我的代码: 1)初始化蓝牙com并启动它的构造函数:
CemBluetooth::CemBluetooth(QObject *parent) : QObject(parent)
{
discoveryAgent = new QBluetoothDeviceDiscoveryAgent();
discoveryAgent -> setLowEnergyDiscoveryTimeout(10000); // in ms
connect(discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)), this, SLOT(addDevice(const QBluetoothDeviceInfo&)));
connect(discoveryAgent, SIGNAL(finished()), this, SLOT(f_ctrl_bl_scanBlDevicesFinished()));
discoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
}2)提取设备的槽addDevice()发现:
void CemBluetooth::addDevice(const QBluetoothDeviceInfo& device)
{
std::cout << "Device discovered: ";
//if (device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) // i shunt this condition for the moment, in order to detect all device.
//{
QString name1 = device.name();
std::cout << name1.toStdString() << std::endl;
//}
}你能帮我找出解决办法吗?
发布于 2020-05-16 06:53:35
问题解决了!我只需将编译器从minGW更改为MSVC,它就能正常工作。确切的原因对我来说还不清楚,但解决办法就在这里。
发布于 2022-01-27 18:51:27
为未来的游客提供一些信息:
"Win32后端已被移除。当Qt被构建为混合时,将不会有一个正常工作的蓝牙后端。“
链接:https://doc-snapshots.qt.io/qt6-dev/qtbluetooth-changes-qt6.html
https://stackoverflow.com/questions/61753002
复制相似问题