Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix already connected pheriperal after restoration #235

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gKamelo
Copy link

@gKamelo gKamelo commented Apr 26, 2020

Fixes #206:

Summary of Problem:

In case of device already being connected during restoration phase in CBCentralManagerDelegate.centralManager(_ central: CBCentralManager, willRestoreState dict: [String: Any]) Bluejay assign connected device to connectedPeripheral. It breaks further logic as Bluejay didn't start connection explicitly yet CBCentralManagerDelegate.centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) will be called along the road, which leads to precondition fatal error due to lack of connectingPeripheral.

Proposed Solution:

I assume that while Bluejay have already connectedPeripheral it is enough to fill missing gap by assigning it to connectingPeripheral. In addition i'm checking current queue task to not break further processing.

As i'm not familiar with the codebase very well i tried to patch the problem with as less as possible changes, but i can imagine that's not perfect and can lead to some unknown to me side effects, so really appreciate any feedback to this PR.

In next week i will probably do more tests around this patch so maybe sth else will came up;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant