From 7512a6e9155196a3ede34b8a552c7c8dfb955ad3 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 25 Sep 2018 20:56:56 -0700 Subject: Bluetooth: restart scan for different device on macOS This makes no sense, but apparently we need to start a fresh scan in order to be able to talk to a different BLE dive computer on the Mac. Signed-off-by: Dirk Hohndel --- core/btdiscovery.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'core') diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp index 0bacbadda..deef322e4 100644 --- a/core/btdiscovery.cpp +++ b/core/btdiscovery.cpp @@ -305,6 +305,15 @@ bool BTDiscovery::checkException(const char* method, const QAndroidJniObject *ob void BTDiscovery::discoverAddress(QString address) { +#if defined(Q_OS_MACOS) + // macOS appears to need a fresh scan if we want to switch devices + static QString lastAddress; + if (lastAddress != address) { + btDeviceInfo.clear(); + discoveryAgent->stop(); + lastAddress = address; + } +#endif if (!btDeviceInfo.keys().contains(address) && !discoveryAgent->isActive()) { qDebug() << "restarting discovery agent"; discoveryAgent->start(); -- cgit v1.2.3-70-g09d2