New feature: Auto Reconnect (iOS 17+) #127
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for Auto Reconnect feature, added in iOS 17 with CBConnectPeripheralOptionEnableAutoReconnect.
Initialization
Connection with Auto Reconnection enabled is initiated with this flag:
IOS-CoreBluetooth-Mock/Example/nRFBlinky/Models/BlinkyManager.swift
Lines 98 to 105 in 78a577e
It's supported on iOS 17 and newer.
Besides this flag, a new delegate method was added to iOS API:
This callback is ONLY CALLED when there the
centralManager(_:didDisconnectPeripheral:error)
is not implemented, and only on iOS 17+ (despite what the documentation says).CoreBluetooth Mock
This PR adds the flag and the above callback to the library. For mock devices, the automatic connection will happen on the first received connectable packet from a mock peripheral.
However, it was not possible to reproduce this (unintended? undocumented? diffcult to use?) behavior of NOT calling this delegate method when the previous
centralManager(_:didDisconnectPeripheral:error)
was implemented (the library has to implement it, but can't check if the user has implemented it using Swift).Instead, this delegate method will be called from the library and the default implementation will call the old one. So, if the app implements only the old one, only the old one will be called, like before. If the new and old one is implemented, the old one will not be implemented. This is DIFFERENT from the native behavior, which calls only the new one in such case.
We recommend only using the new one, which in this library will be called also for iOS pre-17.