Bugfix: State restoration for mock #123
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 fixes the Central Manager state restoration for mock central manager.
I acually tried starte restoration using a native API and did my best to repliacte the same behavior using mock implementation.
Changes
bluetooth-central
- this was added to nRF Blinky sample app.IOS-CoreBluetooth-Mock/Example/nRFBlinky/Models/BlinkyManager.swift
Lines 50 to 58 in 2991245
CBCentralManagerDelegate
report centralManager(_:willRestoreState:) just after it has been initiated, before its state changes to.poweredOn
.CBMPeripheral
in this library)CBMCentralManagerMock
has a static propertysimulateStateRestoration
. An example, how it can be used is inAppDelegate
:IOS-CoreBluetooth-Mock/Example/nRFBlinky/AppDelegate.swift
Lines 67 to 82 in 2991245
Note, that the
CBMCentralManagerRestoredStatePeripheralsKey
key allows to setCBMPeripheralSpec
to be returned to the delegate.CBMPeripheral
will be in stae.connected
, or.connecting
, depending on whether the device is in range, or not. Non-connectable peripheral specs are ignored.