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

Bugfix: Reconnection #119

Merged
merged 4 commits into from
Mar 11, 2025
Merged

Bugfix: Reconnection #119

merged 4 commits into from
Mar 11, 2025

Conversation

philips77
Copy link
Member

This PR fixes #113.

As stated in #113 (comment), the solution accepted in #102 introduced a bug preventing from reconnecting to a peripheral using native Central Manager. The peripheral instance was removed from managed peripherals on disconnection and reconnection was failing.

In #98 (comment) a different approach was also proposed, where the mock services were cleared. This PR applies this solution, but making them clear on disconnection (before the callback) to match the actual behavior when using a native API.

This seems to fix the reconnection problem.

Additionally, this PR modifies the sample nRF Blinky app adding a button to reconnect to a peripheral after a disconnection. I18n was fixed for displaying disconnections and some error messages.

@@ -88,7 +88,7 @@ class BlinkyPeripheral: NSObject, CBPeripheralDelegate {
self.post(.blinkyDidDisconnect(self, error: nil))
}
}
onConnected {
_ = onConnected {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, and the onStateChange observer never gets dispose. But that's not a big deal, as they should live until the app is killed anyway.

@philips77 philips77 merged commit 4d79129 into main Mar 11, 2025
1 check passed
@philips77 philips77 deleted the bugfix/reconnection branch March 11, 2025 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reconnection on disconnection when forceMock == false does not work due
1 participant