mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Bluetooth: discovery should always scan on macOS as well
Instead of only starting the scan when explicitly asked to do so in the BT dialog, create the discovery agent when the download dialog opens, since on macOS we cannot connect to a device without having scanned for it first. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c6b62cbe5c
commit
2ba3eab319
1 changed files with 10 additions and 11 deletions
|
|
@ -71,7 +71,7 @@ static dc_descriptor_t *getDeviceType(QString btName)
|
||||||
}
|
}
|
||||||
|
|
||||||
BTDiscovery::BTDiscovery(QObject*) : m_btValid(false),
|
BTDiscovery::BTDiscovery(QObject*) : m_btValid(false),
|
||||||
discoveryAgent(NULL)
|
discoveryAgent(nullptr)
|
||||||
{
|
{
|
||||||
if (m_instance) {
|
if (m_instance) {
|
||||||
qDebug() << "trying to create an additional BTDiscovery object";
|
qDebug() << "trying to create an additional BTDiscovery object";
|
||||||
|
|
@ -98,25 +98,24 @@ void BTDiscovery::BTDiscoveryReDiscover()
|
||||||
if (1) {
|
if (1) {
|
||||||
#endif
|
#endif
|
||||||
m_btValid = true;
|
m_btValid = true;
|
||||||
#if defined(Q_OS_WIN) || defined(Q_OS_IOS) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
#if !defined(Q_OS_ANDROID)
|
||||||
discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
|
if (discoveryAgent == nullptr) {
|
||||||
connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &BTDiscovery::btDeviceDiscovered);
|
discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
|
||||||
|
connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &BTDiscovery::btDeviceDiscovered);
|
||||||
|
}
|
||||||
qDebug() << "starting BLE discovery";
|
qDebug() << "starting BLE discovery";
|
||||||
discoveryAgent->start();
|
discoveryAgent->start();
|
||||||
#endif
|
#else
|
||||||
#if defined(Q_OS_ANDROID)
|
|
||||||
getBluetoothDevices();
|
getBluetoothDevices();
|
||||||
// and add the paired devices to the internal data
|
// and add the paired devices to the internal data
|
||||||
// So behaviour is same on Linux/Bluez stack and
|
// So behaviour is same on Linux/Bluez stack and
|
||||||
// Android/Java stack with respect to discovery
|
// Android/Java stack with respect to discovery
|
||||||
for (int i = 0; i < btPairedDevices.length(); i++) {
|
for (int i = 0; i < btPairedDevices.length(); i++)
|
||||||
btDeviceDiscoveredMain(btPairedDevices[i]);
|
btDeviceDiscoveredMain(btPairedDevices[i]);
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < btPairedDevices.length(); i++) {
|
for (int i = 0; i < btPairedDevices.length(); i++)
|
||||||
qDebug() << "Paired =" << btPairedDevices[i].name << btPairedDevices[i].address;
|
qDebug() << "Paired =" << btPairedDevices[i].name << btPairedDevices[i].address;
|
||||||
}
|
|
||||||
#if defined(Q_OS_IOS) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
#if defined(Q_OS_IOS) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue