Unsolved qtconnectivity "Device discovery aborted due to unexpected adapter changes"
-
this error happens from time to time (on Ubuntu and Raspbian) while trying to repeatedly scan for BLE devices with deviceDiscoveryAgent
using http://doc.qt.io/qt-5/qbluetoothdevicediscoveryagent.html#QBluetoothDeviceDiscoveryAgent-1 like this:#include "controller.h"
#include <QDebug>Controller::Controller(QObject *parent) : QObject(parent)
{
qDebug()<<"found " <<QBluetoothLocalDevice::allDevices().size()<<" devices";
for (int i=0; i<QBluetoothLocalDevice::allDevices().size(); ++i)
{
qDebug()<< QString ("dongle found, address - %1").arg(QBluetoothLocalDevice::allDevices().at(i).address().toString());
}m_deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); connect(m_deviceDiscoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)), this, SLOT(foundDevice(const QBluetoothDeviceInfo&))); connect(m_deviceDiscoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this, SLOT(deviceScanError(QBluetoothDeviceDiscoveryAgent::Error))); connect(m_deviceDiscoveryAgent, SIGNAL(finished()), this, SLOT(scanFinished())); m_deviceDiscoveryAgent->start();
}
void Controller::foundDevice(const QBluetoothDeviceInfo &beacon)
{
if (beacon.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration)
{
qWarning() << "Discovered LE Device name: " << beacon.name() << " Address: " << beacon.address().toString()
<< "rssi "<<beacon.rssi();
}
}void Controller::deviceScanError(QBluetoothDeviceDiscoveryAgent::Error)
{
qWarning() << "and here errors go";
}void Controller::scanFinished()
{
qDebug()<< "!!scan finished!!-------------------";
m_deviceDiscoveryAgent->stop();
QTimer::singleShot(2000, this, SLOT(startScan()));
}void Controller::startScan()
{
qDebug()<< "==================scan started again=================";
qDebug()<<"list of discovered devices is empty - "
<< m_deviceDiscoveryAgent->discoveredDevices().isEmpty();
m_deviceDiscoveryAgent->start();
}and such an error is nowhere on the internet except for sites like http://code.qt.io/cgit/qt/qtconnectivity.git/commit/?id=5382ada3cb21cfa2721e4f50ced2d288c156018b
can anyone explain what it means? -
Have you found a solution? I'm in the same situation and looking for a stable solution!
-
No. I gave up searching devices with QBluetoothDeviceDiscoveryAgent, as it does not seem "to like" being stopped and started again in the same thread. And frankly speaking stopping/starting it is useless.
Instead I go with bluez "hcitool lescan" in QProcess
-
The fix for this bug is stated in https://bugreports.qt.io/browse/QTBUG-53715. Next target are 5.6.2 and 5.7.1. Should be easy to cherry-pick as well.