-
Notifications
You must be signed in to change notification settings - Fork 1.9k
BLE: tell user to forget existing Omi when pairing is broken #7132
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
base: main
Are you sure you want to change the base?
Changes from all commits
2578e10
9a66cce
173367c
2f15a91
c21e088
0c57a33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||||||||||||||||||||||||||||||||||
| import Flutter | ||||||||||||||||||||||||||||||||||||||
| import UIKit | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /// Bridges Pigeon BleHostApi calls to OmiBleManager. | ||||||||||||||||||||||||||||||||||||||
| final class BleHostApiImpl: BleHostApi { | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -101,4 +102,27 @@ final class BleHostApiImpl: BleHostApi { | |||||||||||||||||||||||||||||||||||||
| // No-op on iOS — state restoration handles background reconnection | ||||||||||||||||||||||||||||||||||||||
| completion(.success("")) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| func openBluetoothSettings() throws { | ||||||||||||||||||||||||||||||||||||||
| // Try the Bluetooth-specific deep-link first; Apple has restricted this URL | ||||||||||||||||||||||||||||||||||||||
| // on newer iOS versions. canOpenURL would always return false here without | ||||||||||||||||||||||||||||||||||||||
| // an LSApplicationQueriesSchemes entry for App-Prefs (a non-public scheme), | ||||||||||||||||||||||||||||||||||||||
| // so check the open() completion handler's success flag instead — that | ||||||||||||||||||||||||||||||||||||||
| // reflects what actually happened. Fall back to the app's settings page | ||||||||||||||||||||||||||||||||||||||
| // (UIApplication.openSettingsURLString) which is guaranteed to open and at | ||||||||||||||||||||||||||||||||||||||
| // least gets the user into Settings. | ||||||||||||||||||||||||||||||||||||||
| let bluetoothUrl = URL(string: "App-Prefs:root=Bluetooth") | ||||||||||||||||||||||||||||||||||||||
| let appSettingsUrl = URL(string: UIApplication.openSettingsURLString) | ||||||||||||||||||||||||||||||||||||||
| DispatchQueue.main.async { | ||||||||||||||||||||||||||||||||||||||
| if let url = bluetoothUrl { | ||||||||||||||||||||||||||||||||||||||
| UIApplication.shared.open(url, options: [:]) { success in | ||||||||||||||||||||||||||||||||||||||
| if !success, let settingsUrl = appSettingsUrl { | ||||||||||||||||||||||||||||||||||||||
| UIApplication.shared.open(settingsUrl, options: [:], completionHandler: nil) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } else if let url = appSettingsUrl { | ||||||||||||||||||||||||||||||||||||||
| UIApplication.shared.open(url, options: [:], completionHandler: nil) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+116
to
+126
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On iOS 9+,
Suggested change
|
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
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.
GATT_INSUF_ENCRYPTION(15) is returned by Android when a peripheral requires an encrypted link but bonding hasn't been established yet — which is exactly what happens the first time a new user tries to connect to an Omi that mandates bonding. In that flow Android typically disconnects with status 15 before presenting the system pairing dialog; the re-bond occurs on the next automatic reconnect attempt. Mapping status 15 topairing_losthere will: (1) display "Can't connect to your Omi — forget the device" to a user who has never paired before, and (2) skip the retry that would let Android complete the bond negotiation.GATT_AUTH_FAIL(137) is the reliable broken-bond signal; the status 15 guard should either be removed or restricted to cases where a prior bond record is already known to exist.