summaryrefslogtreecommitdiff
path: root/src/bluetooth/osx/osxbtdeviceinquiry.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth/osx/osxbtdeviceinquiry.mm')
-rw-r--r--src/bluetooth/osx/osxbtdeviceinquiry.mm19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/bluetooth/osx/osxbtdeviceinquiry.mm b/src/bluetooth/osx/osxbtdeviceinquiry.mm
index 2fd0d2db..4757331c 100644
--- a/src/bluetooth/osx/osxbtdeviceinquiry.mm
+++ b/src/bluetooth/osx/osxbtdeviceinquiry.mm
@@ -112,11 +112,14 @@ const uint8_t IOBlueoothInquiryLengthS = 15;
m_active = true;
[m_inquiry clearFoundDevices];
+
+ qCDebug(QT_BT_OSX) << "Starting device inquiry with"
+ << IOBlueoothInquiryLengthS << "second timeout limit.";
const IOReturn result = [m_inquiry start];
if (result != kIOReturnSuccess) {
// QtBluetooth will probably convert an error into UnknownError,
// losing the actual information.
- qCWarning(QT_BT_OSX) << "failed with IOKit error code:" << result;
+ qCWarning(QT_BT_OSX) << "device inquiry start failed with IOKit error code:" << result;
m_active = false;
} else {
// Docs say it's 10 s. by default, we set it to 15 s. (see -initWithDelegate:),
@@ -124,11 +127,14 @@ const uint8_t IOBlueoothInquiryLengthS = 15;
watchDog.reset(new QTimer);
watchDog->connect(watchDog.get(), &QTimer::timeout, watchDog.get(), [self]{
qCWarning(QT_BT_OSX, "Manually interrupting IOBluetoothDeviceInquiry");
+ qCDebug(QT_BT_OSX) << "Found devices:" << [m_inquiry foundDevices];
[self stop];
});
watchDog->setSingleShot(true);
- watchDog->setInterval(IOBlueoothInquiryLengthS * 2 * 1000); // Let's make it twice as long.
+ // Let's use 17 s. so that IOBluetooth, if it respects 'inquiryLength'
+ // has a chance to stop before we do:
+ watchDog->setInterval((IOBlueoothInquiryLengthS + 2) * 1000);
watchDog->start();
}
@@ -148,6 +154,8 @@ const uint8_t IOBlueoothInquiryLengthS = 15;
- (void)deviceInquiryComplete:(IOBluetoothDeviceInquiry *)sender
error:(IOReturn)error aborted:(BOOL)aborted
{
+ qCDebug(QT_BT_OSX) << "deviceInquiryComplete, error:" << error
+ << "user-stopped:" << aborted;
if (!m_active)
return;
@@ -158,11 +166,11 @@ const uint8_t IOBlueoothInquiryLengthS = 15;
if (error != kIOReturnSuccess && !aborted) {
// QtBluetooth has not too many error codes, 'UnknownError' is not really
- // useful, report the actual error code here:
+ // useful, log the actual error code here:
qCWarning(QT_BT_OSX) << "IOKit error code: " << error;
- m_delegate->error(error);
// Let watchDog to stop it, calling -stop at timeout, otherwise,
- // it looks like inquiry continues and keeps reporting new devices found.
+ // it looks like inquiry continues even after this error and
+ // keeps reporting new devices found.
} else {
// Either a normal completion or from a timer slot.
watchDog.reset();
@@ -174,6 +182,7 @@ const uint8_t IOBlueoothInquiryLengthS = 15;
- (void)deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry *)sender
device:(IOBluetoothDevice *)device
{
+ qCDebug(QT_BT_OSX) << "deviceInquiryDeviceFound:" << [device nameOrAddress];
if (sender != m_inquiry) // Can never happen in the current version.
return;