Closed semvis123 closed 2 years ago
Seems to be working correctly now. I don't know if this breaks the versions before Monterey.
Did they break the API in Monterey? LGTM anyway, let me know when you want this to be merged (as it's still marked as draft)
Did they break the API in Monterey?
Kinda, they changed some threading related behavior I think.
let me know when you want this to be merged
I just tested it on an older macOS version, and it appears to be broken. I guess I could check on which version it is and use the old method on older macOS.
Okay, it seems to be working correctly on both macOS versions (High Sierra and Monterey) now.
It's weird to me that such a fundamental thing would break on macOS. I think that it must be that we're doing something wrong, that probably introduces additional bugs. Can we try to find a solution that works on both versions?
It's weird to me that such a fundamental thing would break on macOS.
Yeah it's indeed weird, even some Xcode provided bluetooth tools seem to be broken.
Can we try to find a solution that works on both versions?
Yeah I guess that's a good idea, I will setup a High Sierra VM (to make testing a bit faster) and test a few more things.
I will setup a High Sierra VM
This didn't work, couldn't get bluetooth working in a macOS VM.
However I did discover a solution that works on both versions, but wakes the cpu every second on Monterey (which should only be needed on High Sierra)
std::unique_lock<std::mutex> lk(macOSBluetoothConnector->disconnectionMutex);
while (macOSBluetoothConnector->running) {
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:.1]];
macOSBluetoothConnector->disconnectionConditionVariable.wait_for(lk, std::chrono::milliseconds(1000), [&]() {
return !macOSBluetoothConnector->running;
});
}
lk.unlock();
I guess it is a decent solution for both versions.
Not quite sure that I understand the macOS concurrency model, but it sounds like it works this way. Merging :)
This brings back functionality, but it still consumes one full cpu core, so it isn't ready for merging. Closes #62