Skip to content

Commit 4a14ddc

Browse files
committedMar 10, 2025··
ios: remember device for automatic reconnection only after pairing
If user aborts pairing, we don't want to auto-connect to this device in the future.
1 parent 3547760 commit 4a14ddc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎frontends/ios/BitBoxApp/BitBoxApp/Bluetooth.swift

+5-4
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ class BluetoothManager: NSObject, ObservableObject, CBCentralManagerDelegate, CB
143143
state.connecting = false
144144
updateBackendState()
145145

146-
// Add to paired devices
147-
pairedDeviceIdentifiers.insert(peripheral.identifier.uuidString)
148-
149146
connectedPeripheral = peripheral
150147
peripheral.delegate = self
151148
peripheral.discoverServices(nil)
@@ -239,7 +236,11 @@ class BluetoothManager: NSObject, ObservableObject, CBCentralManagerDelegate, CB
239236
if characteristic == pProduct {
240237
print("BLE: product changed: \(String(describing: parseProduct()))")
241238
// We can only read the product characteristic when paired.
242-
isPaired = true
239+
if !isPaired {
240+
isPaired = true
241+
// Add to paired devices
242+
pairedDeviceIdentifiers.insert(peripheral.identifier.uuidString)
243+
}
243244
// Invoke device manager to scan now, which will make it detect the device being connected
244245
// (or disconnected, in case the product string indicates that) now instead of waiting for
245246
// the next scan.

0 commit comments

Comments
 (0)
Please sign in to comment.