-
Notifications
You must be signed in to change notification settings - Fork 88
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 Peripheral
state not updating upon connection
#300
Conversation
…in case of disconnect due to bluetooth turned off
Sorry, I don't follow how using a |
It took us a while to figure this one out. So after the change which disconnects the peripherals in the event that bluetooth is powered off, the connectionState would remain in the previous state and not change. This would result in the peripheral state being DISCONNECTED, and the ConnectionState still having the most recent state emitted. Then once you call a connect on the peripheral, the peripheral state would change to connected, but the ConnectionState would not emit again because the state was the same as before. So changing to a shared flow ensures that the ConnectionState emits even if it is the same value as before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @burnhamd! Great investigative work to figure out the problem and fix! 💯
Peripheral
state not updating upon connection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @burnhamd
References issue #290
Found issue where if the device is disconnected and delegate does not return a didDisconnect callback on IOS (for example when bluetooth is turned off) that the state flow would stay in connecting and never show connected in the peripheral side during reconnect.
This fixes that by using shared flow instead of state flow