Releases: steamclock/bluejay
Fix flush listen
- Prevent indefinite flush
- Add missing cancellation handling
- Dedup listen semaphore signals
- Add missing semaphore signal for end listen
- Use timeout enum
Add timeout to synchronized listen
Allow handling stale or stuck listens when using the run background task.
Expose peripheral maximum write size
Useful when EDL is needed and the maximum write size is unknown.
Support connecting immediately after a disconnect
Connecting immediately after a disconnect wasn't possible due to a strict and slightly incorrect double connect protection. This has been fixed now.
Fix write and assemble
Apply the same recent fixes made to writeAndListen for writeAndAssemble as well:
- Better management of semaphore locks and releases
- Better usage of end listen
- Allow failing the operation if bluetooth becomes unavailable or if there's a disconnection after both the read and listen have been setup correctly
Add new bluetooth state variable
Use isBluetoothStateUpdateImminent
to check whether the central manager state is unknown
or resetting
.
Thank you @andeeliao!
Fix disconnect for certain end listen calls
Allow certain end listen calls in the writeAndListen API to propagate disconnect errors back to the synchronized peripheral correctly.
Fix disconnect clean up for run background task
- If there is a disconnect while a background task is running, defer the disconnection clean up it to the end of the background task to allow proper tear down of the Bluejay states
- Fix auto reconnect states to allow proper reconnection when expected
Improve Bluetooth reliability
- Improved handling and exiting the locks in write and listen for synchronized peripheral
- Improved handling of end listen completion for synchronized peripheral
- Improved handling of state restoration for the connecting and disconnecting states
- Fix connection timeout not working as expected
Remove implicit connection timeout
We have changed the connection API slightly.
We should not assume all connection requests need a timeout. There are in fact many cases where an indefinite connection request, the default of CoreBluetooth's connection, is necessary and useful.
This change now requires you to explicitly specify whether your connection has a timeout or not. This will give you greater control and transparency over how your connection requests will behave.
The connection API now has an additional timeout
parameter, and looks like this now:
public func connect(_ peripheralIdentifier: PeripheralIdentifier, timeout: Timeout, completion: @escaping (ConnectionResult) -> Void)