Fix: corebluetooth write without response - #441
szymonlesisz wants to merge 2 commits into
Conversation
ea543f5 to
e33736c
Compare
e33736c to
b000925
Compare
|
i've noticed this pull request where is also OS version/support check added. so im wondering maybe should i create CoreBluetoothInternal.support field? for example: |
b000925 to
3e6056f
Compare
|
Thanks for the PR! This is definitely an issue, but I think there's a way to implement using the delegate, as I'd really worry about blocking the corebluetooth thread with waits. We're gonna go with that, should be in for v0.12. We've got a hardware peripheral test system coming in too, and I've added a WriteWithoutResponse burst test to make sure this works. |
Has this issue been fixed one way or another in 0.12 or 0.13 ? |
|
@prusnak Should've come in around 0.12 I think. |
Hi,
I've run into issue with
WriteType::WithoutResponseon macos.im trying to send ~2MB of data in shortest time possible however corebluetooth keeps loosing the packects shortly after the start.
while looking up for solutions in other bluetooth libs i came across this technical document and this guide
i belive the ultimate fix would be to use
peripheral.peripheralIsReadyToSendWriteWithoutResponseas described in the guide but i dont see a easy way how to implement this method (missing CBPeripheralDelegate reference)so i decided to use attempts loop and check every 15ms (
Interval Minstated in the document) if it is safe to send another packet. the loop ends if true or after 100 retries (1500ms <connSupervisionTimeoutstated in the document)The only problem is that
canSendWriteWithoutResponsewas introduced in macos 11.0 (Big Sur) but it behaves unreliably until 11.2 - returning false until the first write is performed. That is why i've addedcan_send_without_response_supportedflag which is set from theNSProcessInfo.if you dont care about older OS releases (Big Sur was released in november 2020) i can drop the the second commit